mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Frederic Weisbecker <frederic@kernel.org>
To: Kunwu Chan <kunwu.chan@gmail.com>
Cc: arnd@arndb.de, anna-maria@linutronix.de, mingo@kernel.org,
	tglx@kernel.org, linux-arch@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"Paul E . McKenney" <paulmck@kernel.org>
Subject: Re: [PATCH v2 1/2] rwonce: Add READ_ONCE_THIS_CPU() and WRITE_ONCE_THIS_CPU()
Date: Mon, 5 Oct 2026 16:47:23 +0200	[thread overview]
Message-ID: <asO4ey3X6JK0IzlY@localhost.localdomain> (raw)
In-Reply-To: <20261002151757.3605081-2-kunwu.chan@gmail.com>

Le Fri, Oct 02, 2026 at 11:17:55PM +0800, Kunwu Chan a écrit :
> 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.

But there is a plan to handle that with KSCAN, right?

If so:

Acked-by: Frederic Weisbecker <frederic@kernel.org>

Thanks.


> 
> Suggested-by: Thomas Gleixner <tglx@kernel.org>
> Suggested-by: Paul E. McKenney <paulmck@kernel.org>
> Signed-off-by: Kunwu Chan <kunwu.chan@gmail.com>
> ---
>  include/asm-generic/rwonce.h | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/include/asm-generic/rwonce.h b/include/asm-generic/rwonce.h
> index 52b969c7cef9..4d4e009a4489 100644
> --- a/include/asm-generic/rwonce.h
> +++ b/include/asm-generic/rwonce.h
> @@ -61,6 +61,17 @@ do {									\
>  	__WRITE_ONCE(x, val);						\
>  } while (0)
>  
> +/*
> + * {READ,WRITE}_ONCE_THIS_CPU() identify accesses to a per-CPU variable
> + * which are intended to race only with accesses from other execution
> + * contexts on the same CPU, e.g. task and interrupt context.
> + *
> + * For now, these are simple wrappers around READ_ONCE() and
> + * WRITE_ONCE().
> + */
> +#define READ_ONCE_THIS_CPU(x)		READ_ONCE(x)
> +#define WRITE_ONCE_THIS_CPU(x, val)	WRITE_ONCE(x, val)
> +
>  static __no_sanitize_or_inline
>  unsigned long __read_once_word_nocheck(const void *addr)
>  {
> -- 
> 2.43.0
> 

-- 
Frederic Weisbecker
SUSE Labs

  parent reply	other threads:[~2026-10-05 14:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-02 15:17 [PATCH v2 0/2] rwonce: Introduce {READ,WRITE}_ONCE_THIS_CPU() Kunwu Chan
2026-10-02 15:17 ` [PATCH v2 1/2] rwonce: Add READ_ONCE_THIS_CPU() and WRITE_ONCE_THIS_CPU() Kunwu Chan
2026-10-02 15:44   ` Paul E. McKenney
2026-10-05 14:47   ` Frederic Weisbecker [this message]
2026-10-02 15:17 ` [PATCH v2 2/2] timers/nohz: Mark got_idle_tick accesses as same-CPU races Kunwu Chan
2026-10-05 14:54   ` Frederic Weisbecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=asO4ey3X6JK0IzlY@localhost.localdomain \
    --to=frederic@kernel.org \
    --cc=anna-maria@linutronix.de \
    --cc=arnd@arndb.de \
    --cc=kunwu.chan@gmail.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=tglx@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®