1 // SPDX-License-Identifier: GPL-2.0+
3 * RCU CPU stall warnings for normal RCU grace periods
5 * Copyright IBM Corporation, 2019
7 * Author: Paul E. McKenney <paulmck@linux.ibm.com>
10 //////////////////////////////////////////////////////////////////////////////
12 // Controlling CPU stall warnings, including delay calculation.
14 /* panic() on RCU Stall sysctl. */
15 int sysctl_panic_on_rcu_stall __read_mostly
;
17 #ifdef CONFIG_PROVE_RCU
18 #define RCU_STALL_DELAY_DELTA (5 * HZ)
20 #define RCU_STALL_DELAY_DELTA 0
23 /* Limit-check stall timeouts specified at boottime and runtime. */
24 int rcu_jiffies_till_stall_check(void)
26 int till_stall_check
= READ_ONCE(rcu_cpu_stall_timeout
);
29 * Limit check must be consistent with the Kconfig limits
30 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
32 if (till_stall_check
< 3) {
33 WRITE_ONCE(rcu_cpu_stall_timeout
, 3);
35 } else if (till_stall_check
> 300) {
36 WRITE_ONCE(rcu_cpu_stall_timeout
, 300);
37 till_stall_check
= 300;
39 return till_stall_check
* HZ
+ RCU_STALL_DELAY_DELTA
;
41 EXPORT_SYMBOL_GPL(rcu_jiffies_till_stall_check
);
43 /* Don't do RCU CPU stall warnings during long sysrq printouts. */
44 void rcu_sysrq_start(void)
46 if (!rcu_cpu_stall_suppress
)
47 rcu_cpu_stall_suppress
= 2;
50 void rcu_sysrq_end(void)
52 if (rcu_cpu_stall_suppress
== 2)
53 rcu_cpu_stall_suppress
= 0;
56 /* Don't print RCU CPU stall warnings during a kernel panic. */
57 static int rcu_panic(struct notifier_block
*this, unsigned long ev
, void *ptr
)
59 rcu_cpu_stall_suppress
= 1;
63 static struct notifier_block rcu_panic_block
= {
64 .notifier_call
= rcu_panic
,
67 static int __init
check_cpu_stall_init(void)
69 atomic_notifier_chain_register(&panic_notifier_list
, &rcu_panic_block
);
72 early_initcall(check_cpu_stall_init
);
74 /* If so specified via sysctl, panic, yielding cleaner stall-warning output. */
75 static void panic_on_rcu_stall(void)
77 if (sysctl_panic_on_rcu_stall
)
82 * rcu_cpu_stall_reset - prevent further stall warnings in current grace period
84 * Set the stall-warning timeout way off into the future, thus preventing
85 * any RCU CPU stall-warning messages from appearing in the current set of
88 * The caller must disable hard irqs.
90 void rcu_cpu_stall_reset(void)
92 WRITE_ONCE(rcu_state
.jiffies_stall
, jiffies
+ ULONG_MAX
/ 2);
95 //////////////////////////////////////////////////////////////////////////////
97 // Interaction with RCU grace periods
99 /* Start of new grace period, so record stall time (and forcing times). */
100 static void record_gp_stall_check_time(void)
102 unsigned long j
= jiffies
;
105 rcu_state
.gp_start
= j
;
106 j1
= rcu_jiffies_till_stall_check();
107 /* Record ->gp_start before ->jiffies_stall. */
108 smp_store_release(&rcu_state
.jiffies_stall
, j
+ j1
); /* ^^^ */
109 rcu_state
.jiffies_resched
= j
+ j1
/ 2;
110 rcu_state
.n_force_qs_gpstart
= READ_ONCE(rcu_state
.n_force_qs
);
113 /* Zero ->ticks_this_gp and snapshot the number of RCU softirq handlers. */
114 static void zero_cpu_stall_ticks(struct rcu_data
*rdp
)
116 rdp
->ticks_this_gp
= 0;
117 rdp
->softirq_snap
= kstat_softirqs_cpu(RCU_SOFTIRQ
, smp_processor_id());
118 WRITE_ONCE(rdp
->last_fqs_resched
, jiffies
);
122 * If too much time has passed in the current grace period, and if
123 * so configured, go kick the relevant kthreads.
125 static void rcu_stall_kick_kthreads(void)
129 if (!rcu_kick_kthreads
)
131 j
= READ_ONCE(rcu_state
.jiffies_kick_kthreads
);
132 if (time_after(jiffies
, j
) && rcu_state
.gp_kthread
&&
133 (rcu_gp_in_progress() || READ_ONCE(rcu_state
.gp_flags
))) {
134 WARN_ONCE(1, "Kicking %s grace-period kthread\n",
136 rcu_ftrace_dump(DUMP_ALL
);
137 wake_up_process(rcu_state
.gp_kthread
);
138 WRITE_ONCE(rcu_state
.jiffies_kick_kthreads
, j
+ HZ
);
143 * Handler for the irq_work request posted about halfway into the RCU CPU
144 * stall timeout, and used to detect excessive irq disabling. Set state
145 * appropriately, but just complain if there is unexpected state on entry.
147 static void rcu_iw_handler(struct irq_work
*iwp
)
149 struct rcu_data
*rdp
;
150 struct rcu_node
*rnp
;
152 rdp
= container_of(iwp
, struct rcu_data
, rcu_iw
);
154 raw_spin_lock_rcu_node(rnp
);
155 if (!WARN_ON_ONCE(!rdp
->rcu_iw_pending
)) {
156 rdp
->rcu_iw_gp_seq
= rnp
->gp_seq
;
157 rdp
->rcu_iw_pending
= false;
159 raw_spin_unlock_rcu_node(rnp
);
162 //////////////////////////////////////////////////////////////////////////////
164 // Printing RCU CPU stall warnings
166 #ifdef CONFIG_PREEMPTION
169 * Dump detailed information for all tasks blocking the current RCU
170 * grace period on the specified rcu_node structure.
172 static void rcu_print_detail_task_stall_rnp(struct rcu_node
*rnp
)
175 struct task_struct
*t
;
177 raw_spin_lock_irqsave_rcu_node(rnp
, flags
);
178 if (!rcu_preempt_blocked_readers_cgp(rnp
)) {
179 raw_spin_unlock_irqrestore_rcu_node(rnp
, flags
);
182 t
= list_entry(rnp
->gp_tasks
->prev
,
183 struct task_struct
, rcu_node_entry
);
184 list_for_each_entry_continue(t
, &rnp
->blkd_tasks
, rcu_node_entry
) {
186 * We could be printing a lot while holding a spinlock.
187 * Avoid triggering hard lockup.
189 touch_nmi_watchdog();
192 raw_spin_unlock_irqrestore_rcu_node(rnp
, flags
);
196 * Scan the current list of tasks blocked within RCU read-side critical
197 * sections, printing out the tid of each.
199 static int rcu_print_task_stall(struct rcu_node
*rnp
)
201 struct task_struct
*t
;
204 if (!rcu_preempt_blocked_readers_cgp(rnp
))
206 pr_err("\tTasks blocked on level-%d rcu_node (CPUs %d-%d):",
207 rnp
->level
, rnp
->grplo
, rnp
->grphi
);
208 t
= list_entry(rnp
->gp_tasks
->prev
,
209 struct task_struct
, rcu_node_entry
);
210 list_for_each_entry_continue(t
, &rnp
->blkd_tasks
, rcu_node_entry
) {
211 pr_cont(" P%d", t
->pid
);
218 #else /* #ifdef CONFIG_PREEMPTION */
221 * Because preemptible RCU does not exist, we never have to check for
222 * tasks blocked within RCU read-side critical sections.
224 static void rcu_print_detail_task_stall_rnp(struct rcu_node
*rnp
)
229 * Because preemptible RCU does not exist, we never have to check for
230 * tasks blocked within RCU read-side critical sections.
232 static int rcu_print_task_stall(struct rcu_node
*rnp
)
236 #endif /* #else #ifdef CONFIG_PREEMPTION */
239 * Dump stacks of all tasks running on stalled CPUs. First try using
240 * NMIs, but fall back to manual remote stack tracing on architectures
241 * that don't support NMI-based stack dumps. The NMI-triggered stack
242 * traces are more accurate because they are printed by the target CPU.
244 static void rcu_dump_cpu_stacks(void)
248 struct rcu_node
*rnp
;
250 rcu_for_each_leaf_node(rnp
) {
251 raw_spin_lock_irqsave_rcu_node(rnp
, flags
);
252 for_each_leaf_node_possible_cpu(rnp
, cpu
)
253 if (rnp
->qsmask
& leaf_node_cpu_bit(rnp
, cpu
))
254 if (!trigger_single_cpu_backtrace(cpu
))
256 raw_spin_unlock_irqrestore_rcu_node(rnp
, flags
);
260 #ifdef CONFIG_RCU_FAST_NO_HZ
262 static void print_cpu_stall_fast_no_hz(char *cp
, int cpu
)
264 struct rcu_data
*rdp
= &per_cpu(rcu_data
, cpu
);
266 sprintf(cp
, "last_accelerate: %04lx/%04lx, Nonlazy posted: %c%c%c",
267 rdp
->last_accelerate
& 0xffff, jiffies
& 0xffff,
269 ".L"[!rcu_segcblist_n_nonlazy_cbs(&rdp
->cblist
)],
270 ".D"[!!rdp
->tick_nohz_enabled_snap
]);
273 #else /* #ifdef CONFIG_RCU_FAST_NO_HZ */
275 static void print_cpu_stall_fast_no_hz(char *cp
, int cpu
)
280 #endif /* #else #ifdef CONFIG_RCU_FAST_NO_HZ */
282 static const char * const gp_state_names
[] = {
283 [RCU_GP_IDLE
] = "RCU_GP_IDLE",
284 [RCU_GP_WAIT_GPS
] = "RCU_GP_WAIT_GPS",
285 [RCU_GP_DONE_GPS
] = "RCU_GP_DONE_GPS",
286 [RCU_GP_ONOFF
] = "RCU_GP_ONOFF",
287 [RCU_GP_INIT
] = "RCU_GP_INIT",
288 [RCU_GP_WAIT_FQS
] = "RCU_GP_WAIT_FQS",
289 [RCU_GP_DOING_FQS
] = "RCU_GP_DOING_FQS",
290 [RCU_GP_CLEANUP
] = "RCU_GP_CLEANUP",
291 [RCU_GP_CLEANED
] = "RCU_GP_CLEANED",
295 * Convert a ->gp_state value to a character string.
297 static const char *gp_state_getname(short gs
)
299 if (gs
< 0 || gs
>= ARRAY_SIZE(gp_state_names
))
301 return gp_state_names
[gs
];
305 * Print out diagnostic information for the specified stalled CPU.
307 * If the specified CPU is aware of the current RCU grace period, then
308 * print the number of scheduling clock interrupts the CPU has taken
309 * during the time that it has been aware. Otherwise, print the number
310 * of RCU grace periods that this CPU is ignorant of, for example, "1"
311 * if the CPU was aware of the previous grace period.
313 * Also print out idle and (if CONFIG_RCU_FAST_NO_HZ) idle-entry info.
315 static void print_cpu_stall_info(int cpu
)
319 struct rcu_data
*rdp
= per_cpu_ptr(&rcu_data
, cpu
);
321 unsigned long ticks_value
;
324 * We could be printing a lot while holding a spinlock. Avoid
325 * triggering hard lockup.
327 touch_nmi_watchdog();
329 ticks_value
= rcu_seq_ctr(rcu_state
.gp_seq
- rdp
->gp_seq
);
331 ticks_title
= "GPs behind";
333 ticks_title
= "ticks this GP";
334 ticks_value
= rdp
->ticks_this_gp
;
336 print_cpu_stall_fast_no_hz(fast_no_hz
, cpu
);
337 delta
= rcu_seq_ctr(rdp
->mynode
->gp_seq
- rdp
->rcu_iw_gp_seq
);
338 pr_err("\t%d-%c%c%c%c: (%lu %s) idle=%03x/%ld/%#lx softirq=%u/%u fqs=%ld %s\n",
340 "O."[!!cpu_online(cpu
)],
341 "o."[!!(rdp
->grpmask
& rdp
->mynode
->qsmaskinit
)],
342 "N."[!!(rdp
->grpmask
& rdp
->mynode
->qsmaskinitnext
)],
343 !IS_ENABLED(CONFIG_IRQ_WORK
) ? '?' :
344 rdp
->rcu_iw_pending
? (int)min(delta
, 9UL) + '0' :
346 ticks_value
, ticks_title
,
347 rcu_dynticks_snap(rdp
) & 0xfff,
348 rdp
->dynticks_nesting
, rdp
->dynticks_nmi_nesting
,
349 rdp
->softirq_snap
, kstat_softirqs_cpu(RCU_SOFTIRQ
, cpu
),
350 READ_ONCE(rcu_state
.n_force_qs
) - rcu_state
.n_force_qs_gpstart
,
354 /* Complain about starvation of grace-period kthread. */
355 static void rcu_check_gp_kthread_starvation(void)
357 struct task_struct
*gpk
= rcu_state
.gp_kthread
;
360 j
= jiffies
- READ_ONCE(rcu_state
.gp_activity
);
362 pr_err("%s kthread starved for %ld jiffies! g%ld f%#x %s(%d) ->state=%#lx ->cpu=%d\n",
364 (long)rcu_seq_current(&rcu_state
.gp_seq
),
365 READ_ONCE(rcu_state
.gp_flags
),
366 gp_state_getname(rcu_state
.gp_state
), rcu_state
.gp_state
,
367 gpk
? gpk
->state
: ~0, gpk
? task_cpu(gpk
) : -1);
369 pr_err("RCU grace-period kthread stack dump:\n");
370 sched_show_task(gpk
);
371 wake_up_process(gpk
);
376 static void print_other_cpu_stall(unsigned long gp_seq
)
383 struct rcu_node
*rnp
;
386 /* Kick and suppress, if so configured. */
387 rcu_stall_kick_kthreads();
388 if (rcu_cpu_stall_suppress
)
392 * OK, time to rat on our buddy...
393 * See Documentation/RCU/stallwarn.txt for info on how to debug
394 * RCU CPU stall warnings.
396 pr_err("INFO: %s detected stalls on CPUs/tasks:\n", rcu_state
.name
);
397 rcu_for_each_leaf_node(rnp
) {
398 raw_spin_lock_irqsave_rcu_node(rnp
, flags
);
399 ndetected
+= rcu_print_task_stall(rnp
);
400 if (rnp
->qsmask
!= 0) {
401 for_each_leaf_node_possible_cpu(rnp
, cpu
)
402 if (rnp
->qsmask
& leaf_node_cpu_bit(rnp
, cpu
)) {
403 print_cpu_stall_info(cpu
);
407 raw_spin_unlock_irqrestore_rcu_node(rnp
, flags
);
410 for_each_possible_cpu(cpu
)
411 totqlen
+= rcu_get_n_cbs_cpu(cpu
);
412 pr_cont("\t(detected by %d, t=%ld jiffies, g=%ld, q=%lu)\n",
413 smp_processor_id(), (long)(jiffies
- rcu_state
.gp_start
),
414 (long)rcu_seq_current(&rcu_state
.gp_seq
), totqlen
);
416 rcu_dump_cpu_stacks();
418 /* Complain about tasks blocking the grace period. */
419 rcu_for_each_leaf_node(rnp
)
420 rcu_print_detail_task_stall_rnp(rnp
);
422 if (rcu_seq_current(&rcu_state
.gp_seq
) != gp_seq
) {
423 pr_err("INFO: Stall ended before state dump start\n");
426 gpa
= READ_ONCE(rcu_state
.gp_activity
);
427 pr_err("All QSes seen, last %s kthread activity %ld (%ld-%ld), jiffies_till_next_fqs=%ld, root ->qsmask %#lx\n",
428 rcu_state
.name
, j
- gpa
, j
, gpa
,
429 READ_ONCE(jiffies_till_next_fqs
),
430 rcu_get_root()->qsmask
);
431 /* In this case, the current CPU might be at fault. */
432 sched_show_task(current
);
435 /* Rewrite if needed in case of slow consoles. */
436 if (ULONG_CMP_GE(jiffies
, READ_ONCE(rcu_state
.jiffies_stall
)))
437 WRITE_ONCE(rcu_state
.jiffies_stall
,
438 jiffies
+ 3 * rcu_jiffies_till_stall_check() + 3);
440 rcu_check_gp_kthread_starvation();
442 panic_on_rcu_stall();
444 rcu_force_quiescent_state(); /* Kick them all. */
447 static void print_cpu_stall(void)
451 struct rcu_data
*rdp
= this_cpu_ptr(&rcu_data
);
452 struct rcu_node
*rnp
= rcu_get_root();
455 /* Kick and suppress, if so configured. */
456 rcu_stall_kick_kthreads();
457 if (rcu_cpu_stall_suppress
)
461 * OK, time to rat on ourselves...
462 * See Documentation/RCU/stallwarn.txt for info on how to debug
463 * RCU CPU stall warnings.
465 pr_err("INFO: %s self-detected stall on CPU\n", rcu_state
.name
);
466 raw_spin_lock_irqsave_rcu_node(rdp
->mynode
, flags
);
467 print_cpu_stall_info(smp_processor_id());
468 raw_spin_unlock_irqrestore_rcu_node(rdp
->mynode
, flags
);
469 for_each_possible_cpu(cpu
)
470 totqlen
+= rcu_get_n_cbs_cpu(cpu
);
471 pr_cont("\t(t=%lu jiffies g=%ld q=%lu)\n",
472 jiffies
- rcu_state
.gp_start
,
473 (long)rcu_seq_current(&rcu_state
.gp_seq
), totqlen
);
475 rcu_check_gp_kthread_starvation();
477 rcu_dump_cpu_stacks();
479 raw_spin_lock_irqsave_rcu_node(rnp
, flags
);
480 /* Rewrite if needed in case of slow consoles. */
481 if (ULONG_CMP_GE(jiffies
, READ_ONCE(rcu_state
.jiffies_stall
)))
482 WRITE_ONCE(rcu_state
.jiffies_stall
,
483 jiffies
+ 3 * rcu_jiffies_till_stall_check() + 3);
484 raw_spin_unlock_irqrestore_rcu_node(rnp
, flags
);
486 panic_on_rcu_stall();
489 * Attempt to revive the RCU machinery by forcing a context switch.
491 * A context switch would normally allow the RCU state machine to make
492 * progress and it could be we're stuck in kernel space without context
493 * switches for an entirely unreasonable amount of time.
495 set_tsk_need_resched(current
);
496 set_preempt_need_resched();
499 static void check_cpu_stall(struct rcu_data
*rdp
)
507 struct rcu_node
*rnp
;
509 if ((rcu_cpu_stall_suppress
&& !rcu_kick_kthreads
) ||
510 !rcu_gp_in_progress())
512 rcu_stall_kick_kthreads();
516 * Lots of memory barriers to reject false positives.
518 * The idea is to pick up rcu_state.gp_seq, then
519 * rcu_state.jiffies_stall, then rcu_state.gp_start, and finally
520 * another copy of rcu_state.gp_seq. These values are updated in
521 * the opposite order with memory barriers (or equivalent) during
522 * grace-period initialization and cleanup. Now, a false positive
523 * can occur if we get an new value of rcu_state.gp_start and a old
524 * value of rcu_state.jiffies_stall. But given the memory barriers,
525 * the only way that this can happen is if one grace period ends
526 * and another starts between these two fetches. This is detected
527 * by comparing the second fetch of rcu_state.gp_seq with the
528 * previous fetch from rcu_state.gp_seq.
530 * Given this check, comparisons of jiffies, rcu_state.jiffies_stall,
531 * and rcu_state.gp_start suffice to forestall false positives.
533 gs1
= READ_ONCE(rcu_state
.gp_seq
);
534 smp_rmb(); /* Pick up ->gp_seq first... */
535 js
= READ_ONCE(rcu_state
.jiffies_stall
);
536 smp_rmb(); /* ...then ->jiffies_stall before the rest... */
537 gps
= READ_ONCE(rcu_state
.gp_start
);
538 smp_rmb(); /* ...and finally ->gp_start before ->gp_seq again. */
539 gs2
= READ_ONCE(rcu_state
.gp_seq
);
541 ULONG_CMP_LT(j
, js
) ||
542 ULONG_CMP_GE(gps
, js
))
543 return; /* No stall or GP completed since entering function. */
545 jn
= jiffies
+ 3 * rcu_jiffies_till_stall_check() + 3;
546 if (rcu_gp_in_progress() &&
547 (READ_ONCE(rnp
->qsmask
) & rdp
->grpmask
) &&
548 cmpxchg(&rcu_state
.jiffies_stall
, js
, jn
) == js
) {
550 /* We haven't checked in, so go dump stack. */
552 if (rcu_cpu_stall_ftrace_dump
)
553 rcu_ftrace_dump(DUMP_ALL
);
555 } else if (rcu_gp_in_progress() &&
556 ULONG_CMP_GE(j
, js
+ RCU_STALL_RAT_DELAY
) &&
557 cmpxchg(&rcu_state
.jiffies_stall
, js
, jn
) == js
) {
559 /* They had a few time units to dump stack, so complain. */
560 print_other_cpu_stall(gs2
);
561 if (rcu_cpu_stall_ftrace_dump
)
562 rcu_ftrace_dump(DUMP_ALL
);
566 //////////////////////////////////////////////////////////////////////////////
568 // RCU forward-progress mechanisms, including of callback invocation.
572 * Show the state of the grace-period kthreads.
574 void show_rcu_gp_kthreads(void)
581 struct rcu_data
*rdp
;
582 struct rcu_node
*rnp
;
585 ja
= j
- READ_ONCE(rcu_state
.gp_activity
);
586 jr
= j
- READ_ONCE(rcu_state
.gp_req_activity
);
587 jw
= j
- READ_ONCE(rcu_state
.gp_wake_time
);
588 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",
589 rcu_state
.name
, gp_state_getname(rcu_state
.gp_state
),
591 rcu_state
.gp_kthread
? rcu_state
.gp_kthread
->state
: 0x1ffffL
,
592 ja
, jr
, jw
, (long)READ_ONCE(rcu_state
.gp_wake_seq
),
593 (long)READ_ONCE(rcu_state
.gp_seq
),
594 (long)READ_ONCE(rcu_get_root()->gp_seq_needed
),
595 READ_ONCE(rcu_state
.gp_flags
));
596 rcu_for_each_node_breadth_first(rnp
) {
597 if (ULONG_CMP_GE(rcu_state
.gp_seq
, rnp
->gp_seq_needed
))
599 pr_info("\trcu_node %d:%d ->gp_seq %ld ->gp_seq_needed %ld\n",
600 rnp
->grplo
, rnp
->grphi
, (long)rnp
->gp_seq
,
601 (long)rnp
->gp_seq_needed
);
602 if (!rcu_is_leaf_node(rnp
))
604 for_each_leaf_node_possible_cpu(rnp
, cpu
) {
605 rdp
= per_cpu_ptr(&rcu_data
, cpu
);
607 ULONG_CMP_GE(rcu_state
.gp_seq
,
610 pr_info("\tcpu %d ->gp_seq_needed %ld\n",
611 cpu
, (long)rdp
->gp_seq_needed
);
614 for_each_possible_cpu(cpu
) {
615 rdp
= per_cpu_ptr(&rcu_data
, cpu
);
616 if (rcu_segcblist_is_offloaded(&rdp
->cblist
))
617 show_rcu_nocb_state(rdp
);
619 /* sched_show_task(rcu_state.gp_kthread); */
621 EXPORT_SYMBOL_GPL(show_rcu_gp_kthreads
);
624 * This function checks for grace-period requests that fail to motivate
625 * RCU to come out of its idle mode.
627 static void rcu_check_gp_start_stall(struct rcu_node
*rnp
, struct rcu_data
*rdp
,
628 const unsigned long gpssdelay
)
632 struct rcu_node
*rnp_root
= rcu_get_root();
633 static atomic_t warned
= ATOMIC_INIT(0);
635 if (!IS_ENABLED(CONFIG_PROVE_RCU
) || rcu_gp_in_progress() ||
636 ULONG_CMP_GE(rnp_root
->gp_seq
, rnp_root
->gp_seq_needed
))
638 j
= jiffies
; /* Expensive access, and in common case don't get here. */
639 if (time_before(j
, READ_ONCE(rcu_state
.gp_req_activity
) + gpssdelay
) ||
640 time_before(j
, READ_ONCE(rcu_state
.gp_activity
) + gpssdelay
) ||
641 atomic_read(&warned
))
644 raw_spin_lock_irqsave_rcu_node(rnp
, flags
);
646 if (rcu_gp_in_progress() ||
647 ULONG_CMP_GE(rnp_root
->gp_seq
, rnp_root
->gp_seq_needed
) ||
648 time_before(j
, READ_ONCE(rcu_state
.gp_req_activity
) + gpssdelay
) ||
649 time_before(j
, READ_ONCE(rcu_state
.gp_activity
) + gpssdelay
) ||
650 atomic_read(&warned
)) {
651 raw_spin_unlock_irqrestore_rcu_node(rnp
, flags
);
654 /* Hold onto the leaf lock to make others see warned==1. */
657 raw_spin_lock_rcu_node(rnp_root
); /* irqs already disabled. */
659 if (rcu_gp_in_progress() ||
660 ULONG_CMP_GE(rnp_root
->gp_seq
, rnp_root
->gp_seq_needed
) ||
661 time_before(j
, rcu_state
.gp_req_activity
+ gpssdelay
) ||
662 time_before(j
, rcu_state
.gp_activity
+ gpssdelay
) ||
663 atomic_xchg(&warned
, 1)) {
665 /* irqs remain disabled. */
666 raw_spin_unlock_rcu_node(rnp_root
);
667 raw_spin_unlock_irqrestore_rcu_node(rnp
, flags
);
672 raw_spin_unlock_rcu_node(rnp_root
);
673 raw_spin_unlock_irqrestore_rcu_node(rnp
, flags
);
674 show_rcu_gp_kthreads();
678 * Do a forward-progress check for rcutorture. This is normally invoked
679 * due to an OOM event. The argument "j" gives the time period during
680 * which rcutorture would like progress to have been made.
682 void rcu_fwd_progress_check(unsigned long j
)
686 unsigned long max_cbs
= 0;
688 struct rcu_data
*rdp
;
690 if (rcu_gp_in_progress()) {
691 pr_info("%s: GP age %lu jiffies\n",
692 __func__
, jiffies
- rcu_state
.gp_start
);
693 show_rcu_gp_kthreads();
695 pr_info("%s: Last GP end %lu jiffies ago\n",
696 __func__
, jiffies
- rcu_state
.gp_end
);
698 rdp
= this_cpu_ptr(&rcu_data
);
699 rcu_check_gp_start_stall(rdp
->mynode
, rdp
, j
);
702 for_each_possible_cpu(cpu
) {
703 cbs
= rcu_get_n_cbs_cpu(cpu
);
707 pr_info("%s: callbacks", __func__
);
708 pr_cont(" %d: %lu", cpu
, cbs
);
717 EXPORT_SYMBOL_GPL(rcu_fwd_progress_check
);
719 /* Commandeer a sysrq key to dump RCU's tree. */
720 static bool sysrq_rcu
;
721 module_param(sysrq_rcu
, bool, 0444);
723 /* Dump grace-period-request information due to commandeered sysrq. */
724 static void sysrq_show_rcu(int key
)
726 show_rcu_gp_kthreads();
729 static struct sysrq_key_op sysrq_rcudump_op
= {
730 .handler
= sysrq_show_rcu
,
731 .help_msg
= "show-rcu(y)",
732 .action_msg
= "Show RCU tree",
733 .enable_mask
= SYSRQ_ENABLE_DUMP
,
736 static int __init
rcu_sysrq_init(void)
739 return register_sysrq_key('y', &sysrq_rcudump_op
);
742 early_initcall(rcu_sysrq_init
);