Skip to content

Commit 539615d

Browse files
ubizjakIngo Molnar
authored andcommitted
x86/percpu: Introduce the __raw_cpu_read_const() macro
Introduce the __raw_cpu_read_const() macro to further reduce ifdeffery and differences between configs w/ and w/o USE_X86_SEG_SUPPORT. 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 a50ea64 commit 539615d

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

arch/x86/include/asm/percpu.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ do { \
156156
*(qual __my_cpu_type(pcp) *)__my_cpu_ptr(&(pcp)) = (val); \
157157
} while (0)
158158

159+
#define __raw_cpu_read_const(pcp) __raw_cpu_read(, , pcp)
160+
159161
#else /* CONFIG_USE_X86_SEG_SUPPORT */
160162

161163
#define __raw_cpu_read(size, qual, _var) \
@@ -180,6 +182,12 @@ do { \
180182
: [val] __pcpu_reg_imm_##size(pto_val__)); \
181183
} while (0)
182184

185+
/*
186+
* The generic per-cpu infrastrucutre is not suitable for
187+
* reading const-qualified variables.
188+
*/
189+
#define __raw_cpu_read_const(pcp) ({ BUILD_BUG(); (typeof(pcp))0; })
190+
183191
#endif /* CONFIG_USE_X86_SEG_SUPPORT */
184192

185193
#define percpu_stable_op(size, op, _var) \
@@ -470,16 +478,7 @@ do { \
470478
#define this_cpu_write_8(pcp, val) __raw_cpu_write(8, volatile, pcp, val)
471479
#endif
472480

473-
#ifdef CONFIG_USE_X86_SEG_SUPPORT
474-
#define this_cpu_read_const(pcp) __raw_cpu_read(, , pcp)
475-
#else /* CONFIG_USE_X86_SEG_SUPPORT */
476-
477-
/*
478-
* The generic per-cpu infrastrucutre is not suitable for
479-
* reading const-qualified variables.
480-
*/
481-
#define this_cpu_read_const(pcp) ({ BUILD_BUG(); (typeof(pcp))0; })
482-
#endif /* CONFIG_USE_X86_SEG_SUPPORT */
481+
#define this_cpu_read_const(pcp) __raw_cpu_read_const(pcp)
483482

484483
#define this_cpu_read_stable_1(pcp) percpu_stable_op(1, "mov", pcp)
485484
#define this_cpu_read_stable_2(pcp) percpu_stable_op(2, "mov", pcp)

0 commit comments

Comments
 (0)