Skip to content

Commit b01e8dc

Browse files
htejuntorvalds
authored andcommitted
alpha: fix percpu build breakage
alpha percpu access requires custom SHIFT_PERCPU_PTR() definition for modules to work around addressing range limitation. This is done via generating inline assembly using C preprocessing which forces the assembler to generate external reference. This happens behind the compiler's back and makes the compiler think that static percpu variables in modules are unused. This used to be worked around by using __unused attribute for percpu variables which prevent the compiler from omitting the variable; however, recent declare/definition attribute unification change broke this as __used can't be used for declaration. Also, in the process, PER_CPU_ATTRIBUTES definition in alpha percpu.h got broken. This patch adds PER_CPU_DEF_ATTRIBUTES which is only used for definitions and make alpha use it to add __used for percpu variables in modules. This also fixes the PER_CPU_ATTRIBUTES double definition bug. Signed-off-by: Tejun Heo <tj@kernel.org> Tested-by: maximilian attems <max@stro.at> Acked-by: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Cc: Richard Henderson <rth@twiddle.net> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 15e3252 commit b01e8dc

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

‎arch/alpha/include/asm/percpu.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ extern unsigned long __per_cpu_offset[NR_CPUS];
3030

3131
#ifndef MODULE
3232
#define SHIFT_PERCPU_PTR(var, offset) RELOC_HIDE(&per_cpu_var(var), (offset))
33-
#define PER_CPU_ATTRIBUTES
33+
#define PER_CPU_DEF_ATTRIBUTES
3434
#else
3535
/*
3636
* To calculate addresses of locally defined variables, GCC uses 32-bit
@@ -49,7 +49,7 @@ extern unsigned long __per_cpu_offset[NR_CPUS];
4949
: "=&r"(__ptr), "=&r"(tmp_gp)); \
5050
(typeof(&per_cpu_var(var)))(__ptr + (offset)); })
5151

52-
#define PER_CPU_ATTRIBUTES __used
52+
#define PER_CPU_DEF_ATTRIBUTES __used
5353

5454
#endif /* MODULE */
5555

@@ -71,7 +71,7 @@ extern unsigned long __per_cpu_offset[NR_CPUS];
7171
#define __get_cpu_var(var) per_cpu_var(var)
7272
#define __raw_get_cpu_var(var) per_cpu_var(var)
7373

74-
#define PER_CPU_ATTRIBUTES
74+
#define PER_CPU_DEF_ATTRIBUTES
7575

7676
#endif /* SMP */
7777

‎include/asm-generic/percpu.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,8 @@ extern void setup_per_cpu_areas(void);
9797
#define PER_CPU_ATTRIBUTES
9898
#endif
9999

100+
#ifndef PER_CPU_DEF_ATTRIBUTES
101+
#define PER_CPU_DEF_ATTRIBUTES
102+
#endif
103+
100104
#endif /* _ASM_GENERIC_PERCPU_H_ */

‎include/linux/percpu-defs.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424

2525
#define DEFINE_PER_CPU_SECTION(type, name, section) \
2626
__attribute__((__section__(PER_CPU_BASE_SECTION section))) \
27-
PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name
27+
PER_CPU_ATTRIBUTES PER_CPU_DEF_ATTRIBUTES \
28+
__typeof__(type) per_cpu__##name
2829

2930
/*
3031
* Variant on the per-CPU variable declaration/definition theme used for

0 commit comments

Comments
 (0)