Go to the documentation of this file. 1 #ifndef _LINUX_PERCPU_DEFS_H
2 #define _LINUX_PERCPU_DEFS_H
14 #define __PCPU_ATTRS(sec) \
15 __percpu __attribute__((section(PER_CPU_BASE_SECTION sec))) \
18 #define __PCPU_DUMMY_ATTRS \
19 __attribute__((section(".discard"), unused))
26 #define __verify_pcpu_ptr(ptr) do { \
27 const void __percpu *__vpp_verify = (typeof(ptr))NULL; \
50 #if defined(ARCH_NEEDS_WEAK_PER_CPU) || defined(CONFIG_DEBUG_FORCE_WEAK_PER_CPU)
61 #define DECLARE_PER_CPU_SECTION(type, name, sec) \
62 extern __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \
63 extern __PCPU_ATTRS(sec) __typeof__(type) name
65 #define DEFINE_PER_CPU_SECTION(type, name, sec) \
66 __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \
67 extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
68 __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
69 __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES __weak \
75 #define DECLARE_PER_CPU_SECTION(type, name, sec) \
76 extern __PCPU_ATTRS(sec) __typeof__(type) name
78 #define DEFINE_PER_CPU_SECTION(type, name, sec) \
79 __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES \
87 #define DECLARE_PER_CPU(type, name) \
88 DECLARE_PER_CPU_SECTION(type, name, "")
90 #define DEFINE_PER_CPU(type, name) \
91 DEFINE_PER_CPU_SECTION(type, name, "")
97 #define DECLARE_PER_CPU_FIRST(type, name) \
98 DECLARE_PER_CPU_SECTION(type, name, PER_CPU_FIRST_SECTION)
100 #define DEFINE_PER_CPU_FIRST(type, name) \
101 DEFINE_PER_CPU_SECTION(type, name, PER_CPU_FIRST_SECTION)
114 #define DECLARE_PER_CPU_SHARED_ALIGNED(type, name) \
115 DECLARE_PER_CPU_SECTION(type, name, PER_CPU_SHARED_ALIGNED_SECTION) \
116 ____cacheline_aligned_in_smp
118 #define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \
119 DEFINE_PER_CPU_SECTION(type, name, PER_CPU_SHARED_ALIGNED_SECTION) \
120 ____cacheline_aligned_in_smp
122 #define DECLARE_PER_CPU_ALIGNED(type, name) \
123 DECLARE_PER_CPU_SECTION(type, name, PER_CPU_ALIGNED_SECTION) \
124 ____cacheline_aligned
126 #define DEFINE_PER_CPU_ALIGNED(type, name) \
127 DEFINE_PER_CPU_SECTION(type, name, PER_CPU_ALIGNED_SECTION) \
128 ____cacheline_aligned
133 #define DECLARE_PER_CPU_PAGE_ALIGNED(type, name) \
134 DECLARE_PER_CPU_SECTION(type, name, "..page_aligned") \
137 #define DEFINE_PER_CPU_PAGE_ALIGNED(type, name) \
138 DEFINE_PER_CPU_SECTION(type, name, "..page_aligned") \
144 #define DECLARE_PER_CPU_READ_MOSTLY(type, name) \
145 DECLARE_PER_CPU_SECTION(type, name, "..readmostly")
147 #define DEFINE_PER_CPU_READ_MOSTLY(type, name) \
148 DEFINE_PER_CPU_SECTION(type, name, "..readmostly")
156 #define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(var)
157 #define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(var)
159 #define EXPORT_PER_CPU_SYMBOL(var)
160 #define EXPORT_PER_CPU_SYMBOL_GPL(var)