From: Zilin Guan <zilinguan811@gmail.com>
To: paulmck@kernel.org
Cc: boqun.feng@gmail.com, frederic@kernel.org,
jiangshanlai@gmail.com, joel@joelfernandes.org,
josh@joshtriplett.org, linux-kernel@vger.kernel.org,
mathieu.desnoyers@efficios.com, neeraj.upadhyay@kernel.org,
qiang.zhang1211@gmail.com, rcu@vger.kernel.org,
rostedt@goodmis.org, urezki@gmail.com, zilinguan811@gmail.com,
xujianhao01@gmail.com
Subject: Re: [PATCH] rcu: Use READ_ONCE() for rdp->gpwrap access in __note_gp_changes()
Date: Thu, 7 Nov 2024 14:01:17 +0000 [thread overview]
Message-ID: <20241107140117.3790954-1-zilinguan811@gmail.com> (raw)
In-Reply-To: <65bfe6b1-3bfa-469d-aada-8e79d1101d5d@paulmck-laptop>
On Wed, Nov 06, 2024 at 12:18:25PM -0800, Paul E. McKenney wrote:
> Good eyes!!!
>
> But did you find this with KCSAN, or by visual inspection?
>
> The reason that I ask is that the __note_gp_changes() should be
> invoked with the leaf rnp->lock held, which should exclude writes to
> the rdp->gpwrap fields for all CPUs corresponding to that leaf rcu_node
> structure.
>
> Note the raw_lockdep_assert_held_rcu_node(rnp) call at the beginning of
> this function.
>
> So I believe that the proper fix is to *remove* READ_ONCE() from accesses
> to rdp->gpwrap in this function.
>
> Or am I missing something here?
>
> Thanx, Paul
I found this by visual inspection.
When reviewing the function __note_gp_changes(), I noticed that other
accesses to rdp->gpwrap are protected with either READ_ONCE() or
WRITE_ONCE(), which led me to suspect a potential data race at line 1305.
However, I am not certain whether holding rnp->lock protects access to
rdp->gpwrap in this case. If it indeed ensures that no concurrent writes
can occur, then I agree that the correct approach would be to remove
READ_ONCE() from those accesses.
Thanks,
Zilin
next prev parent reply other threads:[~2024-11-07 14:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-04 15:12 Zilin Guan
2024-11-06 20:18 ` Paul E. McKenney
2024-11-07 14:01 ` Zilin Guan [this message]
2024-11-07 14:15 ` 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=20241107140117.3790954-1-zilinguan811@gmail.com \
--to=zilinguan811@gmail.com \
--cc=boqun.feng@gmail.com \
--cc=frederic@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=neeraj.upadhyay@kernel.org \
--cc=paulmck@kernel.org \
--cc=qiang.zhang1211@gmail.com \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=urezki@gmail.com \
--cc=xujianhao01@gmail.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®