Skip to content

Commit ce99b9c

Browse files
ubizjakIngo Molnar
authored andcommitted
x86/percpu: Move raw_percpu_xchg_op() to a better place
Move raw_percpu_xchg_op() together with this_percpu_xchg_op() and trivially rename some internal variables to harmonize them between macro implementations. No functional changes intended. Signed-off-by: Uros Bizjak <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Linus Torvalds <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 0539084 commit ce99b9c

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

arch/x86/include/asm/percpu.h

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,17 @@ do { \
229229
(typeof(_var))(unsigned long) (paro_tmp__ + _val); \
230230
})
231231

232+
/*
233+
* raw_cpu_xchg() can use a load-store since
234+
* it is not required to be IRQ-safe.
235+
*/
236+
#define raw_percpu_xchg_op(_var, _nval) \
237+
({ \
238+
typeof(_var) pxo_old__ = raw_cpu_read(_var); \
239+
raw_cpu_write(_var, _nval); \
240+
pxo_old__; \
241+
})
242+
232243
/*
233244
* this_cpu_xchg() is implemented using cmpxchg without a lock prefix.
234245
* xchg is expensive due to the implied lock prefix. The processor
@@ -499,18 +510,6 @@ do { \
499510
#define raw_cpu_or_1(pcp, val) percpu_to_op(1, , "or", (pcp), val)
500511
#define raw_cpu_or_2(pcp, val) percpu_to_op(2, , "or", (pcp), val)
501512
#define raw_cpu_or_4(pcp, val) percpu_to_op(4, , "or", (pcp), val)
502-
503-
/*
504-
* raw_cpu_xchg() can use a load-store since it is not required to be
505-
* IRQ-safe.
506-
*/
507-
#define raw_percpu_xchg_op(var, nval) \
508-
({ \
509-
typeof(var) pxo_ret__ = raw_cpu_read(var); \
510-
raw_cpu_write(var, (nval)); \
511-
pxo_ret__; \
512-
})
513-
514513
#define raw_cpu_xchg_1(pcp, val) raw_percpu_xchg_op(pcp, val)
515514
#define raw_cpu_xchg_2(pcp, val) raw_percpu_xchg_op(pcp, val)
516515
#define raw_cpu_xchg_4(pcp, val) raw_percpu_xchg_op(pcp, val)

0 commit comments

Comments
 (0)