diff options
Diffstat (limited to 'include/linux/percpu-defs.h')
| -rw-r--r-- | include/linux/percpu-defs.h | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h index 2351191f8c82..ce2dc655cd1d 100644 --- a/include/linux/percpu-defs.h +++ b/include/linux/percpu-defs.h | |||
| @@ -2,12 +2,6 @@ | |||
| 2 | #define _LINUX_PERCPU_DEFS_H | 2 | #define _LINUX_PERCPU_DEFS_H |
| 3 | 3 | ||
| 4 | /* | 4 | /* |
| 5 | * Determine the real variable name from the name visible in the | ||
| 6 | * kernel sources. | ||
| 7 | */ | ||
| 8 | #define per_cpu_var(var) per_cpu__##var | ||
| 9 | |||
| 10 | /* | ||
| 11 | * Base implementations of per-CPU variable declarations and definitions, where | 5 | * Base implementations of per-CPU variable declarations and definitions, where |
| 12 | * the section in which the variable is to be placed is provided by the | 6 | * the section in which the variable is to be placed is provided by the |
| 13 | * 'sec' argument. This may be used to affect the parameters governing the | 7 | * 'sec' argument. This may be used to affect the parameters governing the |
| @@ -18,13 +12,23 @@ | |||
| 18 | * that section. | 12 | * that section. |
| 19 | */ | 13 | */ |
| 20 | #define __PCPU_ATTRS(sec) \ | 14 | #define __PCPU_ATTRS(sec) \ |
| 21 | __attribute__((section(PER_CPU_BASE_SECTION sec))) \ | 15 | __percpu __attribute__((section(PER_CPU_BASE_SECTION sec))) \ |
| 22 | PER_CPU_ATTRIBUTES | 16 | PER_CPU_ATTRIBUTES |
| 23 | 17 | ||
| 24 | #define __PCPU_DUMMY_ATTRS \ | 18 | #define __PCPU_DUMMY_ATTRS \ |
| 25 | __attribute__((section(".discard"), unused)) | 19 | __attribute__((section(".discard"), unused)) |
| 26 | 20 | ||
| 27 | /* | 21 | /* |
| 22 | * Macro which verifies @ptr is a percpu pointer without evaluating | ||
| 23 | * @ptr. This is to be used in percpu accessors to verify that the | ||
| 24 | * input parameter is a percpu pointer. | ||
| 25 | */ | ||
| 26 | #define __verify_pcpu_ptr(ptr) do { \ | ||
| 27 | const void __percpu *__vpp_verify = (typeof(ptr))NULL; \ | ||
| 28 | (void)__vpp_verify; \ | ||
| 29 | } while (0) | ||
| 30 | |||
| 31 | /* | ||
| 28 | * s390 and alpha modules require percpu variables to be defined as | 32 | * s390 and alpha modules require percpu variables to be defined as |
| 29 | * weak to force the compiler to generate GOT based external | 33 | * weak to force the compiler to generate GOT based external |
| 30 | * references for them. This is necessary because percpu sections | 34 | * references for them. This is necessary because percpu sections |
| @@ -56,24 +60,24 @@ | |||
| 56 | */ | 60 | */ |
| 57 | #define DECLARE_PER_CPU_SECTION(type, name, sec) \ | 61 | #define DECLARE_PER_CPU_SECTION(type, name, sec) \ |
| 58 | extern __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \ | 62 | extern __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \ |
| 59 | extern __PCPU_ATTRS(sec) __typeof__(type) per_cpu__##name | 63 | extern __PCPU_ATTRS(sec) __typeof__(type) name |
| 60 | 64 | ||
| 61 | #define DEFINE_PER_CPU_SECTION(type, name, sec) \ | 65 | #define DEFINE_PER_CPU_SECTION(type, name, sec) \ |
| 62 | __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \ | 66 | __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \ |
| 63 | extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \ | 67 | extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \ |
| 64 | __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \ | 68 | __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \ |
| 65 | __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES __weak \ | 69 | __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES __weak \ |
| 66 | __typeof__(type) per_cpu__##name | 70 | __typeof__(type) name |
| 67 | #else | 71 | #else |
| 68 | /* | 72 | /* |
| 69 | * Normal declaration and definition macros. | 73 | * Normal declaration and definition macros. |
| 70 | */ | 74 | */ |
| 71 | #define DECLARE_PER_CPU_SECTION(type, name, sec) \ | 75 | #define DECLARE_PER_CPU_SECTION(type, name, sec) \ |
| 72 | extern __PCPU_ATTRS(sec) __typeof__(type) per_cpu__##name | 76 | extern __PCPU_ATTRS(sec) __typeof__(type) name |
| 73 | 77 | ||
| 74 | #define DEFINE_PER_CPU_SECTION(type, name, sec) \ | 78 | #define DEFINE_PER_CPU_SECTION(type, name, sec) \ |
| 75 | __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES \ | 79 | __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES \ |
| 76 | __typeof__(type) per_cpu__##name | 80 | __typeof__(type) name |
| 77 | #endif | 81 | #endif |
| 78 | 82 | ||
| 79 | /* | 83 | /* |
| @@ -135,10 +139,16 @@ | |||
| 135 | __aligned(PAGE_SIZE) | 139 | __aligned(PAGE_SIZE) |
| 136 | 140 | ||
| 137 | /* | 141 | /* |
| 138 | * Intermodule exports for per-CPU variables. | 142 | * Intermodule exports for per-CPU variables. sparse forgets about |
| 143 | * address space across EXPORT_SYMBOL(), change EXPORT_SYMBOL() to | ||
| 144 | * noop if __CHECKER__. | ||
| 139 | */ | 145 | */ |
| 140 | #define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var) | 146 | #ifndef __CHECKER__ |
| 141 | #define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var) | 147 | #define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(var) |
| 142 | 148 | #define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(var) | |
| 149 | #else | ||
| 150 | #define EXPORT_PER_CPU_SYMBOL(var) | ||
| 151 | #define EXPORT_PER_CPU_SYMBOL_GPL(var) | ||
| 152 | #endif | ||
| 143 | 153 | ||
| 144 | #endif /* _LINUX_PERCPU_DEFS_H */ | 154 | #endif /* _LINUX_PERCPU_DEFS_H */ |
