Skip to content

Commit f042a43

Browse files
committed
rcutorture: Add READ_ONCE() to rcu_torture_count and rcu_torture_batch
The rcutorture rcu_torture_count and rcu_torture_batch per-CPU variables are read locklessly, so this commit adds the READ_ONCE() to a load in order to avoid various types of compiler vandalism^Woptimization. This data race was reported by KCSAN. Not appropriate for backporting due to failure being unlikely and due to this being rcutorture. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 102c14d commit f042a43

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/rcu/rcutorture.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,8 +1413,8 @@ rcu_torture_stats_print(void)
14131413

14141414
for_each_possible_cpu(cpu) {
14151415
for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
1416-
pipesummary[i] += per_cpu(rcu_torture_count, cpu)[i];
1417-
batchsummary[i] += per_cpu(rcu_torture_batch, cpu)[i];
1416+
pipesummary[i] += READ_ONCE(per_cpu(rcu_torture_count, cpu)[i]);
1417+
batchsummary[i] += READ_ONCE(per_cpu(rcu_torture_batch, cpu)[i]);
14181418
}
14191419
}
14201420
for (i = RCU_TORTURE_PIPE_LEN - 1; i >= 0; i--) {

0 commit comments

Comments
 (0)