Skip to content

Commit c94055f

Browse files
Brian GerstKAGA-KOKO
authored andcommitted
x86/percpu: Clean up percpu_stable_op()
Use __pcpu_size_call_return() to simplify this_cpu_read_stable(). Also remove __bad_percpu_size() which is now unused. Signed-off-by: Brian Gerst <[email protected]> Signed-off-by: Nick Desaulniers <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Nick Desaulniers <[email protected]> Tested-by: Sedat Dilek <[email protected]> Reviewed-by: Nick Desaulniers <[email protected]> Acked-by: Linus Torvalds <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Dennis Zhou <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent ebcd580 commit c94055f

File tree

1 file changed

+12
-29
lines changed

1 file changed

+12
-29
lines changed

arch/x86/include/asm/percpu.h

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@
8585

8686
/* For arch-specific code, we can use direct single-insn ops (they
8787
* don't give an lvalue though). */
88-
extern void __bad_percpu_size(void);
8988

9089
#define __pcpu_type_1 u8
9190
#define __pcpu_type_2 u16
@@ -167,33 +166,13 @@ do { \
167166
(typeof(_var))(unsigned long) pfo_val__; \
168167
})
169168

170-
#define percpu_stable_op(op, var) \
171-
({ \
172-
typeof(var) pfo_ret__; \
173-
switch (sizeof(var)) { \
174-
case 1: \
175-
asm(op "b "__percpu_arg(P1)",%0" \
176-
: "=q" (pfo_ret__) \
177-
: "p" (&(var))); \
178-
break; \
179-
case 2: \
180-
asm(op "w "__percpu_arg(P1)",%0" \
181-
: "=r" (pfo_ret__) \
182-
: "p" (&(var))); \
183-
break; \
184-
case 4: \
185-
asm(op "l "__percpu_arg(P1)",%0" \
186-
: "=r" (pfo_ret__) \
187-
: "p" (&(var))); \
188-
break; \
189-
case 8: \
190-
asm(op "q "__percpu_arg(P1)",%0" \
191-
: "=r" (pfo_ret__) \
192-
: "p" (&(var))); \
193-
break; \
194-
default: __bad_percpu_size(); \
195-
} \
196-
pfo_ret__; \
169+
#define percpu_stable_op(size, op, _var) \
170+
({ \
171+
__pcpu_type_##size pfo_val__; \
172+
asm(__pcpu_op2_##size(op, __percpu_arg(P[var]), "%[val]") \
173+
: [val] __pcpu_reg_##size("=", pfo_val__) \
174+
: [var] "p" (&(_var))); \
175+
(typeof(_var))(unsigned long) pfo_val__; \
197176
})
198177

199178
/*
@@ -258,7 +237,11 @@ do { \
258237
* per-thread variables implemented as per-cpu variables and thus
259238
* stable for the duration of the respective task.
260239
*/
261-
#define this_cpu_read_stable(var) percpu_stable_op("mov", var)
240+
#define this_cpu_read_stable_1(pcp) percpu_stable_op(1, "mov", pcp)
241+
#define this_cpu_read_stable_2(pcp) percpu_stable_op(2, "mov", pcp)
242+
#define this_cpu_read_stable_4(pcp) percpu_stable_op(4, "mov", pcp)
243+
#define this_cpu_read_stable_8(pcp) percpu_stable_op(8, "mov", pcp)
244+
#define this_cpu_read_stable(pcp) __pcpu_size_call_return(this_cpu_read_stable_, pcp)
262245

263246
#define raw_cpu_read_1(pcp) percpu_from_op(1, , "mov", pcp)
264247
#define raw_cpu_read_2(pcp) percpu_from_op(2, , "mov", pcp)

0 commit comments

Comments
 (0)