mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Sun Shaojie <sunshaojie@kylinos.cn>
Cc: Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
	Boqun Feng <boqun@kernel.org>, Waiman Long <longman@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] locking/percpu-rwsem: Annotate intentional data race in readers_active_check()
Date: Tue, 23 Jun 2026 11:44:50 +0200	[thread overview]
Message-ID: <20260623094450.GP42921@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20260623093445.456402-1-sunshaojie@kylinos.cn>

On Tue, Jun 23, 2026 at 05:34:45PM +0800, Sun Shaojie wrote:
> KCSAN reports a data race in readers_active_check():
> 
>   BUG: KCSAN: data-race in readers_active_check / percpu_down_write
> 
>   race at unknown origin, with read to 0xffff9f3eb5bf5f30 of 4 bytes
>   by task 1271 on cpu 14:
>    readers_active_check+0x...
>    percpu_down_write+0x152/0x1f0
> 
>   value changed: 0xfffffff9 -> 0xfffffff8
> 
> This is a benign race. Annotate it with data_race() to suppress the
> KCSAN warning.

I'm not even sure I can tell what actual access is seemed problematic
from this report, let alone tell your reasoning for why it is benign.

And while I think the patch is ok (with my vague memories of the code at
hand), this changelog is entirely insufficient.

> Signed-off-by: Sun Shaojie <sunshaojie@kylinos.cn>
> ---
>  kernel/locking/percpu-rwsem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/locking/percpu-rwsem.c b/kernel/locking/percpu-rwsem.c
> index f7e152c40d6d..6c78961fe753 100644
> --- a/kernel/locking/percpu-rwsem.c
> +++ b/kernel/locking/percpu-rwsem.c
> @@ -211,7 +211,7 @@ EXPORT_SYMBOL_GPL(percpu_is_read_locked);
>   */
>  static bool readers_active_check(struct percpu_rw_semaphore *sem)
>  {
> -	if (per_cpu_sum(*sem->read_count) != 0)
> +	if (data_race(per_cpu_sum(*sem->read_count)) != 0)
>  		return false;
>  
>  	/*
> -- 
> 2.25.1
> 

  reply	other threads:[~2026-06-23  9:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-23  9:34 Sun Shaojie
2026-06-23  9:44 ` Peter Zijlstra [this message]
2026-06-23 10:41   ` [PATCH v2] " Sun Shaojie
2026-06-23 13:25     ` Peter Zijlstra

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=20260623094450.GP42921@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=boqun@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=sunshaojie@kylinos.cn \
    --cc=will@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

Powered by JetHome