From: Petr Mladek <pmladek@suse.com>
To: John Ogness <john.ogness@linutronix.de>
Cc: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
linux-kernel@vger.kernel.org,
syzbot+8324b8fd984b86905a66@syzkaller.appspotmail.com
Subject: Re: [PATCH] printk: mark racy data block id accesses in the ringbuffer
Date: Mon, 12 Oct 2026 14:29:19 +0200 [thread overview]
Message-ID: <aszSn4stj7ydLJNk@pathway.suse.cz> (raw)
In-Reply-To: <87a4oj9r1s.fsf@jogness.linutronix.de>
On Mon 2026-10-12 12:06:47, John Ogness wrote:
> On 2026-10-11, Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com> wrote:
> > data_alloc() stores the descriptor ID into a newly reserved data block
> > while data_make_reusable(), running from data_push_tail() on another CPU,
> > may still be loading the ID from the same area. The code relies on this
> > race being harmless: a stale or garbage ID simply fails the descriptor
> > lookup or the blk_lpos check. But the accesses are plain, so KCSAN
> > reports them, and the compiler is free to tear or refetch the ID.
> >
> > Use READ_ONCE()/WRITE_ONCE() for every access to the block ID that can
> > overlap with the lockless reader. No functional change intended.
>
> READ_ONCE()/WRITE_ONCE() could cause minor side-effects as it prohibits
> optimizations that do not need to be prohibited. These would not cause a
> problem, but they are unnecessary. The data race is allowed.
>
> How about using data_race() instead?
>
> id = data_race(blk->id);
>
> data_race(blk->id = id);
I prefer data_race() because it makes it clear that the race is
expected. Using READ_ONCE()/READ_ONCE() would create false expectations
that they are needed to prevent some races.
Best Regards,
Petr
prev parent reply other threads:[~2026-10-12 12:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-11 9:17 Nguyen Ngoc Thang
2026-10-12 10:00 ` John Ogness
2026-10-12 12:29 ` Petr Mladek [this message]
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=aszSn4stj7ydLJNk@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=ngocthang2710.1999@gmail.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=syzbot+8324b8fd984b86905a66@syzkaller.appspotmail.com \
/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®