Skip to contentSkip to conversation

Move read_mostly definition to asm/cache.h

PATCH In review Kyle McMartin 3 participants 5 messages Jan 11, 2006 – Jan 15, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Move read_mostly definition to asm/cache.h

From: Kyle McMartin <[email protected]>

Seems like needless clutter having a bunch of #if defined(CONFIG_$ARCH) in include/linux/cache.h. Move the per architecture section definition to asm/cache.h, and keep the if-not-defined dummy case in linux/cache.h to catch architectures which don't implement the section.

Verified that symbols still go in .data.read_mostly on parisc, and the compile doesn't break.

---

I accidently committed this to an up-to-date master branch, as I forgot to check out the temporary branch I was going to commit it on. Swapping the sums from .git/refs/heads/{master,read_mostly} wouldn't break anything, if the only different between the two was this commit, right?

 include/asm-i386/cache.h    |    2 ++
 include/asm-ia64/cache.h    |    2 ++
 include/asm-parisc/cache.h  |    2 ++
 include/asm-sparc64/cache.h |    2 ++
 include/asm-x86_64/cache.h  |    2 ++
 include/linux/cache.h       |    4 +---
 6 files changed, 11 insertions(+), 3 deletions(-)

b7b3d524ba7fae865789ecc49b8ff660f5ef928b

include/asm-i386/cache.h +2 -0
index 615911e..ca15c9c 100644
@@ -10,4 +10,6 @@
 #define L1_CACHE_SHIFT	(CONFIG_X86_L1_CACHE_SHIFT)
 #define L1_CACHE_BYTES	(1 << L1_CACHE_SHIFT)
 
+#define __read_mostly __attribute__((__section__(".data.read_mostly")))
+
 #endif
include/asm-ia64/cache.h +2 -0
index 40dd251..f0a104d 100644
@@ -25,4 +25,6 @@
 # define SMP_CACHE_BYTES	(1 << 3)
 #endif
 
+#define __read_mostly __attribute__((__section__(".data.read_mostly")))
+
 #endif /* _ASM_IA64_CACHE_H */
include/asm-parisc/cache.h +2 -0
index 93f179f..ae50f8e 100644
@@ -29,6 +29,8 @@
 
 #define SMP_CACHE_BYTES L1_CACHE_BYTES
 
+#define __read_mostly __attribute__((__section__(".data.read_mostly")))
+
 extern void flush_data_cache_local(void *);  /* flushes local data-cache only */
 extern void flush_instruction_cache_local(void *); /* flushes local code-cache only */
 #ifdef CONFIG_SMP
include/asm-sparc64/cache.h +2 -0
index f7d35a2..e9df17a 100644
@@ -13,4 +13,6 @@
 #define        SMP_CACHE_BYTES_SHIFT	6
 #define        SMP_CACHE_BYTES		(1 << SMP_CACHE_BYTES_SHIFT) /* L2 cache line size. */
 
+#define __read_mostly __attribute__((__section__(".data.read_mostly")))
+
 #endif
include/asm-x86_64/cache.h +2 -0
index b4a2401..f06f33a 100644
@@ -10,4 +10,6 @@
 #define L1_CACHE_SHIFT	(CONFIG_X86_L1_CACHE_SHIFT)
 #define L1_CACHE_BYTES	(1 << L1_CACHE_SHIFT)
 
+#define __read_mostly __attribute__((__section__(".data.read_mostly")))
+
 #endif
include/linux/cache.h +1 -3
index d22e632..cc4b3aa 100644
@@ -13,9 +13,7 @@
 #define SMP_CACHE_BYTES L1_CACHE_BYTES
 #endif
 
-#if defined(CONFIG_X86) || defined(CONFIG_SPARC64) || defined(CONFIG_IA64) || defined(CONFIG_PARISC)
-#define __read_mostly __attribute__((__section__(".data.read_mostly")))
-#else
+#ifndef __read_mostly
 #define __read_mostly
 #endif
 
Signature · 1 line
1.0.GIT
#1 lore raw
Quoted 6 lines · Kyle McMartin

I accidently committed this to an up-to-date master branch, as I forgot to check out the temporary branch I was going to commit it on. Swapping the sums from .git/refs/heads/{master,read_mostly} wouldn't break anything, if the only different between the two was this commit, right?

Correct. The branch head files really are just plain ascii references to the top commit, you can rename branches by just renaming the file (and thus switch branches by just cross-renaming them, ie just switching the contents).

Linus

#2 lore raw
Quoted 10 lines · Linus Torvalds
Quoted 5 lines

I accidently committed this to an up-to-date master branch, as I forgot to check out the temporary branch I was going to commit it on. Swapping the sums from .git/refs/heads/{master,read_mostly} wouldn't break anything, if the only different between the two was this commit, right?

Correct. The branch head files really are just plain ascii references to the top commit, you can rename branches by just renaming the file (and thus switch branches by just cross-renaming them, ie just switching the contents).

Careful.

If one of the swapped branches is your current branch (i.e. pointed at by .git/HEAD), you need to remember to switch that as well.

For example, after making the mistake of committing to "master":

	$ git commit ;# oops, to the master
        $ git show-branch origin master read_mostly
	!   [origin] latest update from Linus
         *  [master] latest for read_mostly
          ! [read_mostly] last update from Linus
        ---
         +  [master] latest for read_mostly
        +++ [origin] last update from Linus

Then swap heads:

	$ read_mostly_head=`cat .git/refs/heads/master`
        $ cat .git/refs/heads/read_mostly >.git/refs/heads/read_mostly
	$ echo "$read_mostly_head" >.git/refs/heads/read_mostly

At this point:

* Your index file still matches $read_mostly_head
* Your working tree matches your index file
* Your .git/HEAD is pointing at .git/refs/heads/master

Essentially, you are (you want to be) in read_mostly branch, but your .git/HEAD incorrectly says you are on the master branch. So you would need:

	$ git symbolic-ref HEAD refs/heads/read_mostly

after swapping. Then you would be on read_mostly branch.

        $ git show-branch origin master read_mostly
	!   [origin] latest update from Linus
         !  [master] last update from Linus
          * [read_mostly] latest for read_mostly
        ---
          + [read_mostly] latest for read_mostly
        +++ [origin] last update from Linus

BTW, would people object if I made the show-branch output like this?

        $ git show-branch origin master read_mostly
	!   [origin] latest update from Linus
         !  [master] last update from Linus
          * [read_mostly] latest for read_mostly
        ---
          * [read_mostly] latest for read_mostly
        ++* [origin] last update from Linus
#3 lore raw
Quoted 8 lines · Junio C Hamano

Essentially, you are (you want to be) in read_mostly branch, but your .git/HEAD incorrectly says you are on the master branch. So you would need:

	$ git symbolic-ref HEAD refs/heads/read_mostly

after swapping. Then you would be on read_mostly branch.

Alternatively, if I had (I haven't touched the tree, just format-patch'd which looked right) used git-reset --hard HEAD and been up to date (working tree and index file) with whatever ended up being pointed to by HEAD, right?

I'll try to remember the symbolic-ref thing for next time, usually when this happens I just blow away the last commit and try again, but I felt adventurous today. :)

Cheers,
Kyle

#4 lore raw
Quoted 4 lines · Kyle McMartin

Alternatively, if I had (I haven't touched the tree, just format-patch'd which looked right) used git-reset --hard HEAD and been up to date (working tree and index file) with whatever ended up being pointed to by HEAD, right?

Yes.

Quoted 3 lines

I'll try to remember the symbolic-ref thing for next time, usually when this happens I just blow away the last commit and try again, but I felt adventurous today. :)

After making the mistake of committing to "master":

	$ git commit ;# oops, to the master
        $ git show-branch origin master read-mostly
	!  [origin] latest update from Linus
         * [master] latest for read-mostly
        --
         * [master] latest for read-mostly
        +* [origin] last update from Linus

you could do this, which would be easier to visualize:

	$ git branch read-mostly ;# may need branch "-f" if exists.
        $ git reset --hard HEAD^ ;# rewind the current head by one.

Which would give you this:

        $ git show-branch origin master read-mostly
	!   [origin] latest update from Linus
         *  [master] latest update from Linus
          ! [read-mostly] latest for read-mostly
        --
          ! [read-mostly] latest for read-mostly
        +*! [origin] last update from Linus