Skip to content

Commit 764f6a8

Browse files
Zilin Guanfbq
authored andcommitted
rcu: Remove READ_ONCE() for rdp->gpwrap access in __note_gp_changes()
There is one access to the per-CPU rdp->gpwrap field in the __note_gp_changes() function that does not use READ_ONCE(), but all other accesses 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 all calls to __note_gp_changes() hold rnp->lock, which excludes writes to the rdp->gpwrap fields for all CPUs associated with that same leaf rcu_node structure. This commit therefore removes READ_ONCE() from rdp->gpwrap accesses within the __note_gp_changes() function. Signed-off-by: Zilin Guan <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]> Signed-off-by: Boqun Feng <[email protected]>
1 parent a3e8162 commit 764f6a8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/rcu/tree.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,7 @@ static bool __note_gp_changes(struct rcu_node *rnp, struct rcu_data *rdp)
12541254

12551255
/* Handle the ends of any preceding grace periods first. */
12561256
if (rcu_seq_completed_gp(rdp->gp_seq, rnp->gp_seq) ||
1257-
unlikely(READ_ONCE(rdp->gpwrap))) {
1257+
unlikely(rdp->gpwrap)) {
12581258
if (!offloaded)
12591259
ret = rcu_advance_cbs(rnp, rdp); /* Advance CBs. */
12601260
rdp->core_needs_qs = false;
@@ -1268,7 +1268,7 @@ static bool __note_gp_changes(struct rcu_node *rnp, struct rcu_data *rdp)
12681268

12691269
/* Now handle the beginnings of any new-to-this-CPU grace periods. */
12701270
if (rcu_seq_new_gp(rdp->gp_seq, rnp->gp_seq) ||
1271-
unlikely(READ_ONCE(rdp->gpwrap))) {
1271+
unlikely(rdp->gpwrap)) {
12721272
/*
12731273
* If the current grace period is waiting for this CPU,
12741274
* set up to detect a quiescent state, otherwise don't
@@ -1283,7 +1283,7 @@ static bool __note_gp_changes(struct rcu_node *rnp, struct rcu_data *rdp)
12831283
rdp->gp_seq = rnp->gp_seq; /* Remember new grace-period state. */
12841284
if (ULONG_CMP_LT(rdp->gp_seq_needed, rnp->gp_seq_needed) || rdp->gpwrap)
12851285
WRITE_ONCE(rdp->gp_seq_needed, rnp->gp_seq_needed);
1286-
if (IS_ENABLED(CONFIG_PROVE_RCU) && READ_ONCE(rdp->gpwrap))
1286+
if (IS_ENABLED(CONFIG_PROVE_RCU) && rdp->gpwrap)
12871287
WRITE_ONCE(rdp->last_sched_clock, jiffies);
12881288
WRITE_ONCE(rdp->gpwrap, false);
12891289
rcu_gpnum_ovf(rnp, rdp);

0 commit comments

Comments
 (0)