Skip to content

Commit 5396d31

Browse files
committed
rcutorture: Annotation lockless accesses to rcu_torture_current
The rcutorture global variable rcu_torture_current is accessed locklessly, so it must use the RCU pointer load/store primitives. This commit therefore adds several that were missed. 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 f042a43 commit 5396d31

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

kernel/rcu/rcutorture.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,6 +1407,7 @@ rcu_torture_stats_print(void)
14071407
int i;
14081408
long pipesummary[RCU_TORTURE_PIPE_LEN + 1] = { 0 };
14091409
long batchsummary[RCU_TORTURE_PIPE_LEN + 1] = { 0 };
1410+
struct rcu_torture *rtcp;
14101411
static unsigned long rtcv_snap = ULONG_MAX;
14111412
static bool splatted;
14121413
struct task_struct *wtp;
@@ -1423,10 +1424,10 @@ rcu_torture_stats_print(void)
14231424
}
14241425

14251426
pr_alert("%s%s ", torture_type, TORTURE_FLAG);
1427+
rtcp = rcu_access_pointer(rcu_torture_current);
14261428
pr_cont("rtc: %p %s: %lu tfle: %d rta: %d rtaf: %d rtf: %d ",
1427-
rcu_torture_current,
1428-
rcu_torture_current && !rcu_stall_is_suppressed_at_boot()
1429-
? "ver" : "VER",
1429+
rtcp,
1430+
rtcp && !rcu_stall_is_suppressed_at_boot() ? "ver" : "VER",
14301431
rcu_torture_current_version,
14311432
list_empty(&rcu_torture_freelist),
14321433
atomic_read(&n_rcu_torture_alloc),
@@ -1482,7 +1483,8 @@ rcu_torture_stats_print(void)
14821483
if (cur_ops->stats)
14831484
cur_ops->stats();
14841485
if (rtcv_snap == rcu_torture_current_version &&
1485-
rcu_torture_current != NULL && !rcu_stall_is_suppressed()) {
1486+
rcu_access_pointer(rcu_torture_current) &&
1487+
!rcu_stall_is_suppressed()) {
14861488
int __maybe_unused flags = 0;
14871489
unsigned long __maybe_unused gp_seq = 0;
14881490

0 commit comments

Comments
 (0)