Skip to content

Commit 2a2ae87

Browse files
committed
rcu: Add *_ONCE() to rcu_data ->rcu_forced_tick
The rcu_data structure's ->rcu_forced_tick field is read locklessly, so this commit adds WRITE_ONCE() to all updates and READ_ONCE() to all lockless reads. This data race was reported by KCSAN. Not appropriate for backporting due to failure being unlikely. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent a5b8950 commit 2a2ae87

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

kernel/rcu/tree.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -818,11 +818,12 @@ static __always_inline void rcu_nmi_enter_common(bool irq)
818818
incby = 1;
819819
} else if (tick_nohz_full_cpu(rdp->cpu) &&
820820
rdp->dynticks_nmi_nesting == DYNTICK_IRQ_NONIDLE &&
821-
READ_ONCE(rdp->rcu_urgent_qs) && !rdp->rcu_forced_tick) {
821+
READ_ONCE(rdp->rcu_urgent_qs) &&
822+
!READ_ONCE(rdp->rcu_forced_tick)) {
822823
raw_spin_lock_rcu_node(rdp->mynode);
823824
// Recheck under lock.
824825
if (rdp->rcu_urgent_qs && !rdp->rcu_forced_tick) {
825-
rdp->rcu_forced_tick = true;
826+
WRITE_ONCE(rdp->rcu_forced_tick, true);
826827
tick_dep_set_cpu(rdp->cpu, TICK_DEP_BIT_RCU);
827828
}
828829
raw_spin_unlock_rcu_node(rdp->mynode);
@@ -899,7 +900,7 @@ static void rcu_disable_urgency_upon_qs(struct rcu_data *rdp)
899900
WRITE_ONCE(rdp->rcu_need_heavy_qs, false);
900901
if (tick_nohz_full_cpu(rdp->cpu) && rdp->rcu_forced_tick) {
901902
tick_dep_clear_cpu(rdp->cpu, TICK_DEP_BIT_RCU);
902-
rdp->rcu_forced_tick = false;
903+
WRITE_ONCE(rdp->rcu_forced_tick, false);
903904
}
904905
}
905906

0 commit comments

Comments
 (0)