Skip to content

Commit 47fbb07

Browse files
committed
rcu: Use data_race() for RCU CPU stall-warning prints
Although the accesses used to determine whether or not a stall should be printed are an integral part of the concurrency algorithm governing use of the corresponding variables, the values that are simply printed are ancillary. As such, it is best to use data_race() for these accesses in order to provide the greatest latitude in the use of KCSAN for the other accesses that are an integral part of the algorithm. This commit therefore changes the relevant uses of READ_ONCE() to data_race(). Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 5822b81 commit 47fbb07

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

kernel/rcu/tree_stall.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ static void rcu_check_gp_kthread_starvation(void)
360360
pr_err("%s kthread starved for %ld jiffies! g%ld f%#x %s(%d) ->state=%#lx ->cpu=%d\n",
361361
rcu_state.name, j,
362362
(long)rcu_seq_current(&rcu_state.gp_seq),
363-
READ_ONCE(rcu_state.gp_flags),
363+
data_race(rcu_state.gp_flags),
364364
gp_state_getname(rcu_state.gp_state), rcu_state.gp_state,
365365
gpk ? gpk->state : ~0, gpk ? task_cpu(gpk) : -1);
366366
if (gpk) {
@@ -421,10 +421,10 @@ static void print_other_cpu_stall(unsigned long gp_seq)
421421
pr_err("INFO: Stall ended before state dump start\n");
422422
} else {
423423
j = jiffies;
424-
gpa = READ_ONCE(rcu_state.gp_activity);
424+
gpa = data_race(rcu_state.gp_activity);
425425
pr_err("All QSes seen, last %s kthread activity %ld (%ld-%ld), jiffies_till_next_fqs=%ld, root ->qsmask %#lx\n",
426426
rcu_state.name, j - gpa, j, gpa,
427-
READ_ONCE(jiffies_till_next_fqs),
427+
data_race(jiffies_till_next_fqs),
428428
rcu_get_root()->qsmask);
429429
/* In this case, the current CPU might be at fault. */
430430
sched_show_task(current);
@@ -581,23 +581,23 @@ void show_rcu_gp_kthreads(void)
581581
struct task_struct *t = READ_ONCE(rcu_state.gp_kthread);
582582

583583
j = jiffies;
584-
ja = j - READ_ONCE(rcu_state.gp_activity);
585-
jr = j - READ_ONCE(rcu_state.gp_req_activity);
586-
jw = j - READ_ONCE(rcu_state.gp_wake_time);
584+
ja = j - data_race(rcu_state.gp_activity);
585+
jr = j - data_race(rcu_state.gp_req_activity);
586+
jw = j - data_race(rcu_state.gp_wake_time);
587587
pr_info("%s: wait state: %s(%d) ->state: %#lx delta ->gp_activity %lu ->gp_req_activity %lu ->gp_wake_time %lu ->gp_wake_seq %ld ->gp_seq %ld ->gp_seq_needed %ld ->gp_flags %#x\n",
588588
rcu_state.name, gp_state_getname(rcu_state.gp_state),
589589
rcu_state.gp_state, t ? t->state : 0x1ffffL,
590-
ja, jr, jw, (long)READ_ONCE(rcu_state.gp_wake_seq),
591-
(long)READ_ONCE(rcu_state.gp_seq),
592-
(long)READ_ONCE(rcu_get_root()->gp_seq_needed),
593-
READ_ONCE(rcu_state.gp_flags));
590+
ja, jr, jw, (long)data_race(rcu_state.gp_wake_seq),
591+
(long)data_race(rcu_state.gp_seq),
592+
(long)data_race(rcu_get_root()->gp_seq_needed),
593+
data_race(rcu_state.gp_flags));
594594
rcu_for_each_node_breadth_first(rnp) {
595595
if (ULONG_CMP_GE(READ_ONCE(rcu_state.gp_seq),
596596
READ_ONCE(rnp->gp_seq_needed)))
597597
continue;
598598
pr_info("\trcu_node %d:%d ->gp_seq %ld ->gp_seq_needed %ld\n",
599-
rnp->grplo, rnp->grphi, (long)READ_ONCE(rnp->gp_seq),
600-
(long)READ_ONCE(rnp->gp_seq_needed));
599+
rnp->grplo, rnp->grphi, (long)data_race(rnp->gp_seq),
600+
(long)data_race(rnp->gp_seq_needed));
601601
if (!rcu_is_leaf_node(rnp))
602602
continue;
603603
for_each_leaf_node_possible_cpu(rnp, cpu) {
@@ -607,7 +607,7 @@ void show_rcu_gp_kthreads(void)
607607
READ_ONCE(rdp->gp_seq_needed)))
608608
continue;
609609
pr_info("\tcpu %d ->gp_seq_needed %ld\n",
610-
cpu, (long)READ_ONCE(rdp->gp_seq_needed));
610+
cpu, (long)data_race(rdp->gp_seq_needed));
611611
}
612612
}
613613
for_each_possible_cpu(cpu) {

0 commit comments

Comments
 (0)