[tip: core/rcu] rcu: Add READ_ONCE() to rcu_segcblist ->tails[]
From: tip-bot2 for Paul E. McKenney
Date: Tue Mar 24 2020 - 05:18:11 EST
The following commit has been merged into the core/rcu branch of tip:
Commit-ID: bfeebe24212d374f82bbf5b005371fe13acabb93
Gitweb: https://git.kernel.org/tip/bfeebe24212d374f82bbf5b005371fe13acabb93
Author: Paul E. McKenney <paulmck@xxxxxxxxxx>
AuthorDate: Fri, 03 Jan 2020 16:14:08 -08:00
Committer: Paul E. McKenney <paulmck@xxxxxxxxxx>
CommitterDate: Thu, 20 Feb 2020 15:58:22 -08:00
rcu: Add READ_ONCE() to rcu_segcblist ->tails[]
The rcu_segcblist structure's ->tails[] array entries are read
locklessly, so this commit adds the READ_ONCE() to a load in order to
avoid destructive compiler optimizations.
This data race was reported by KCSAN.
Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxx>
---
kernel/rcu/rcu_segcblist.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/rcu/rcu_segcblist.c b/kernel/rcu/rcu_segcblist.c
index 5f4fd3b..426a472 100644
--- a/kernel/rcu/rcu_segcblist.c
+++ b/kernel/rcu/rcu_segcblist.c
@@ -182,7 +182,7 @@ void rcu_segcblist_offload(struct rcu_segcblist *rsclp)
bool rcu_segcblist_ready_cbs(struct rcu_segcblist *rsclp)
{
return rcu_segcblist_is_enabled(rsclp) &&
- &rsclp->head != rsclp->tails[RCU_DONE_TAIL];
+ &rsclp->head != READ_ONCE(rsclp->tails[RCU_DONE_TAIL]);
}
/*