Skip to content

Commit a5b8950

Browse files
committed
rcu: Add READ_ONCE() to rcu_data ->gpwrap
The rcu_data structure's ->gpwrap field is read locklessly, and so this commit adds the required READ_ONCE() to a pair of laods in order to avoid destructive compiler optimizations. This data race was reported by KCSAN. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 65bb0dc commit a5b8950

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

kernel/rcu/tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ static void rcu_accelerate_cbs_unlocked(struct rcu_node *rnp,
13221322

13231323
rcu_lockdep_assert_cblist_protected(rdp);
13241324
c = rcu_seq_snap(&rcu_state.gp_seq);
1325-
if (!rdp->gpwrap && ULONG_CMP_GE(rdp->gp_seq_needed, c)) {
1325+
if (!READ_ONCE(rdp->gpwrap) && ULONG_CMP_GE(rdp->gp_seq_needed, c)) {
13261326
/* Old request still live, so mark recent callbacks. */
13271327
(void)rcu_segcblist_accelerate(&rdp->cblist, c);
13281328
return;

kernel/rcu/tree_stall.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ void show_rcu_gp_kthreads(void)
602602
continue;
603603
for_each_leaf_node_possible_cpu(rnp, cpu) {
604604
rdp = per_cpu_ptr(&rcu_data, cpu);
605-
if (rdp->gpwrap ||
605+
if (READ_ONCE(rdp->gpwrap) ||
606606
ULONG_CMP_GE(READ_ONCE(rcu_state.gp_seq),
607607
READ_ONCE(rdp->gp_seq_needed)))
608608
continue;

0 commit comments

Comments
 (0)