diff options
author | David Howells <dhowells@redhat.com> | 2009-04-21 18:00:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-21 22:39:59 -0400 |
commit | 9b8de7479d0dbab1ed98b5b015d44232c9d3d08e (patch) | |
tree | 1b138996efe642f03699a7737af109dfa72ef830 /include/asm-generic/percpu.h | |
parent | ccc5ff94c66e628d3c501b26ace5d4339667715d (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/asm-generic/percpu.h')
-rw-r--r-- | include/asm-generic/percpu.h | 43 |
1 files changed, 41 insertions, 2 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_ */ |