Skip to contentSkip to conversation

Allow for per-cpu data being in .tdata and .tbss sections

PATCH New Paul Mackerras 1 participant 1 message May 10, 2006 Generic include/asm header files

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow for per-cpu data being in .tdata and .tbss sections

This lays the groundwork for using __thread for per-cpu variables. The toolchain will put initialized __thread variables into a .tdata section, and uninitialized __thread variables into a .tbss section. Thus the module loader needs to cope with two per-cpu sections, of which one is initialized and the other must be zeroed.

With this patch, the module loader looks for .tdata and .tbss, and if it finds neither, falls back to the .data.percpu section that we currently use. This patch extends the various percpu_modcopy implementations to take two size parameters: the first is the amount to initialize and the second is the amount to zero following that. At the moment all percpu_modcopy implementations simply check that the amount to zero is zero.

I have a following patch that makes 64-bit powerpc use __thread for per-cpu variables.

---

arch/ia64/kernel/module.c +3 -1
index 3a30cfc..88790f4 100644
@@ -944,9 +944,11 @@ module_arch_cleanup (struct module *mod)
 
 #ifdef CONFIG_SMP
 void
-percpu_modcopy (void *pcpudst, const void *src, unsigned long size)
+percpu_modcopy (void *pcpudst, const void *src, unsigned long size,
+		unsigned long zero_size)
 {
 	unsigned int i;
+	BUG_ON(zero_size != 0);
 	for_each_possible_cpu(i) {
 		memcpy(pcpudst + __per_cpu_offset[i], src, size);
 	}
include/asm-ia64/percpu.h +2 -1
index 4bfbeb4..f0a679e 100644
@@ -45,7 +45,8 @@ #define per_cpu(var, cpu)  (*RELOC_HIDE(
 #define __get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __ia64_per_cpu_var(local_per_cpu_offset)))
 #define __raw_get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __ia64_per_cpu_var(local_per_cpu_offset)))
 
-extern void percpu_modcopy(void *pcpudst, const void *src, unsigned long size);
+extern void percpu_modcopy(void *pcpudst, const void *src,
+			   unsigned long init_sz, unsigned long zero_sz);
 extern void setup_per_cpu_areas (void);
 extern void *per_cpu_init(void);
 
include/asm-powerpc/percpu.h +2 -1
index faa1fc7..5d603ff 100644
@@ -25,9 +25,10 @@ #define __get_cpu_var(var) (*RELOC_HIDE(
 #define __raw_get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __my_cpu_offset()))
 
 /* A macro to avoid #include hell... */
-#define percpu_modcopy(pcpudst, src, size)			\
+#define percpu_modcopy(pcpudst, src, size, zero_size)		\
 do {								\
 	unsigned int __i;					\
+	BUG_ON(zero_size != 0);					\
 	for_each_possible_cpu(__i)				\
 		memcpy((pcpudst)+__per_cpu_offset(__i),		\
 		       (src), (size));				\
include/asm-s390/percpu.h +2 -1
index d9a8cca..c443986 100644
@@ -44,9 +44,10 @@ #define __raw_get_cpu_var(var) __reloc_h
 #define per_cpu(var,cpu) __reloc_hide(var,__per_cpu_offset[cpu])
 
 /* A macro to avoid #include hell... */
-#define percpu_modcopy(pcpudst, src, size)			\
+#define percpu_modcopy(pcpudst, src, size, zero_size)		\
 do {								\
 	unsigned int __i;					\
+	BUG_ON(zero_size != 0);					\
 	for_each_possible_cpu(__i)				\
 		memcpy((pcpudst)+__per_cpu_offset[__i],		\
 		       (src), (size));				\
include/asm-sparc64/percpu.h +2 -1
index a6ece06..21f9b01 100644
@@ -24,9 +24,10 @@ #define __get_cpu_var(var) (*RELOC_HIDE(
 #define __raw_get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __local_per_cpu_offset))
 
 /* A macro to avoid #include hell... */
-#define percpu_modcopy(pcpudst, src, size)			\
+#define percpu_modcopy(pcpudst, src, size, zero_size)		\
 do {								\
 	unsigned int __i;					\
+	BUG_ON(zero_size != 0);					\
 	for_each_possible_cpu(__i)				\
 		memcpy((pcpudst)+__per_cpu_offset(__i),		\
 		       (src), (size));				\
include/asm-x86_64/percpu.h +2 -1
index 549eb92..0e6ffde 100644
@@ -24,9 +24,10 @@ #define __get_cpu_var(var) (*RELOC_HIDE(
 #define __raw_get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __my_cpu_offset()))
 
 /* A macro to avoid #include hell... */
-#define percpu_modcopy(pcpudst, src, size)			\
+#define percpu_modcopy(pcpudst, src, size, zero_size)		\
 do {								\
 	unsigned int __i;					\
+	BUG_ON(zero_size != 0);					\
 	for_each_possible_cpu(__i)				\
 		memcpy((pcpudst)+__per_cpu_offset(__i),		\
 		       (src), (size));				\
kernel/module.c +66 -25

150 lines not on this page · raw message