[PATCH v2 14/20] arm64: percpu: Implement preemptible read/write ops
Mark Rutland
mark.rutland at arm.com
Wed Aug 5 06:34:57 PDT 2026
On Wed, Aug 05, 2026 at 10:24:04AM +0100, Ryan Roberts wrote:
> On 04/08/2026 18:04, Mark Rutland wrote:
> > ---
> FYI I'm seeing build warnings caused by this patch (with ftrace enabled - based
> on the warnings, I'm guessing that's the key bit), using:
>
> aarch64-linux-gnu-gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
>
> I haven't investigated the cause.
Thanks for the heads-up.
This is an unfortunate effect of the casting in this_cpu_write_##sz
wrappers:
(1) For cases where pcp is itself a pointer, compilers warn for the
unreachable (sz != 8) cases, unless we add a cast to unsigned long
in all of the cases.
(2) With the cast, compilers warn about implicit truncation (as you're
seeing here), where we've performed redundant extension in the first
place.
To workaround that I believe we need an explicit cast somewhere, unless we can
get the compilers to realise the other cases are obviously unreachable. Two
possible workarounds:
(a) We make __percpu_write_##sz() take an unsigned long, and cast it
down to u##sz in the asm arguments.
(b) We update this_cpu_write_{1,2,4,8} with {u8,u16,u32,u64} casts,
applied after the unsigned long cast.
For now, (a) is the simplest, as below. I'll see if there's a better option.q
Mark.
---->8----
diff --git a/arch/arm64/include/asm/percpu.h b/arch/arm64/include/asm/percpu.h
index d868a88960123..dd49d14d9cd91 100644
--- a/arch/arm64/include/asm/percpu.h
+++ b/arch/arm64/include/asm/percpu.h
@@ -149,7 +149,7 @@ static inline unsigned long __percpu_read_##sz(void __percpu *pcp) \
return val; \
} \
\
-static inline void __percpu_write_##sz(void __percpu *pcp, u##sz val) \
+static inline void __percpu_write_##sz(void __percpu *pcp, unsigned long val) \
{ \
u16 *gprs = ¤t_thread_info()->pcpu_gprs; \
unsigned long off; \
@@ -161,7 +161,7 @@ static inline void __percpu_write_##sz(void __percpu *pcp, u##sz val) \
: [gprs] "=Qo" (*gprs), \
[off] "=&r" (off) \
: [pcp] "r" (pcp), \
- [val] "r" (val) \
+ [val] "r" ((u##sz)val) \
: "memory" \
); \
}
More information about the linux-arm-kernel
mailing list