aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2009-04-21 18:00:24 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-21 22:39:59 -0400
commit9b8de7479d0dbab1ed98b5b015d44232c9d3d08e (patch)
tree1b138996efe642f03699a7737af109dfa72ef830 /include
parentccc5ff94c66e628d3c501b26ace5d4339667715d (diff)
FRV: Fix the section attribute on UP DECLARE_PER_CPU()
In non-SMP mode, the variable section attribute specified by DECLARE_PER_CPU() does not agree with that specified by DEFINE_PER_CPU(). This means that architectures that have a small data section references relative to a base register may throw up linkage errors due to too great a displacement between where the base register points and the per-CPU variable. On FRV, the .h declaration says that the variable is in the .sdata section, but the .c definition says it's actually in the .data section. The linker throws up the following errors: kernel/built-in.o: In function `release_task': kernel/exit.c:78: relocation truncated to fit: R_FRV_GPREL12 against symbol `per_cpu__process_counts' defined in .data section in kernel/built-in.o kernel/exit.c:78: relocation truncated to fit: R_FRV_GPREL12 against symbol `per_cpu__process_counts' defined in .data section in kernel/built-in.o To fix this, DECLARE_PER_CPU() should simply apply the same section attribute as does DEFINE_PER_CPU(). However, this is made slightly more complex by virtue of the fact that there are several variants on DEFINE, so these need to be matched by variants on DECLARE. Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/asm-generic/percpu.h43
-rw-r--r--include/linux/percpu.h24
2 files changed, 41 insertions, 26 deletions
diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h
index b0e63c672ebd..af47b9e10064 100644
--- a/include/asm-generic/percpu.h
+++ b/include/asm-generic/percpu.h
@@ -73,11 +73,50 @@ extern void setup_per_cpu_areas(void);
73 73
74#endif /* SMP */ 74#endif /* SMP */
75 75
76#ifndef PER_CPU_BASE_SECTION
77#ifdef CONFIG_SMP
78#define PER_CPU_BASE_SECTION ".data.percpu"
79#else
80#define PER_CPU_BASE_SECTION ".data"
81#endif
82#endif
83
84#ifdef CONFIG_SMP
85
86#ifdef MODULE
87#define PER_CPU_SHARED_ALIGNED_SECTION ""
88#else
89#define PER_CPU_SHARED_ALIGNED_SECTION ".shared_aligned"
90#endif
91#define PER_CPU_FIRST_SECTION ".first"
92
93#else
94
95#define PER_CPU_SHARED_ALIGNED_SECTION ""
96#define PER_CPU_FIRST_SECTION ""
97
98#endif
99
76#ifndef PER_CPU_ATTRIBUTES 100#ifndef PER_CPU_ATTRIBUTES
77#define PER_CPU_ATTRIBUTES 101#define PER_CPU_ATTRIBUTES
78#endif 102#endif
79 103
80#define DECLARE_PER_CPU(type, name) extern PER_CPU_ATTRIBUTES \ 104#define DECLARE_PER_CPU_SECTION(type, name, section) \
81 __typeof__(type) per_cpu_var(name) 105 extern \
106 __attribute__((__section__(PER_CPU_BASE_SECTION section))) \
107 PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name
108
109#define DECLARE_PER_CPU(type, name) \
110 DECLARE_PER_CPU_SECTION(type, name, "")
111
112#define DECLARE_PER_CPU_SHARED_ALIGNED(type, name) \
113 DECLARE_PER_CPU_SECTION(type, name, PER_CPU_SHARED_ALIGNED_SECTION) \
114 ____cacheline_aligned_in_smp
115
116#define DECLARE_PER_CPU_PAGE_ALIGNED(type, name) \
117 DECLARE_PER_CPU_SECTION(type, name, ".page_aligned")
118
119#define DECLARE_PER_CPU_FIRST(type, name) \
120 DECLARE_PER_CPU_SECTION(type, name, PER_CPU_FIRST_SECTION)
82 121
83#endif /* _ASM_GENERIC_PERCPU_H_ */ 122#endif /* _ASM_GENERIC_PERCPU_H_ */
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index cfda2d5ad319..f052d8184993 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -9,30 +9,6 @@
9 9
10#include <asm/percpu.h> 10#include <asm/percpu.h>
11 11
12#ifndef PER_CPU_BASE_SECTION
13#ifdef CONFIG_SMP
14#define PER_CPU_BASE_SECTION ".data.percpu"
15#else
16#define PER_CPU_BASE_SECTION ".data"
17#endif
18#endif
19
20#ifdef CONFIG_SMP
21
22#ifdef MODULE
23#define PER_CPU_SHARED_ALIGNED_SECTION ""
24#else
25#define PER_CPU_SHARED_ALIGNED_SECTION ".shared_aligned"
26#endif
27#define PER_CPU_FIRST_SECTION ".first"
28
29#else
30
31#define PER_CPU_SHARED_ALIGNED_SECTION ""
32#define PER_CPU_FIRST_SECTION ""
33
34#endif
35
36#define DEFINE_PER_CPU_SECTION(type, name, section) \ 12#define DEFINE_PER_CPU_SECTION(type, name, section) \
37 __attribute__((__section__(PER_CPU_BASE_SECTION section))) \ 13 __attribute__((__section__(PER_CPU_BASE_SECTION section))) \
38 PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name 14 PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name