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: [PATCH v2] rcu: Remove READ_ONCE() for rdp->gpwrap access in __note_gp_changes()
Date: Sun, 10 Nov 2024 14:47:47 +0000 [thread overview]
Message-ID: <20241110144747.21379-1-zilinguan811@gmail.com> (raw)
There is one access to rdp->gpwrap in the __note_gp_changes() function
that does not use READ_ONCE() for protection, while other accesses to
rdp->gpwrap do use READ_ONCE(). When using the 8*TREE03 and
CONFIG_NR_CPUS=8 configuration, KCSAN found no data races at that point.
This is because other functions should hold rnp->lock when calling
__note_gp_changes(), which ensures proper exclusion of writes to the
rdp->gpwrap fields for all CPUs associated with that leaf rcu_node
structure.
Therefore, using READ_ONCE() to protect rdp->gpwrap within the
__note_gp_changes() function is unnecessary.
Signed-off-by: Zilin Guan <zilinguan811@gmail.com>
---
v1 -> v2: Remove READ_ONCE() from accesses to rdp->gpwrap.
kernel/rcu/tree.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 77b5b39e19a8..68eb0f746575 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -1275,7 +1275,7 @@ static bool __note_gp_changes(struct rcu_node *rnp, struct rcu_data *rdp)
/* Handle the ends of any preceding grace periods first. */
if (rcu_seq_completed_gp(rdp->gp_seq, rnp->gp_seq) ||
- unlikely(READ_ONCE(rdp->gpwrap))) {
+ unlikely(rdp->gpwrap)) {
if (!offloaded)
ret = rcu_advance_cbs(rnp, rdp); /* Advance CBs. */
rdp->core_needs_qs = false;
@@ -1289,7 +1289,7 @@ static bool __note_gp_changes(struct rcu_node *rnp, struct rcu_data *rdp)
/* Now handle the beginnings of any new-to-this-CPU grace periods. */
if (rcu_seq_new_gp(rdp->gp_seq, rnp->gp_seq) ||
- unlikely(READ_ONCE(rdp->gpwrap))) {
+ unlikely(rdp->gpwrap)) {
/*
* If the current grace period is waiting for this CPU,
* set up to detect a quiescent state, otherwise don't
@@ -1304,7 +1304,7 @@ static bool __note_gp_changes(struct rcu_node *rnp, struct rcu_data *rdp)
rdp->gp_seq = rnp->gp_seq; /* Remember new grace-period state. */
if (ULONG_CMP_LT(rdp->gp_seq_needed, rnp->gp_seq_needed) || rdp->gpwrap)
WRITE_ONCE(rdp->gp_seq_needed, rnp->gp_seq_needed);
- if (IS_ENABLED(CONFIG_PROVE_RCU) && READ_ONCE(rdp->gpwrap))
+ if (IS_ENABLED(CONFIG_PROVE_RCU) && rdp->gpwrap)
WRITE_ONCE(rdp->last_sched_clock, jiffies);
WRITE_ONCE(rdp->gpwrap, false);
rcu_gpnum_ovf(rnp, rdp);
--
2.34.1
next reply other threads:[~2024-11-10 14:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-10 14:47 Zilin Guan [this message]
2024-12-10 20:56 ` 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=20241110144747.21379-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®