Skip to content

Commit b68c614

Browse files
committed
srcu: Add data_race() to ->srcu_lock_count and ->srcu_unlock_count arrays
The srcu_data structure's ->srcu_lock_count and ->srcu_unlock_count arrays are read and written locklessly, so this commit adds the data_race() to the diagnostic-print loads from these arrays in order mark them as known and approved data-racy accesses. This data race was reported by KCSAN. Not appropriate for backporting due to failure being unlikely and due to this being used only by rcutorture. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 065a6db commit b68c614

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

kernel/rcu/srcutree.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,17 +1281,17 @@ void srcu_torture_stats_print(struct srcu_struct *ssp, char *tt, char *tf)
12811281
struct srcu_data *sdp;
12821282

12831283
sdp = per_cpu_ptr(ssp->sda, cpu);
1284-
u0 = sdp->srcu_unlock_count[!idx];
1285-
u1 = sdp->srcu_unlock_count[idx];
1284+
u0 = data_race(sdp->srcu_unlock_count[!idx]);
1285+
u1 = data_race(sdp->srcu_unlock_count[idx]);
12861286

12871287
/*
12881288
* Make sure that a lock is always counted if the corresponding
12891289
* unlock is counted.
12901290
*/
12911291
smp_rmb();
12921292

1293-
l0 = sdp->srcu_lock_count[!idx];
1294-
l1 = sdp->srcu_lock_count[idx];
1293+
l0 = data_race(sdp->srcu_lock_count[!idx]);
1294+
l1 = data_race(sdp->srcu_lock_count[idx]);
12951295

12961296
c0 = l0 - u0;
12971297
c1 = l1 - u1;

0 commit comments

Comments
 (0)