Skip to content

Commit 065a6db

Browse files
committed
rcu: Add READ_ONCE and data_race() to rcu_node ->boost_tasks
The rcu_node structure's ->boost_tasks field is read locklessly, so this commit adds the READ_ONCE() to one load in order to avoid destructive compiler optimizations. The other load is from a diagnostic print, so data_race() suffices. 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 314eeb4 commit 065a6db

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

kernel/rcu/tree_plugin.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ dump_blkd_tasks(struct rcu_node *rnp, int ncheck)
760760
pr_info("%s: %d:%d ->qsmask %#lx ->qsmaskinit %#lx ->qsmaskinitnext %#lx\n",
761761
__func__, rnp1->grplo, rnp1->grphi, rnp1->qsmask, rnp1->qsmaskinit, rnp1->qsmaskinitnext);
762762
pr_info("%s: ->gp_tasks %p ->boost_tasks %p ->exp_tasks %p\n",
763-
__func__, READ_ONCE(rnp->gp_tasks), rnp->boost_tasks,
763+
__func__, READ_ONCE(rnp->gp_tasks), data_race(rnp->boost_tasks),
764764
READ_ONCE(rnp->exp_tasks));
765765
pr_info("%s: ->blkd_tasks", __func__);
766766
i = 0;
@@ -1036,7 +1036,8 @@ static int rcu_boost_kthread(void *arg)
10361036
for (;;) {
10371037
WRITE_ONCE(rnp->boost_kthread_status, RCU_KTHREAD_WAITING);
10381038
trace_rcu_utilization(TPS("End boost kthread@rcu_wait"));
1039-
rcu_wait(rnp->boost_tasks || READ_ONCE(rnp->exp_tasks));
1039+
rcu_wait(READ_ONCE(rnp->boost_tasks) ||
1040+
READ_ONCE(rnp->exp_tasks));
10401041
trace_rcu_utilization(TPS("Start boost kthread@rcu_wait"));
10411042
WRITE_ONCE(rnp->boost_kthread_status, RCU_KTHREAD_RUNNING);
10421043
more2boost = rcu_boost(rnp);

0 commit comments

Comments
 (0)