From: Bart Van Assche <bvanassche@acm.org>
To: paulmck@kernel.org
Cc: Breno Leitao <leitao@debian.org>, Jens Axboe <axboe@kernel.dk>,
"open list:BLOCK LAYER" <linux-block@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] block: Annotate a racy read in blk_do_io_stat()
Date: Fri, 10 May 2024 13:30:03 -0700 [thread overview]
Message-ID: <4d230bac-bdb0-4a01-8006-e95156965aa8@acm.org> (raw)
In-Reply-To: <c83d9c25-b839-4e31-8dd4-85f3cb938653@paulmck-laptop>
On 5/10/24 10:08 AM, Paul E. McKenney wrote:
> To see that, consider a variable that is supposed to be accessed only
> under a lock (aside from the debugging/statistical access). Under RCU's
> KCSAN rules, marking those debugging/statistical accesses with READ_ONCE()
> would require all the updates to be marked with WRITE_ONCE(). Which would
> prevent KCSAN from noticing a buggy lockless WRITE_ONCE() update of
> that variable.
>
> In contrast, if we use data_race() for the debugging/statistical accesses
> and leave the normal lock-protected accesses unmarked (as normal
> C-language accesses), then KCSAN will complain about buggy lockless
> accesses, even if they are marked with READ_ONCE() or WRITE_ONCE().
>
> Does that help, or am I missing your point?
Thanks, that's very helpful. Has it been considered to add this
explanation as a comment above the data_race() macro definition?
There may be other kernel developers who are wondering about when
to use data_race() and when to use READ_ONCE().
Thanks,
Bart.
next prev parent reply other threads:[~2024-05-10 20:30 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-10 14:19 [PATCH] block: Annotate a racy read in blk_do_io_stat() Breno Leitao
2024-05-10 14:28 ` Bart Van Assche
2024-05-10 14:57 ` Breno Leitao
2024-05-10 15:41 ` Paul E. McKenney
2024-05-10 16:20 ` Bart Van Assche
2024-05-10 17:08 ` Paul E. McKenney
2024-05-10 20:30 ` Bart Van Assche [this message]
2024-05-10 22:35 ` Paul E. McKenney
2024-05-10 23:22 ` Bart Van Assche
2024-05-11 0:41 ` Paul E. McKenney
2024-05-13 8:13 ` Marco Elver
2024-05-14 23:47 ` Paul E. McKenney
2024-05-15 7:58 ` Marco Elver
2024-05-15 12:48 ` Breno Leitao
2024-05-15 13:20 ` Marco Elver
2024-05-15 15:57 ` Paul E. McKenney
2024-05-15 17:40 ` Marco Elver
2024-05-15 21:51 ` Paul E. McKenney
2024-05-16 6:35 ` Marco Elver
2024-05-20 18:05 ` Paul E. McKenney
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=4d230bac-bdb0-4a01-8006-e95156965aa8@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=leitao@debian.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@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