1 Using RCU's CPU Stall Detector
3 The CONFIG_RCU_CPU_STALL_DETECTOR kernel config parameter enables
4 RCU's CPU stall detector, which detects conditions that unduly delay
5 RCU grace periods. The stall detector's idea of what constitutes
6 "unduly delayed" is controlled by a set of C preprocessor macros:
8 RCU_SECONDS_TILL_STALL_CHECK
10 This macro defines the period of time that RCU will wait from
11 the beginning of a grace period until it issues an RCU CPU
12 stall warning. This time period is normally ten seconds.
14 RCU_SECONDS_TILL_STALL_RECHECK
16 This macro defines the period of time that RCU will wait after
17 issuing a stall warning until it issues another stall warning
18 for the same stall. This time period is normally set to thirty
23 The CPU stall detector tries to make the offending CPU print its
24 own warnings, as this often gives better-quality stack traces.
25 However, if the offending CPU does not detect its own stall in
26 the number of jiffies specified by RCU_STALL_RAT_DELAY, then
27 some other CPU will complain. This delay is normally set to
30 When a CPU detects that it is stalling, it will print a message similar
33 INFO: rcu_sched_state detected stall on CPU 5 (t=2500 jiffies)
35 This message indicates that CPU 5 detected that it was causing a stall,
36 and that the stall was affecting RCU-sched. This message will normally be
37 followed by a stack dump of the offending CPU. On TREE_RCU kernel builds,
38 RCU and RCU-sched are implemented by the same underlying mechanism,
39 while on TREE_PREEMPT_RCU kernel builds, RCU is instead implemented
42 On the other hand, if the offending CPU fails to print out a stall-warning
43 message quickly enough, some other CPU will print a message similar to
46 INFO: rcu_bh_state detected stalls on CPUs/tasks: { 3 5 } (detected by 2, 2502 jiffies)
48 This message indicates that CPU 2 detected that CPUs 3 and 5 were both
49 causing stalls, and that the stall was affecting RCU-bh. This message
50 will normally be followed by stack dumps for each CPU. Please note that
51 TREE_PREEMPT_RCU builds can be stalled by tasks as well as by CPUs,
52 and that the tasks will be indicated by PID, for example, "P3421".
53 It is even possible for a rcu_preempt_state stall to be caused by both
54 CPUs -and- tasks, in which case the offending CPUs and tasks will all
55 be called out in the list.
57 Finally, if the grace period ends just as the stall warning starts
58 printing, there will be a spurious stall-warning message:
60 INFO: rcu_bh_state detected stalls on CPUs/tasks: { } (detected by 4, 2502 jiffies)
62 This is rare, but does happen from time to time in real life.
64 So your kernel printed an RCU CPU stall warning. The next question is
65 "What caused it?" The following problems can result in RCU CPU stall
68 o A CPU looping in an RCU read-side critical section.
70 o A CPU looping with interrupts disabled. This condition can
71 result in RCU-sched and RCU-bh stalls.
73 o A CPU looping with preemption disabled. This condition can
74 result in RCU-sched stalls and, if ksoftirqd is in use, RCU-bh
77 o A CPU looping with bottom halves disabled. This condition can
78 result in RCU-sched and RCU-bh stalls.
80 o For !CONFIG_PREEMPT kernels, a CPU looping anywhere in the kernel
81 without invoking schedule().
83 o A bug in the RCU implementation.
85 o A hardware failure. This is quite unlikely, but has occurred
86 at least once in real life. A CPU failed in a running system,
87 becoming unresponsive, but not causing an immediate crash.
88 This resulted in a series of RCU CPU stall warnings, eventually
89 leading the realization that the CPU had failed.
91 The RCU, RCU-sched, and RCU-bh implementations have CPU stall
92 warning. SRCU does not have its own CPU stall warnings, but its
93 calls to synchronize_sched() will result in RCU-sched detecting
94 RCU-sched-related CPU stalls. Please note that RCU only detects
95 CPU stalls when there is a grace period in progress. No grace period,
96 no CPU stall warnings.
98 To diagnose the cause of the stall, inspect the stack traces.
99 The offending function will usually be near the top of the stack.
100 If you have a series of stall warnings from a single extended stall,
101 comparing the stack traces can often help determine where the stall
102 is occurring, which will usually be in the function nearest the top of
103 that portion of the stack which remains the same from trace to trace.
104 If you can reliably trigger the stall, ftrace can be quite helpful.
106 RCU bugs can often be debugged with the help of CONFIG_RCU_TRACE.