diff options
author | Tejun Heo <tj@kernel.org> | 2014-06-17 19:12:34 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-06-17 19:12:34 -0400 |
commit | 9defda18f913181debfe7cdc8c0a752f707ac861 (patch) | |
tree | 68cd16a060d3350883a17eae4757620472fa66a1 | |
parent | 62fde54123fb64879326c8b71c3f92cc5db1c452 (diff) |
percpu: move accessors from include/linux/percpu.h to percpu-defs.h
include/linux/percpu-defs.h is gonna host all accessors and operations
so that arch headers can make use of them too without worrying about
circular dependency through include/linux/percpu.h.
This patch moves the following accessors from include/linux/percpu.h
to include/linux/percpu-defs.h.
* get/put_cpu_var()
* get/put_cpu_ptr()
* per_cpu_ptr()
This is pure reorgniazation.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Christoph Lameter <cl@linux.com>
-rw-r--r-- | include/linux/percpu-defs.h | 32 | ||||
-rw-r--r-- | include/linux/percpu.h | 37 |
2 files changed, 32 insertions, 37 deletions
diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h index 1a1af3e06a71..f782f98004db 100644 --- a/include/linux/percpu-defs.h +++ b/include/linux/percpu-defs.h | |||
@@ -252,5 +252,37 @@ | |||
252 | /* keep until we have removed all uses of __this_cpu_ptr */ | 252 | /* keep until we have removed all uses of __this_cpu_ptr */ |
253 | #define __this_cpu_ptr(ptr) raw_cpu_ptr(ptr) | 253 | #define __this_cpu_ptr(ptr) raw_cpu_ptr(ptr) |
254 | 254 | ||
255 | /* | ||
256 | * Must be an lvalue. Since @var must be a simple identifier, | ||
257 | * we force a syntax error here if it isn't. | ||
258 | */ | ||
259 | #define get_cpu_var(var) (*({ \ | ||
260 | preempt_disable(); \ | ||
261 | this_cpu_ptr(&var); })) | ||
262 | |||
263 | /* | ||
264 | * The weird & is necessary because sparse considers (void)(var) to be | ||
265 | * a direct dereference of percpu variable (var). | ||
266 | */ | ||
267 | #define put_cpu_var(var) do { \ | ||
268 | (void)&(var); \ | ||
269 | preempt_enable(); \ | ||
270 | } while (0) | ||
271 | |||
272 | #define get_cpu_ptr(var) ({ \ | ||
273 | preempt_disable(); \ | ||
274 | this_cpu_ptr(var); }) | ||
275 | |||
276 | #define put_cpu_ptr(var) do { \ | ||
277 | (void)(var); \ | ||
278 | preempt_enable(); \ | ||
279 | } while (0) | ||
280 | |||
281 | #ifdef CONFIG_SMP | ||
282 | #define per_cpu_ptr(ptr, cpu) SHIFT_PERCPU_PTR((ptr), per_cpu_offset((cpu))) | ||
283 | #else | ||
284 | #define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR((ptr)); }) | ||
285 | #endif | ||
286 | |||
255 | #endif /* __ASSEMBLY__ */ | 287 | #endif /* __ASSEMBLY__ */ |
256 | #endif /* _LINUX_PERCPU_DEFS_H */ | 288 | #endif /* _LINUX_PERCPU_DEFS_H */ |
diff --git a/include/linux/percpu.h b/include/linux/percpu.h index 8419053d0f2e..97b207990c45 100644 --- a/include/linux/percpu.h +++ b/include/linux/percpu.h | |||
@@ -23,32 +23,6 @@ | |||
23 | PERCPU_MODULE_RESERVE) | 23 | PERCPU_MODULE_RESERVE) |
24 | #endif | 24 | #endif |
25 | 25 | ||
26 | /* | ||
27 | * Must be an lvalue. Since @var must be a simple identifier, | ||
28 | * we force a syntax error here if it isn't. | ||
29 | */ | ||
30 | #define get_cpu_var(var) (*({ \ | ||
31 | preempt_disable(); \ | ||
32 | this_cpu_ptr(&var); })) | ||
33 | |||
34 | /* | ||
35 | * The weird & is necessary because sparse considers (void)(var) to be | ||
36 | * a direct dereference of percpu variable (var). | ||
37 | */ | ||
38 | #define put_cpu_var(var) do { \ | ||
39 | (void)&(var); \ | ||
40 | preempt_enable(); \ | ||
41 | } while (0) | ||
42 | |||
43 | #define get_cpu_ptr(var) ({ \ | ||
44 | preempt_disable(); \ | ||
45 | this_cpu_ptr(var); }) | ||
46 | |||
47 | #define put_cpu_ptr(var) do { \ | ||
48 | (void)(var); \ | ||
49 | preempt_enable(); \ | ||
50 | } while (0) | ||
51 | |||
52 | /* minimum unit size, also is the maximum supported allocation size */ | 26 | /* minimum unit size, also is the maximum supported allocation size */ |
53 | #define PCPU_MIN_UNIT_SIZE PFN_ALIGN(32 << 10) | 27 | #define PCPU_MIN_UNIT_SIZE PFN_ALIGN(32 << 10) |
54 | 28 | ||
@@ -140,17 +114,6 @@ extern int __init pcpu_page_first_chunk(size_t reserved_size, | |||
140 | pcpu_fc_populate_pte_fn_t populate_pte_fn); | 114 | pcpu_fc_populate_pte_fn_t populate_pte_fn); |
141 | #endif | 115 | #endif |
142 | 116 | ||
143 | /* | ||
144 | * Use this to get to a cpu's version of the per-cpu object | ||
145 | * dynamically allocated. Non-atomic access to the current CPU's | ||
146 | * version should probably be combined with get_cpu()/put_cpu(). | ||
147 | */ | ||
148 | #ifdef CONFIG_SMP | ||
149 | #define per_cpu_ptr(ptr, cpu) SHIFT_PERCPU_PTR((ptr), per_cpu_offset((cpu))) | ||
150 | #else | ||
151 | #define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR((ptr)); }) | ||
152 | #endif | ||
153 | |||
154 | extern void __percpu *__alloc_reserved_percpu(size_t size, size_t align); | 117 | extern void __percpu *__alloc_reserved_percpu(size_t size, size_t align); |
155 | extern bool is_kernel_percpu_address(unsigned long addr); | 118 | extern bool is_kernel_percpu_address(unsigned long addr); |
156 | 119 | ||