Skip to content

Commit 47c9dbd

Browse files
ubizjakIngo Molnar
authored andcommitted
x86/percpu: Move some percpu accessors around to reduce ifdeffery
Move some percpu accessors around, mainly to reduce ifdeffery and improve readabilty by following dependencies between accessors. No functional change intended. Signed-off-by: Uros Bizjak <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Linus Torvalds <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 4890891 commit 47c9dbd

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

arch/x86/include/asm/percpu.h

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -445,17 +445,6 @@ do { \
445445
#define this_cpu_try_cmpxchg128(pcp, ovalp, nval) percpu_try_cmpxchg128_op(16, volatile, pcp, ovalp, nval)
446446
#endif
447447

448-
/*
449-
* this_cpu_read() makes gcc load the percpu variable every time it is
450-
* accessed while this_cpu_read_stable() allows the value to be cached.
451-
* this_cpu_read_stable() is more efficient and can be used if its value
452-
* is guaranteed to be valid across cpus. The current users include
453-
* pcpu_hot.current_task and pcpu_hot.top_of_stack, both of which are
454-
* actually per-thread variables implemented as per-CPU variables and
455-
* thus stable for the duration of the respective task.
456-
*/
457-
#define this_cpu_read_stable(pcp) __pcpu_size_call_return(this_cpu_read_stable_, pcp)
458-
459448
#define raw_cpu_read_1(pcp) __raw_cpu_read(1, , pcp)
460449
#define raw_cpu_read_2(pcp) __raw_cpu_read(2, , pcp)
461450
#define raw_cpu_read_4(pcp) __raw_cpu_read(4, , pcp)
@@ -470,16 +459,6 @@ do { \
470459
#define this_cpu_write_2(pcp, val) __raw_cpu_write(2, volatile, pcp, val)
471460
#define this_cpu_write_4(pcp, val) __raw_cpu_write(4, volatile, pcp, val)
472461

473-
#ifdef CONFIG_X86_64
474-
#define raw_cpu_read_8(pcp) __raw_cpu_read(8, , pcp)
475-
#define raw_cpu_write_8(pcp, val) __raw_cpu_write(8, , pcp, val)
476-
477-
#define this_cpu_read_8(pcp) __raw_cpu_read(8, volatile, pcp)
478-
#define this_cpu_write_8(pcp, val) __raw_cpu_write(8, volatile, pcp, val)
479-
#endif
480-
481-
#define this_cpu_read_const(pcp) __raw_cpu_read_const(pcp)
482-
483462
#define this_cpu_read_stable_1(pcp) __raw_cpu_read_stable(1, pcp)
484463
#define this_cpu_read_stable_2(pcp) __raw_cpu_read_stable(2, pcp)
485464
#define this_cpu_read_stable_4(pcp) __raw_cpu_read_stable(4, pcp)
@@ -535,6 +514,12 @@ do { \
535514
* 32 bit must fall back to generic operations.
536515
*/
537516
#ifdef CONFIG_X86_64
517+
#define raw_cpu_read_8(pcp) __raw_cpu_read(8, , pcp)
518+
#define raw_cpu_write_8(pcp, val) __raw_cpu_write(8, , pcp, val)
519+
520+
#define this_cpu_read_8(pcp) __raw_cpu_read(8, volatile, pcp)
521+
#define this_cpu_write_8(pcp, val) __raw_cpu_write(8, volatile, pcp, val)
522+
538523
#define this_cpu_read_stable_8(pcp) __raw_cpu_read_stable(8, pcp)
539524

540525
#define raw_cpu_add_8(pcp, val) percpu_add_op(8, , (pcp), val)
@@ -561,6 +546,19 @@ do { \
561546
#define raw_cpu_read_long(pcp) raw_cpu_read_4(pcp)
562547
#endif
563548

549+
#define this_cpu_read_const(pcp) __raw_cpu_read_const(pcp)
550+
551+
/*
552+
* this_cpu_read() makes gcc load the percpu variable every time it is
553+
* accessed while this_cpu_read_stable() allows the value to be cached.
554+
* this_cpu_read_stable() is more efficient and can be used if its value
555+
* is guaranteed to be valid across cpus. The current users include
556+
* pcpu_hot.current_task and pcpu_hot.top_of_stack, both of which are
557+
* actually per-thread variables implemented as per-CPU variables and
558+
* thus stable for the duration of the respective task.
559+
*/
560+
#define this_cpu_read_stable(pcp) __pcpu_size_call_return(this_cpu_read_stable_, pcp)
561+
564562
#define x86_this_cpu_constant_test_bit(_nr, _var) \
565563
({ \
566564
unsigned long __percpu *addr__ = \

0 commit comments

Comments
 (0)