Re: [PATCH v3 1/2] rwonce: Add READ_ONCE_THIS_CPU() and WRITE_ONCE_THIS_CPU()
From: Arnd Bergmann
Date: Wed Oct 07 2026 - 07:44:51 EST
On Wed, Oct 7, 2026, at 04:28, Kunwu Chan wrote:
> Per-CPU variables are sometimes accessed from different execution
> contexts on the same CPU, typically task context and an interrupt or
> NMI handler.
>
> A plain READ_ONCE() or WRITE_ONCE() marks such an access as an
> intentional race but does not express where the racing accesses are
> expected to come from. This distinction allows concurrency tools such
> as KCSAN to tell an intentional same-CPU context race apart from an
> access that may race across CPUs.
>
> Add READ_ONCE_THIS_CPU() and WRITE_ONCE_THIS_CPU() to identify accesses
> to a per-CPU variable which are intended to race only with accesses
> from other execution contexts on the same CPU. For now, they are
> simple wrappers around READ_ONCE() and WRITE_ONCE(), so generated code
> and tool behaviour are unchanged.
>
> Suggested-by: Thomas Gleixner <tglx@xxxxxxxxxx>
> Suggested-by: Paul E. McKenney <paulmck@xxxxxxxxxx>
> Reviewed-by: Paul E. McKenney <paulmck@xxxxxxxxxx>
> Acked-by: Frederic Weisbecker <frederic@xxxxxxxxxx>
> Signed-off-by: Kunwu Chan <kunwu.chan@xxxxxxxxx>
No objections here, but since I missed the background, I don't
see what a future implementation of the new macros might do
that is different from the existing macros, maybe you can still
clarify that.
For taking this through something other than my asm-generic tree:
Acked-by: Arnd Bergmann <arnd@xxxxxxxx>