Skip to content

Commit fcbcc0e

Browse files
zhangzl2013paulmckrcu
authored andcommitted
rcu: Fix the (t=0 jiffies) false positive
It is possible that an over-long grace period will end while the RCU CPU stall warning message is printing. In this case, the estimate of the offending grace period's duration can be erroneous due to refetching of rcu_state.gp_start, which will now be the time of the newly started grace period. Computation of this duration clearly needs to use the start time for the old over-long grace period, not the fresh new one. This commit avoids such errors by causing both print_other_cpu_stall() and print_cpu_stall() to reuse the value previously fetched by their caller. Signed-off-by: Zhaolong Zhang <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 1fca4d1 commit fcbcc0e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

kernel/rcu/tree_stall.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ static void rcu_check_gp_kthread_starvation(void)
371371
}
372372
}
373373

374-
static void print_other_cpu_stall(unsigned long gp_seq)
374+
static void print_other_cpu_stall(unsigned long gp_seq, unsigned long gps)
375375
{
376376
int cpu;
377377
unsigned long flags;
@@ -408,7 +408,7 @@ static void print_other_cpu_stall(unsigned long gp_seq)
408408
for_each_possible_cpu(cpu)
409409
totqlen += rcu_get_n_cbs_cpu(cpu);
410410
pr_cont("\t(detected by %d, t=%ld jiffies, g=%ld, q=%lu)\n",
411-
smp_processor_id(), (long)(jiffies - rcu_state.gp_start),
411+
smp_processor_id(), (long)(jiffies - gps),
412412
(long)rcu_seq_current(&rcu_state.gp_seq), totqlen);
413413
if (ndetected) {
414414
rcu_dump_cpu_stacks();
@@ -442,7 +442,7 @@ static void print_other_cpu_stall(unsigned long gp_seq)
442442
rcu_force_quiescent_state(); /* Kick them all. */
443443
}
444444

445-
static void print_cpu_stall(void)
445+
static void print_cpu_stall(unsigned long gps)
446446
{
447447
int cpu;
448448
unsigned long flags;
@@ -467,7 +467,7 @@ static void print_cpu_stall(void)
467467
for_each_possible_cpu(cpu)
468468
totqlen += rcu_get_n_cbs_cpu(cpu);
469469
pr_cont("\t(t=%lu jiffies g=%ld q=%lu)\n",
470-
jiffies - rcu_state.gp_start,
470+
jiffies - gps,
471471
(long)rcu_seq_current(&rcu_state.gp_seq), totqlen);
472472

473473
rcu_check_gp_kthread_starvation();
@@ -546,7 +546,7 @@ static void check_cpu_stall(struct rcu_data *rdp)
546546
cmpxchg(&rcu_state.jiffies_stall, js, jn) == js) {
547547

548548
/* We haven't checked in, so go dump stack. */
549-
print_cpu_stall();
549+
print_cpu_stall(gps);
550550
if (rcu_cpu_stall_ftrace_dump)
551551
rcu_ftrace_dump(DUMP_ALL);
552552

@@ -555,7 +555,7 @@ static void check_cpu_stall(struct rcu_data *rdp)
555555
cmpxchg(&rcu_state.jiffies_stall, js, jn) == js) {
556556

557557
/* They had a few time units to dump stack, so complain. */
558-
print_other_cpu_stall(gs2);
558+
print_other_cpu_stall(gs2, gps);
559559
if (rcu_cpu_stall_ftrace_dump)
560560
rcu_ftrace_dump(DUMP_ALL);
561561
}

0 commit comments

Comments
 (0)