Skip to content

Commit 105abf8

Browse files
committed
rcu: Add WRITE_ONCE() to rcu_node ->qsmaskinitnext
The rcu_state structure's ->qsmaskinitnext field is read locklessly, so this commit adds the WRITE_ONCE() to an update in order to provide proper documentation and READ_ONCE()/WRITE_ONCE() pairing. This data race was reported by KCSAN. Not appropriate for backporting due to failure being unlikely for systems not doing incessant CPU-hotplug operations. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 2906d21 commit 105abf8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/rcu/tree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3379,7 +3379,7 @@ void rcu_cpu_starting(unsigned int cpu)
33793379
rnp = rdp->mynode;
33803380
mask = rdp->grpmask;
33813381
raw_spin_lock_irqsave_rcu_node(rnp, flags);
3382-
rnp->qsmaskinitnext |= mask;
3382+
WRITE_ONCE(rnp->qsmaskinitnext, rnp->qsmaskinitnext | mask);
33833383
oldmask = rnp->expmaskinitnext;
33843384
rnp->expmaskinitnext |= mask;
33853385
oldmask ^= rnp->expmaskinitnext;
@@ -3432,7 +3432,7 @@ void rcu_report_dead(unsigned int cpu)
34323432
rcu_report_qs_rnp(mask, rnp, rnp->gp_seq, flags);
34333433
raw_spin_lock_irqsave_rcu_node(rnp, flags);
34343434
}
3435-
rnp->qsmaskinitnext &= ~mask;
3435+
WRITE_ONCE(rnp->qsmaskinitnext, rnp->qsmaskinitnext & ~mask);
34363436
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
34373437
raw_spin_unlock(&rcu_state.ofl_lock);
34383438

0 commit comments

Comments
 (0)