1#ifndef _LINUX_PERCPU_DEFS_H
2#define _LINUX_PERCPU_DEFS_H
3
4
5
6
7
8#define per_cpu_var(var) per_cpu__##var
9
10
11
12
13
14
15
16
17
18
19
20#define __PCPU_ATTRS(sec) \
21 __attribute__((section(PER_CPU_BASE_SECTION sec))) \
22 PER_CPU_ATTRIBUTES
23
24#define __PCPU_DUMMY_ATTRS \
25 __attribute__((section(".discard"), unused))
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46#if defined(ARCH_NEEDS_WEAK_PER_CPU) || defined(CONFIG_DEBUG_FORCE_WEAK_PER_CPU)
47
48
49
50
51
52
53
54
55
56
57#define DECLARE_PER_CPU_SECTION(type, name, sec) \
58 extern __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \
59 extern __PCPU_ATTRS(sec) __typeof__(type) per_cpu__##name
60
61#define DEFINE_PER_CPU_SECTION(type, name, sec) \
62 __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \
63 __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
64 __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES __weak \
65 __typeof__(type) per_cpu__##name
66#else
67
68
69
70#define DECLARE_PER_CPU_SECTION(type, name, sec) \
71 extern __PCPU_ATTRS(sec) __typeof__(type) per_cpu__##name
72
73#define DEFINE_PER_CPU_SECTION(type, name, sec) \
74 __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES \
75 __typeof__(type) per_cpu__##name
76#endif
77
78
79
80
81
82#define DECLARE_PER_CPU(type, name) \
83 DECLARE_PER_CPU_SECTION(type, name, "")
84
85#define DEFINE_PER_CPU(type, name) \
86 DEFINE_PER_CPU_SECTION(type, name, "")
87
88
89
90
91
92#define DECLARE_PER_CPU_FIRST(type, name) \
93 DECLARE_PER_CPU_SECTION(type, name, PER_CPU_FIRST_SECTION)
94
95#define DEFINE_PER_CPU_FIRST(type, name) \
96 DEFINE_PER_CPU_SECTION(type, name, PER_CPU_FIRST_SECTION)
97
98
99
100
101
102
103
104
105
106
107
108
109#define DECLARE_PER_CPU_SHARED_ALIGNED(type, name) \
110 DECLARE_PER_CPU_SECTION(type, name, PER_CPU_SHARED_ALIGNED_SECTION) \
111 ____cacheline_aligned_in_smp
112
113#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \
114 DEFINE_PER_CPU_SECTION(type, name, PER_CPU_SHARED_ALIGNED_SECTION) \
115 ____cacheline_aligned_in_smp
116
117#define DECLARE_PER_CPU_ALIGNED(type, name) \
118 DECLARE_PER_CPU_SECTION(type, name, PER_CPU_ALIGNED_SECTION) \
119 ____cacheline_aligned
120
121#define DEFINE_PER_CPU_ALIGNED(type, name) \
122 DEFINE_PER_CPU_SECTION(type, name, PER_CPU_ALIGNED_SECTION) \
123 ____cacheline_aligned
124
125
126
127
128#define DECLARE_PER_CPU_PAGE_ALIGNED(type, name) \
129 DECLARE_PER_CPU_SECTION(type, name, ".page_aligned") \
130 __aligned(PAGE_SIZE)
131
132#define DEFINE_PER_CPU_PAGE_ALIGNED(type, name) \
133 DEFINE_PER_CPU_SECTION(type, name, ".page_aligned") \
134 __aligned(PAGE_SIZE)
135
136
137
138
139#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
140#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
141
142
143#endif
144