aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/percpu.h
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2009-10-29 09:34:15 -0400
committerTejun Heo <tj@kernel.org>2009-10-29 09:34:15 -0400
commitf7b64fe806029e0a0454df132eec3c5ab576102c (patch)
tree04812617c2c64f0fa169df3b63686079df1131d6 /include/linux/percpu.h
parentdd17c8f72993f9461e9c19250e3f155d6d99df22 (diff)
percpu: make access macros universal
Now that per_cpu__ prefix is gone, there's no distinction between static and dynamic percpu variables. Make get_cpu_var() take dynamic percpu variables and ensure that all macros have parentheses around the parameter evaluation and evaluate the variable parameter only once such that any expression which evaluates to percpu address can be used safely. Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'include/linux/percpu.h')
-rw-r--r--include/linux/percpu.h23
1 files changed, 14 insertions, 9 deletions
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index e12410e55e05..f965f833a643 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -27,10 +27,13 @@
27 * we force a syntax error here if it isn't. 27 * we force a syntax error here if it isn't.
28 */ 28 */
29#define get_cpu_var(var) (*({ \ 29#define get_cpu_var(var) (*({ \
30 extern int simple_identifier_##var(void); \
31 preempt_disable(); \ 30 preempt_disable(); \
32 &__get_cpu_var(var); })) 31 &__get_cpu_var(var); }))
33#define put_cpu_var(var) preempt_enable() 32
33#define put_cpu_var(var) do { \
34 (void)(var); \
35 preempt_enable(); \
36} while (0)
34 37
35#ifdef CONFIG_SMP 38#ifdef CONFIG_SMP
36 39
@@ -182,17 +185,19 @@ static inline void *pcpu_lpage_remapped(void *kaddr)
182#ifndef percpu_read 185#ifndef percpu_read
183# define percpu_read(var) \ 186# define percpu_read(var) \
184 ({ \ 187 ({ \
185 typeof(var) __tmp_var__; \ 188 typeof(var) *pr_ptr__ = &(var); \
186 __tmp_var__ = get_cpu_var(var); \ 189 typeof(var) pr_ret__; \
187 put_cpu_var(var); \ 190 pr_ret__ = get_cpu_var(*pr_ptr__); \
188 __tmp_var__; \ 191 put_cpu_var(*pr_ptr__); \
192 pr_ret__; \
189 }) 193 })
190#endif 194#endif
191 195
192#define __percpu_generic_to_op(var, val, op) \ 196#define __percpu_generic_to_op(var, val, op) \
193do { \ 197do { \
194 get_cpu_var(var) op val; \ 198 typeof(var) *pgto_ptr__ = &(var); \
195 put_cpu_var(var); \ 199 get_cpu_var(*pgto_ptr__) op val; \
200 put_cpu_var(*pgto_ptr__); \
196} while (0) 201} while (0)
197 202
198#ifndef percpu_write 203#ifndef percpu_write
@@ -304,7 +309,7 @@ do { \
304#define _this_cpu_generic_to_op(pcp, val, op) \ 309#define _this_cpu_generic_to_op(pcp, val, op) \
305do { \ 310do { \
306 preempt_disable(); \ 311 preempt_disable(); \
307 *__this_cpu_ptr(&pcp) op val; \ 312 *__this_cpu_ptr(&(pcp)) op val; \
308 preempt_enable(); \ 313 preempt_enable(); \
309} while (0) 314} while (0)
310 315