Skip to content

Commit 3ca3b0e

Browse files
committed
rcu: Add *_ONCE() to rcu_node ->boost_kthread_status
The rcu_node structure's ->boost_kthread_status field is accessed locklessly, so this commit causes all updates to use WRITE_ONCE() and all reads to use READ_ONCE(). 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 2a2ae87 commit 3ca3b0e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

kernel/rcu/tree_plugin.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,18 +1032,18 @@ static int rcu_boost_kthread(void *arg)
10321032

10331033
trace_rcu_utilization(TPS("Start boost kthread@init"));
10341034
for (;;) {
1035-
rnp->boost_kthread_status = RCU_KTHREAD_WAITING;
1035+
WRITE_ONCE(rnp->boost_kthread_status, RCU_KTHREAD_WAITING);
10361036
trace_rcu_utilization(TPS("End boost kthread@rcu_wait"));
10371037
rcu_wait(rnp->boost_tasks || rnp->exp_tasks);
10381038
trace_rcu_utilization(TPS("Start boost kthread@rcu_wait"));
1039-
rnp->boost_kthread_status = RCU_KTHREAD_RUNNING;
1039+
WRITE_ONCE(rnp->boost_kthread_status, RCU_KTHREAD_RUNNING);
10401040
more2boost = rcu_boost(rnp);
10411041
if (more2boost)
10421042
spincnt++;
10431043
else
10441044
spincnt = 0;
10451045
if (spincnt > 10) {
1046-
rnp->boost_kthread_status = RCU_KTHREAD_YIELDING;
1046+
WRITE_ONCE(rnp->boost_kthread_status, RCU_KTHREAD_YIELDING);
10471047
trace_rcu_utilization(TPS("End boost kthread@rcu_yield"));
10481048
schedule_timeout_interruptible(2);
10491049
trace_rcu_utilization(TPS("Start boost kthread@rcu_yield"));
@@ -1082,7 +1082,7 @@ static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags)
10821082
rnp->boost_tasks = rnp->gp_tasks;
10831083
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
10841084
rcu_wake_cond(rnp->boost_kthread_task,
1085-
rnp->boost_kthread_status);
1085+
READ_ONCE(rnp->boost_kthread_status));
10861086
} else {
10871087
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
10881088
}

0 commit comments

Comments
 (0)