]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/percpu: Introduce the __raw_cpu_read_const() macro
authorUros Bizjak <ubizjak@gmail.com>
Tue, 30 Apr 2024 09:17:23 +0000 (11:17 +0200)
committerIngo Molnar <mingo@kernel.org>
Sat, 18 May 2024 09:18:42 +0000 (11:18 +0200)
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 <ubizjak@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/20240430091833.196482-4-ubizjak@gmail.com
arch/x86/include/asm/percpu.h

index f360ac5fccdef27d298d824900742b7f5e05d389..d20255138426f14ec3e54a54c4644fc8aaf404d7 100644 (file)
@@ -156,6 +156,8 @@ do {                                                                        \
        *(qual __my_cpu_type(pcp) *)__my_cpu_ptr(&(pcp)) = (val);       \
 } while (0)
 
+#define __raw_cpu_read_const(pcp)      __raw_cpu_read(, , pcp)
+
 #else /* CONFIG_USE_X86_SEG_SUPPORT */
 
 #define __raw_cpu_read(size, qual, _var)                               \
@@ -180,6 +182,12 @@ do {                                                                       \
            : [val] __pcpu_reg_imm_##size(pto_val__));                  \
 } while (0)
 
+/*
+ * The generic per-cpu infrastrucutre is not suitable for
+ * reading const-qualified variables.
+ */
+#define __raw_cpu_read_const(pcp)      ({ BUILD_BUG(); (typeof(pcp))0; })
+
 #endif /* CONFIG_USE_X86_SEG_SUPPORT */
 
 #define percpu_stable_op(size, op, _var)                               \
@@ -470,16 +478,7 @@ do {                                                                       \
 #define this_cpu_write_8(pcp, val)     __raw_cpu_write(8, volatile, pcp, val)
 #endif
 
-#ifdef CONFIG_USE_X86_SEG_SUPPORT
-#define this_cpu_read_const(pcp)       __raw_cpu_read(, , pcp)
-#else /* CONFIG_USE_X86_SEG_SUPPORT */
-
-/*
- * The generic per-cpu infrastrucutre is not suitable for
- * reading const-qualified variables.
- */
-#define this_cpu_read_const(pcp)       ({ BUILD_BUG(); (typeof(pcp))0; })
-#endif /* CONFIG_USE_X86_SEG_SUPPORT */
+#define this_cpu_read_const(pcp)       __raw_cpu_read_const(pcp)
 
 #define this_cpu_read_stable_1(pcp)    percpu_stable_op(1, "mov", pcp)
 #define this_cpu_read_stable_2(pcp)    percpu_stable_op(2, "mov", pcp)