[PATCH] per_cpu: fix DEFINE_PER_CPU_SHARED_ALIGNED for modules
From: Eric Dumazet
Date: Wed May 14 2008 - 01:19:17 EST
Andrew,
A typo was included in the patch I sent yesterday, since I was testing :
#ifdef CONFIG_MODULES
while the intention was to test
#ifdef MODULE
So that all SHARED_ALIGNED vmlinux percpu variables still are in the
special section.
The fix is only needed when compiling modules.
Thank you
[PATCH] per_cpu: fix DEFINE_PER_CPU_SHARED_ALIGNED for modules
Current module loader lookups ".data.percpu" ELF section to perform
per_cpu relocation. But DEFINE_PER_CPU_SHARED_ALIGNED()
uses another section (".data.percpu.shared_aligned"), currently only
handled in vmlinux.lds, not by module loader.
To correct this problem, instead of adding logic into module loader,
or using at build time a module.lds file for all arches to group
".data.percpu.shared_aligned" into ".data.percpu",
just use ".data.percpu" for modules.
Alignment requirements are correctly handled by ld and module loader.
Signed-off-by: Eric Dumazet <dada1@xxxxxxxxxxxxx>
---
include/linux/percpu.h | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index d746a2a..4cdd393 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -13,8 +13,14 @@
__attribute__((__section__(".data.percpu"))) \
PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name
+#ifdef MODULE
+#define SHARED_ALIGNED_SECTION ".data.percpu"
+#else
+#define SHARED_ALIGNED_SECTION ".data.percpu.shared_aligned"
+#endif
+
#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \
- __attribute__((__section__(".data.percpu.shared_aligned"))) \
+ __attribute__((__section__(SHARED_ALIGNED_SECTION))) \
PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name \
____cacheline_aligned_in_smp
#else