, . . ARM vmlinux.lds.S, vmlinux.lds.h percpu.h; . ".discard" , ; .
PER_CPU, PER_CPU_FIRST, PER_CPU_SHARED_ALIGNED .. .
.
#define DECLARE_PER_CPU_SECTION(type, name, sec) \
extern __attribute__((section(".discard"), unused)) \
char __pcpu_scope_##name; \
extern __attribute__((section(PER_CPU_BASE_SECTION sec))) __typeof__(type) name
sec ; note PER_CPU_BASE_SECTION .
, ... , . If, .... ,
static DEFINE_PER_CPU_PAGE_ALIGNED(...
DEFINE_PER_CPU(unsigned int, irq_count) = -1;
, GNU (, , ), , , kbuild.
, ,
* s390 and alpha modules require percpu variables to be defined as
* weak to force the compiler to generate GOT based external
* references for them. This is necessary because percpu sections
* will be located outside of the usually addressable area.
* This definition puts the following two extra restrictions when
* defining percpu variables.
*
* 1. The symbol must be globally unique, even the static ones.
* 2. Static percpu variables cannot be defined inside a function.
*
* Archs which need weak percpu definitions should define
* ARCH_NEEDS_WEAK_PER_CPU in asm/percpu.h when necessary.
.. __attribute__((weak)) , . #else, weak .
, ,
β1. ?
,
DECLARE_PER_CPU_PAGE_ALIGNED(int,foobar);
static DEFINE_PER_CPU_PAGE_ALIGNED(int,foobar);
β2,... __pcpu_unique_##name, ?
weak . __pcpu_unique_##name weak, , weak .
. Gcc , .