Skip to content

Commit 5822b81

Browse files
committed
rcu: Add WRITE_ONCE() to rcu_node ->boost_tasks
The rcu_node structure's ->boost_tasks 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. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent b68c614 commit 5822b81

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/rcu/tree_plugin.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ rcu_preempt_deferred_qs_irqrestore(struct task_struct *t, unsigned long flags)
505505
/* Snapshot ->boost_mtx ownership w/rnp->lock held. */
506506
drop_boost_mutex = rt_mutex_owner(&rnp->boost_mtx) == t;
507507
if (&t->rcu_node_entry == rnp->boost_tasks)
508-
rnp->boost_tasks = np;
508+
WRITE_ONCE(rnp->boost_tasks, np);
509509
}
510510

511511
/*
@@ -1082,7 +1082,7 @@ static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags)
10821082
rnp->qsmask == 0 &&
10831083
(ULONG_CMP_GE(jiffies, rnp->boost_time) || rcu_state.cbovld))) {
10841084
if (rnp->exp_tasks == NULL)
1085-
rnp->boost_tasks = rnp->gp_tasks;
1085+
WRITE_ONCE(rnp->boost_tasks, rnp->gp_tasks);
10861086
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
10871087
rcu_wake_cond(rnp->boost_kthread_task,
10881088
READ_ONCE(rnp->boost_kthread_status));

0 commit comments

Comments
 (0)