[Devel] [PATCH vz10 16/32] ms/percpu: cast percpu pointer in PERCPU_PTR() via unsigned long
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Aug 21 19:37:02 MSK 2026
From: Uros Bizjak <ubizjak at gmail.com>
Cast pointer from percpu address space to generic (kernel) address space
in PERCPU_PTR() macro via unsigned long intermediate cast [1]. This
intermediate cast is also required to avoid build failure when GCC's
strict named address space checks for x86 targets [2] are enabled.
Found by GCC's named address space checks.
[1] https://sparse.docs.kernel.org/en/latest/annotations.html#address-space-name
[2] https://gcc.gnu.org/onlinedocs/gcc/Named-Address-Spaces.html#x86-Named-Address-Spaces
Link: https://lkml.kernel.org/r/20241021080856.48746-3-ubizjak@gmail.com
Signed-off-by: Uros Bizjak <ubizjak at gmail.com>
Acked-by: Christoph Lameter <cl at linux.com>
Cc: Dennis Zhou <dennis at kernel.org>
Cc: Tejun Heo <tj at kernel.org>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
(cherry picked from commit dabddd687c9e1a06241d6b4d1f66b9f2b60b3ad1)
Conflict resolution: the previous patch of the same upstream series had
to drop the stray trailing semicolon of PERCPU_PTR() to stay buildable
here, so only the body of the macro is replaced.
https://virtuozzo.atlassian.net/browse/VSTOR-134732
Feature: fix rh/sched
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
include/linux/percpu-defs.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h
index 02bcd74afc6c..ee236ee0bed6 100644
--- a/include/linux/percpu-defs.h
+++ b/include/linux/percpu-defs.h
@@ -221,7 +221,10 @@ do { \
} while (0)
#define PERCPU_PTR(__p) \
- (typeof(*(__p)) __force __kernel *)(__p)
+({ \
+ unsigned long __pcpu_ptr = (__force unsigned long)(__p); \
+ (typeof(*(__p)) __force __kernel *)(__pcpu_ptr); \
+})
#ifdef CONFIG_SMP
--
2.47.1
More information about the Devel
mailing list