Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0 |
| 2 | |
| 3 | ============================== |
Paul E. McKenney | 4c54005 | 2010-01-14 16:10:57 -0800 | [diff] [blame] | 4 | Using RCU's CPU Stall Detector |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 5 | ============================== |
Paul E. McKenney | 4c54005 | 2010-01-14 16:10:57 -0800 | [diff] [blame] | 6 | |
Paul E. McKenney | 8e2a439 | 2017-02-08 14:30:15 -0800 | [diff] [blame] | 7 | This document first discusses what sorts of issues RCU's CPU stall |
| 8 | detector can locate, and then discusses kernel parameters and Kconfig |
| 9 | options that can be used to fine-tune the detector's operation. Finally, |
| 10 | this document explains the stall detector's "splat" format. |
| 11 | |
| 12 | |
| 13 | What Causes RCU CPU Stall Warnings? |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 14 | =================================== |
Paul E. McKenney | 8e2a439 | 2017-02-08 14:30:15 -0800 | [diff] [blame] | 15 | |
| 16 | So your kernel printed an RCU CPU stall warning. The next question is |
| 17 | "What caused it?" The following problems can result in RCU CPU stall |
| 18 | warnings: |
| 19 | |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 20 | - A CPU looping in an RCU read-side critical section. |
Paul E. McKenney | 8e2a439 | 2017-02-08 14:30:15 -0800 | [diff] [blame] | 21 | |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 22 | - A CPU looping with interrupts disabled. |
Paul E. McKenney | 8e2a439 | 2017-02-08 14:30:15 -0800 | [diff] [blame] | 23 | |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 24 | - A CPU looping with preemption disabled. |
Paul E. McKenney | 8e2a439 | 2017-02-08 14:30:15 -0800 | [diff] [blame] | 25 | |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 26 | - A CPU looping with bottom halves disabled. |
Paul E. McKenney | 8e2a439 | 2017-02-08 14:30:15 -0800 | [diff] [blame] | 27 | |
Sebastian Andrzej Siewior | 81ad58b | 2020-12-15 15:16:49 +0100 | [diff] [blame] | 28 | - For !CONFIG_PREEMPTION kernels, a CPU looping anywhere in the kernel |
Paul E. McKenney | f2b1760 | 2017-10-24 08:42:41 -0700 | [diff] [blame] | 29 | without invoking schedule(). If the looping in the kernel is |
| 30 | really expected and desirable behavior, you might need to add |
| 31 | some calls to cond_resched(). |
Paul E. McKenney | 8e2a439 | 2017-02-08 14:30:15 -0800 | [diff] [blame] | 32 | |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 33 | - Booting Linux using a console connection that is too slow to |
Paul E. McKenney | 8e2a439 | 2017-02-08 14:30:15 -0800 | [diff] [blame] | 34 | keep up with the boot-time console-message rate. For example, |
Akira Yokosawa | e3879ec | 2021-05-20 13:32:36 +0900 | [diff] [blame] | 35 | a 115Kbaud serial console can be *way* too slow to keep up |
Paul E. McKenney | 8e2a439 | 2017-02-08 14:30:15 -0800 | [diff] [blame] | 36 | with boot-time message rates, and will frequently result in |
| 37 | RCU CPU stall warning messages. Especially if you have added |
| 38 | debug printk()s. |
| 39 | |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 40 | - Anything that prevents RCU's grace-period kthreads from running. |
Paul E. McKenney | 8e2a439 | 2017-02-08 14:30:15 -0800 | [diff] [blame] | 41 | This can result in the "All QSes seen" console-log message. |
| 42 | This message will include information on when the kthread last |
Paul E. McKenney | dfa0ee4 | 2017-08-09 10:16:29 -0700 | [diff] [blame] | 43 | ran and how often it should be expected to run. It can also |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 44 | result in the ``rcu_.*kthread starved for`` console-log message, |
Paul E. McKenney | dfa0ee4 | 2017-08-09 10:16:29 -0700 | [diff] [blame] | 45 | which will include additional debugging information. |
Paul E. McKenney | 8e2a439 | 2017-02-08 14:30:15 -0800 | [diff] [blame] | 46 | |
Sebastian Andrzej Siewior | 81ad58b | 2020-12-15 15:16:49 +0100 | [diff] [blame] | 47 | - A CPU-bound real-time task in a CONFIG_PREEMPTION kernel, which might |
Paul E. McKenney | 8e2a439 | 2017-02-08 14:30:15 -0800 | [diff] [blame] | 48 | happen to preempt a low-priority task in the middle of an RCU |
| 49 | read-side critical section. This is especially damaging if |
| 50 | that low-priority task is not permitted to run on any other CPU, |
| 51 | in which case the next RCU grace period can never complete, which |
| 52 | will eventually cause the system to run out of memory and hang. |
| 53 | While the system is in the process of running itself out of |
| 54 | memory, you might see stall-warning messages. |
| 55 | |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 56 | - A CPU-bound real-time task in a CONFIG_PREEMPT_RT kernel that |
Paul E. McKenney | 8e2a439 | 2017-02-08 14:30:15 -0800 | [diff] [blame] | 57 | is running at a higher priority than the RCU softirq threads. |
| 58 | This will prevent RCU callbacks from ever being invoked, |
| 59 | and in a CONFIG_PREEMPT_RCU kernel will further prevent |
| 60 | RCU grace periods from ever completing. Either way, the |
| 61 | system will eventually run out of memory and hang. In the |
| 62 | CONFIG_PREEMPT_RCU case, you might see stall-warning |
| 63 | messages. |
| 64 | |
Paul E. McKenney | 0500873 | 2019-07-08 08:01:50 -0700 | [diff] [blame] | 65 | You can use the rcutree.kthread_prio kernel boot parameter to |
| 66 | increase the scheduling priority of RCU's kthreads, which can |
| 67 | help avoid this problem. However, please note that doing this |
| 68 | can increase your system's context-switch rate and thus degrade |
| 69 | performance. |
| 70 | |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 71 | - A periodic interrupt whose handler takes longer than the time |
Paul E. McKenney | dfa0ee4 | 2017-08-09 10:16:29 -0700 | [diff] [blame] | 72 | interval between successive pairs of interrupts. This can |
| 73 | prevent RCU's kthreads and softirq handlers from running. |
| 74 | Note that certain high-overhead debugging options, for example |
| 75 | the function_graph tracer, can result in interrupt handler taking |
| 76 | considerably longer than normal, which can in turn result in |
| 77 | RCU CPU stall warnings. |
| 78 | |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 79 | - Testing a workload on a fast system, tuning the stall-warning |
Paul E. McKenney | 3d916a4 | 2017-08-10 14:33:17 -0700 | [diff] [blame] | 80 | timeout down to just barely avoid RCU CPU stall warnings, and then |
| 81 | running the same workload with the same stall-warning timeout on a |
| 82 | slow system. Note that thermal throttling and on-demand governors |
| 83 | can cause a single system to be sometimes fast and sometimes slow! |
| 84 | |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 85 | - A hardware or software issue shuts off the scheduler-clock |
Paul E. McKenney | 8e2a439 | 2017-02-08 14:30:15 -0800 | [diff] [blame] | 86 | interrupt on a CPU that is not in dyntick-idle mode. This |
| 87 | problem really has happened, and seems to be most likely to |
| 88 | result in RCU CPU stall warnings for CONFIG_NO_HZ_COMMON=n kernels. |
| 89 | |
Paul E. McKenney | b81898e | 2020-04-30 12:23:11 -0700 | [diff] [blame] | 90 | - A hardware or software issue that prevents time-based wakeups |
| 91 | from occurring. These issues can range from misconfigured or |
| 92 | buggy timer hardware through bugs in the interrupt or exception |
| 93 | path (whether hardware, firmware, or software) through bugs |
| 94 | in Linux's timer subsystem through bugs in the scheduler, and, |
Neeraj Upadhyay | 683954e | 2020-11-16 21:36:00 +0530 | [diff] [blame] | 95 | yes, even including bugs in RCU itself. It can also result in |
| 96 | the ``rcu_.*timer wakeup didn't happen for`` console-log message, |
| 97 | which will include additional debugging information. |
Paul E. McKenney | b81898e | 2020-04-30 12:23:11 -0700 | [diff] [blame] | 98 | |
Paul E. McKenney | 13bc8fa | 2021-07-22 21:41:48 -0700 | [diff] [blame] | 99 | - A low-level kernel issue that either fails to invoke one of the |
| 100 | variants of rcu_user_enter(), rcu_user_exit(), rcu_idle_enter(), |
| 101 | rcu_idle_exit(), rcu_irq_enter(), or rcu_irq_exit() on the one |
| 102 | hand, or that invokes one of them too many times on the other. |
| 103 | Historically, the most frequent issue has been an omission |
| 104 | of either irq_enter() or irq_exit(), which in turn invoke |
| 105 | rcu_irq_enter() or rcu_irq_exit(), respectively. Building your |
| 106 | kernel with CONFIG_RCU_EQS_DEBUG=y can help track down these types |
| 107 | of issues, which sometimes arise in architecture-specific code. |
| 108 | |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 109 | - A bug in the RCU implementation. |
Paul E. McKenney | 8e2a439 | 2017-02-08 14:30:15 -0800 | [diff] [blame] | 110 | |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 111 | - A hardware failure. This is quite unlikely, but has occurred |
Paul E. McKenney | 8e2a439 | 2017-02-08 14:30:15 -0800 | [diff] [blame] | 112 | at least once in real life. A CPU failed in a running system, |
| 113 | becoming unresponsive, but not causing an immediate crash. |
| 114 | This resulted in a series of RCU CPU stall warnings, eventually |
| 115 | leading the realization that the CPU had failed. |
| 116 | |
Paul E. McKenney | 7709590 | 2018-07-02 08:25:57 -0700 | [diff] [blame] | 117 | The RCU, RCU-sched, and RCU-tasks implementations have CPU stall warning. |
Akira Yokosawa | e3879ec | 2021-05-20 13:32:36 +0900 | [diff] [blame] | 118 | Note that SRCU does *not* have CPU stall warnings. Please note that |
Paul E. McKenney | 7709590 | 2018-07-02 08:25:57 -0700 | [diff] [blame] | 119 | RCU only detects CPU stalls when there is a grace period in progress. |
Paul E. McKenney | 8e2a439 | 2017-02-08 14:30:15 -0800 | [diff] [blame] | 120 | No grace period, no CPU stall warnings. |
| 121 | |
| 122 | To diagnose the cause of the stall, inspect the stack traces. |
| 123 | The offending function will usually be near the top of the stack. |
| 124 | If you have a series of stall warnings from a single extended stall, |
| 125 | comparing the stack traces can often help determine where the stall |
| 126 | is occurring, which will usually be in the function nearest the top of |
| 127 | that portion of the stack which remains the same from trace to trace. |
| 128 | If you can reliably trigger the stall, ftrace can be quite helpful. |
| 129 | |
| 130 | RCU bugs can often be debugged with the help of CONFIG_RCU_TRACE |
| 131 | and with RCU's event tracing. For information on RCU's event tracing, |
| 132 | see include/trace/events/rcu.h. |
| 133 | |
| 134 | |
| 135 | Fine-Tuning the RCU CPU Stall Detector |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 136 | ====================================== |
Paul E. McKenney | 8e2a439 | 2017-02-08 14:30:15 -0800 | [diff] [blame] | 137 | |
| 138 | The rcuupdate.rcu_cpu_stall_suppress module parameter disables RCU's |
| 139 | CPU stall detector, which detects conditions that unduly delay RCU grace |
| 140 | periods. This module parameter enables CPU stall detection by default, |
| 141 | but may be overridden via boot-time parameter or at runtime via sysfs. |
Paul E. McKenney | a00e0d71 | 2011-02-08 17:14:39 -0800 | [diff] [blame] | 142 | The stall detector's idea of what constitutes "unduly delayed" is |
| 143 | controlled by a set of kernel configuration variables and cpp macros: |
Paul E. McKenney | 4c54005 | 2010-01-14 16:10:57 -0800 | [diff] [blame] | 144 | |
Paul E. McKenney | a00e0d71 | 2011-02-08 17:14:39 -0800 | [diff] [blame] | 145 | CONFIG_RCU_CPU_STALL_TIMEOUT |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 146 | ---------------------------- |
Paul E. McKenney | 4c54005 | 2010-01-14 16:10:57 -0800 | [diff] [blame] | 147 | |
Paul E. McKenney | a00e0d71 | 2011-02-08 17:14:39 -0800 | [diff] [blame] | 148 | This kernel configuration parameter defines the period of time |
| 149 | that RCU will wait from the beginning of a grace period until it |
| 150 | issues an RCU CPU stall warning. This time period is normally |
Paul E. McKenney | 64d3b7a | 2013-08-19 11:59:43 -0700 | [diff] [blame] | 151 | 21 seconds. |
Paul E. McKenney | 4c54005 | 2010-01-14 16:10:57 -0800 | [diff] [blame] | 152 | |
Paul E. McKenney | 24cd7fd | 2012-01-20 17:35:55 -0800 | [diff] [blame] | 153 | This configuration parameter may be changed at runtime via the |
Xie XiuQi | 84596ccb | 2014-11-11 12:03:26 +0800 | [diff] [blame] | 154 | /sys/module/rcupdate/parameters/rcu_cpu_stall_timeout, however |
Paul E. McKenney | 24cd7fd | 2012-01-20 17:35:55 -0800 | [diff] [blame] | 155 | this parameter is checked only at the beginning of a cycle. |
Paul E. McKenney | 64d3b7a | 2013-08-19 11:59:43 -0700 | [diff] [blame] | 156 | So if you are 10 seconds into a 40-second stall, setting this |
Paul E. McKenney | 24cd7fd | 2012-01-20 17:35:55 -0800 | [diff] [blame] | 157 | sysfs parameter to (say) five will shorten the timeout for the |
Akira Yokosawa | e3879ec | 2021-05-20 13:32:36 +0900 | [diff] [blame] | 158 | *next* stall, or the following warning for the current stall |
Paul E. McKenney | 24cd7fd | 2012-01-20 17:35:55 -0800 | [diff] [blame] | 159 | (assuming the stall lasts long enough). It will not affect the |
| 160 | timing of the next warning for the current stall. |
Paul E. McKenney | 4c54005 | 2010-01-14 16:10:57 -0800 | [diff] [blame] | 161 | |
Paul E. McKenney | 24cd7fd | 2012-01-20 17:35:55 -0800 | [diff] [blame] | 162 | Stall-warning messages may be enabled and disabled completely via |
Paul E. McKenney | 96224da | 2014-02-25 09:47:34 -0800 | [diff] [blame] | 163 | /sys/module/rcupdate/parameters/rcu_cpu_stall_suppress. |
Paul E. McKenney | 24cd7fd | 2012-01-20 17:35:55 -0800 | [diff] [blame] | 164 | |
Paul E. McKenney | 24cd7fd | 2012-01-20 17:35:55 -0800 | [diff] [blame] | 165 | RCU_STALL_DELAY_DELTA |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 166 | --------------------- |
Paul E. McKenney | 24cd7fd | 2012-01-20 17:35:55 -0800 | [diff] [blame] | 167 | |
| 168 | Although the lockdep facility is extremely useful, it does add |
| 169 | some overhead. Therefore, under CONFIG_PROVE_RCU, the |
| 170 | RCU_STALL_DELAY_DELTA macro allows five extra seconds before |
Paul E. McKenney | 64d3b7a | 2013-08-19 11:59:43 -0700 | [diff] [blame] | 171 | giving an RCU CPU stall warning message. (This is a cpp |
| 172 | macro, not a kernel configuration parameter.) |
Paul E. McKenney | 4c54005 | 2010-01-14 16:10:57 -0800 | [diff] [blame] | 173 | |
| 174 | RCU_STALL_RAT_DELAY |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 175 | ------------------- |
Paul E. McKenney | 4c54005 | 2010-01-14 16:10:57 -0800 | [diff] [blame] | 176 | |
Paul E. McKenney | f1d507b | 2010-04-15 15:49:46 -0700 | [diff] [blame] | 177 | The CPU stall detector tries to make the offending CPU print its |
| 178 | own warnings, as this often gives better-quality stack traces. |
| 179 | However, if the offending CPU does not detect its own stall in |
| 180 | the number of jiffies specified by RCU_STALL_RAT_DELAY, then |
| 181 | some other CPU will complain. This delay is normally set to |
Paul E. McKenney | 64d3b7a | 2013-08-19 11:59:43 -0700 | [diff] [blame] | 182 | two jiffies. (This is a cpp macro, not a kernel configuration |
| 183 | parameter.) |
Paul E. McKenney | 4c54005 | 2010-01-14 16:10:57 -0800 | [diff] [blame] | 184 | |
Paul E. McKenney | 37fe5f0 | 2014-07-29 09:49:23 -0700 | [diff] [blame] | 185 | rcupdate.rcu_task_stall_timeout |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 186 | ------------------------------- |
Paul E. McKenney | 37fe5f0 | 2014-07-29 09:49:23 -0700 | [diff] [blame] | 187 | |
| 188 | This boot/sysfs parameter controls the RCU-tasks stall warning |
| 189 | interval. A value of zero or less suppresses RCU-tasks stall |
| 190 | warnings. A positive value sets the stall-warning interval |
Zhenzhong Duan | 588759a | 2019-04-14 11:11:03 +0800 | [diff] [blame] | 191 | in seconds. An RCU-tasks stall warning starts with the line: |
Paul E. McKenney | 37fe5f0 | 2014-07-29 09:49:23 -0700 | [diff] [blame] | 192 | |
| 193 | INFO: rcu_tasks detected stalls on tasks: |
| 194 | |
| 195 | And continues with the output of sched_show_task() for each |
| 196 | task stalling the current RCU-tasks grace period. |
| 197 | |
Paul E. McKenney | 8e2a439 | 2017-02-08 14:30:15 -0800 | [diff] [blame] | 198 | |
| 199 | Interpreting RCU's CPU Stall-Detector "Splats" |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 200 | ============================================== |
Paul E. McKenney | 8e2a439 | 2017-02-08 14:30:15 -0800 | [diff] [blame] | 201 | |
Paul E. McKenney | 99c0974 | 2021-07-14 11:46:55 -0700 | [diff] [blame] | 202 | For non-RCU-tasks flavors of RCU, when a CPU detects that some other |
| 203 | CPU is stalling, it will print a message similar to the following:: |
Paul E. McKenney | f1d507b | 2010-04-15 15:49:46 -0700 | [diff] [blame] | 204 | |
Paul E. McKenney | d3cf517 | 2017-08-17 12:29:22 -0700 | [diff] [blame] | 205 | INFO: rcu_sched detected stalls on CPUs/tasks: |
| 206 | 2-...: (3 GPs behind) idle=06c/0/0 softirq=1453/1455 fqs=0 |
| 207 | 16-...: (0 ticks this GP) idle=81c/0/0 softirq=764/764 fqs=0 |
Paul E. McKenney | e133346 | 2018-05-02 12:39:42 -0700 | [diff] [blame] | 208 | (detected by 32, t=2603 jiffies, g=7075, q=625) |
Paul E. McKenney | f1d507b | 2010-04-15 15:49:46 -0700 | [diff] [blame] | 209 | |
Paul E. McKenney | d3cf517 | 2017-08-17 12:29:22 -0700 | [diff] [blame] | 210 | This message indicates that CPU 32 detected that CPUs 2 and 16 were both |
| 211 | causing stalls, and that the stall was affecting RCU-sched. This message |
Paul E. McKenney | f1d507b | 2010-04-15 15:49:46 -0700 | [diff] [blame] | 212 | will normally be followed by stack dumps for each CPU. Please note that |
Paul E. McKenney | d3cf517 | 2017-08-17 12:29:22 -0700 | [diff] [blame] | 213 | PREEMPT_RCU builds can be stalled by tasks as well as by CPUs, and that |
| 214 | the tasks will be indicated by PID, for example, "P3421". It is even |
Akira Yokosawa | e3879ec | 2021-05-20 13:32:36 +0900 | [diff] [blame] | 215 | possible for an rcu_state stall to be caused by both CPUs *and* tasks, |
Joel Fernandes (Google) | dd944ca | 2018-09-22 19:41:27 -0400 | [diff] [blame] | 216 | in which case the offending CPUs and tasks will all be called out in the list. |
Paul E. McKenney | 99c0974 | 2021-07-14 11:46:55 -0700 | [diff] [blame] | 217 | In some cases, CPUs will detect themselves stalling, which will result |
| 218 | in a self-detected stall. |
Paul E. McKenney | f1d507b | 2010-04-15 15:49:46 -0700 | [diff] [blame] | 219 | |
Paul E. McKenney | d3cf517 | 2017-08-17 12:29:22 -0700 | [diff] [blame] | 220 | CPU 2's "(3 GPs behind)" indicates that this CPU has not interacted with |
| 221 | the RCU core for the past three grace periods. In contrast, CPU 16's "(0 |
| 222 | ticks this GP)" indicates that this CPU has not taken any scheduling-clock |
| 223 | interrupts during the current stalled grace period. |
Paul E. McKenney | 24cd7fd | 2012-01-20 17:35:55 -0800 | [diff] [blame] | 224 | |
| 225 | The "idle=" portion of the message prints the dyntick-idle state. |
| 226 | The hex number before the first "/" is the low-order 12 bits of the |
Paul E. McKenney | d3cf517 | 2017-08-17 12:29:22 -0700 | [diff] [blame] | 227 | dynticks counter, which will have an even-numbered value if the CPU |
| 228 | is in dyntick-idle mode and an odd-numbered value otherwise. The hex |
| 229 | number between the two "/"s is the value of the nesting, which will be |
| 230 | a small non-negative number if in the idle loop (as shown above) and a |
| 231 | very large positive number otherwise. |
Paul E. McKenney | 24cd7fd | 2012-01-20 17:35:55 -0800 | [diff] [blame] | 232 | |
Paul E. McKenney | 6231069 | 2013-03-06 13:37:09 -0800 | [diff] [blame] | 233 | The "softirq=" portion of the message tracks the number of RCU softirq |
| 234 | handlers that the stalled CPU has executed. The number before the "/" |
| 235 | is the number that had executed since boot at the time that this CPU |
| 236 | last noted the beginning of a grace period, which might be the current |
| 237 | (stalled) grace period, or it might be some earlier grace period (for |
| 238 | example, if the CPU might have been in dyntick-idle mode for an extended |
Haocheng Xie | 9984fd7 | 2021-05-25 17:31:52 +0800 | [diff] [blame] | 239 | time period). The number after the "/" is the number that have executed |
Paul E. McKenney | 6231069 | 2013-03-06 13:37:09 -0800 | [diff] [blame] | 240 | since boot until the current time. If this latter number stays constant |
| 241 | across repeated stall-warning messages, it is possible that RCU's softirq |
| 242 | handlers are no longer able to execute on this CPU. This can happen if |
| 243 | the stalled CPU is spinning with interrupts are disabled, or, in -rt |
| 244 | kernels, if a high-priority process is starving RCU's softirq handler. |
| 245 | |
Joel Fernandes (Google) | a78ad16 | 2018-10-29 22:15:59 -0700 | [diff] [blame] | 246 | The "fqs=" shows the number of force-quiescent-state idle/offline |
Paul E. McKenney | d3cf517 | 2017-08-17 12:29:22 -0700 | [diff] [blame] | 247 | detection passes that the grace-period kthread has made across this |
| 248 | CPU since the last time that this CPU noted the beginning of a grace |
| 249 | period. |
| 250 | |
| 251 | The "detected by" line indicates which CPU detected the stall (in this |
Paul E. McKenney | e133346 | 2018-05-02 12:39:42 -0700 | [diff] [blame] | 252 | case, CPU 32), how many jiffies have elapsed since the start of the grace |
| 253 | period (in this case 2603), the grace-period sequence number (7075), and |
| 254 | an estimate of the total number of RCU callbacks queued across all CPUs |
| 255 | (625 in this case). |
Paul E. McKenney | d3cf517 | 2017-08-17 12:29:22 -0700 | [diff] [blame] | 256 | |
Paul E. McKenney | d3cf517 | 2017-08-17 12:29:22 -0700 | [diff] [blame] | 257 | If the grace period ends just as the stall warning starts printing, |
| 258 | there will be a spurious stall-warning message, which will include |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 259 | the following:: |
Paul E. McKenney | d3cf517 | 2017-08-17 12:29:22 -0700 | [diff] [blame] | 260 | |
| 261 | INFO: Stall ended before state dump start |
| 262 | |
| 263 | This is rare, but does happen from time to time in real life. It is also |
| 264 | possible for a zero-jiffy stall to be flagged in this case, depending |
| 265 | on how the stall warning and the grace-period initialization happen to |
| 266 | interact. Please note that it is not possible to entirely eliminate this |
| 267 | sort of false positive without resorting to things like stop_machine(), |
| 268 | which is overkill for this sort of problem. |
| 269 | |
| 270 | If all CPUs and tasks have passed through quiescent states, but the |
| 271 | grace period has nevertheless failed to end, the stall-warning splat |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 272 | will include something like the following:: |
Paul E. McKenney | d3cf517 | 2017-08-17 12:29:22 -0700 | [diff] [blame] | 273 | |
| 274 | All QSes seen, last rcu_preempt kthread activity 23807 (4297905177-4297881370), jiffies_till_next_fqs=3, root ->qsmask 0x0 |
| 275 | |
| 276 | The "23807" indicates that it has been more than 23 thousand jiffies |
| 277 | since the grace-period kthread ran. The "jiffies_till_next_fqs" |
| 278 | indicates how frequently that kthread should run, giving the number |
| 279 | of jiffies between force-quiescent-state scans, in this case three, |
| 280 | which is way less than 23807. Finally, the root rcu_node structure's |
| 281 | ->qsmask field is printed, which will normally be zero. |
Paul E. McKenney | 24cd7fd | 2012-01-20 17:35:55 -0800 | [diff] [blame] | 282 | |
Paul E. McKenney | fb81a44 | 2014-12-17 08:35:02 -0800 | [diff] [blame] | 283 | If the relevant grace-period kthread has been unable to run prior to |
Paul E. McKenney | d3cf517 | 2017-08-17 12:29:22 -0700 | [diff] [blame] | 284 | the stall warning, as was the case in the "All QSes seen" line above, |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 285 | the following additional line is printed:: |
Paul E. McKenney | fb81a44 | 2014-12-17 08:35:02 -0800 | [diff] [blame] | 286 | |
Paul E. McKenney | 99c0974 | 2021-07-14 11:46:55 -0700 | [diff] [blame] | 287 | rcu_sched kthread starved for 23807 jiffies! g7075 f0x0 RCU_GP_WAIT_FQS(3) ->state=0x1 ->cpu=5 |
| 288 | Unless rcu_sched kthread gets sufficient CPU time, OOM is now expected behavior. |
Paul E. McKenney | fb81a44 | 2014-12-17 08:35:02 -0800 | [diff] [blame] | 289 | |
Paul E. McKenney | d3cf517 | 2017-08-17 12:29:22 -0700 | [diff] [blame] | 290 | Starving the grace-period kthreads of CPU time can of course result |
| 291 | in RCU CPU stall warnings even when all CPUs and tasks have passed |
Paul E. McKenney | e133346 | 2018-05-02 12:39:42 -0700 | [diff] [blame] | 292 | through the required quiescent states. The "g" number shows the current |
| 293 | grace-period sequence number, the "f" precedes the ->gp_flags command |
| 294 | to the grace-period kthread, the "RCU_GP_WAIT_FQS" indicates that the |
| 295 | kthread is waiting for a short timeout, the "state" precedes value of the |
| 296 | task_struct ->state field, and the "cpu" indicates that the grace-period |
| 297 | kthread last ran on CPU 5. |
Paul E. McKenney | fb81a44 | 2014-12-17 08:35:02 -0800 | [diff] [blame] | 298 | |
Neeraj Upadhyay | 683954e | 2020-11-16 21:36:00 +0530 | [diff] [blame] | 299 | If the relevant grace-period kthread does not wake from FQS wait in a |
| 300 | reasonable time, then the following additional line is printed:: |
| 301 | |
| 302 | kthread timer wakeup didn't happen for 23804 jiffies! g7076 f0x0 RCU_GP_WAIT_FQS(5) ->state=0x402 |
| 303 | |
| 304 | The "23804" indicates that kthread's timer expired more than 23 thousand |
| 305 | jiffies ago. The rest of the line has meaning similar to the kthread |
| 306 | starvation case. |
| 307 | |
| 308 | Additionally, the following line is printed:: |
| 309 | |
| 310 | Possible timer handling issue on cpu=4 timer-softirq=11142 |
| 311 | |
| 312 | Here "cpu" indicates that the grace-period kthread last ran on CPU 4, |
| 313 | where it queued the fqs timer. The number following the "timer-softirq" |
| 314 | is the current ``TIMER_SOFTIRQ`` count on cpu 4. If this value does not |
| 315 | change on successive RCU CPU stall warnings, there is further reason to |
| 316 | suspect a timer problem. |
| 317 | |
Paul E. McKenney | 99c0974 | 2021-07-14 11:46:55 -0700 | [diff] [blame] | 318 | These messages are usually followed by stack dumps of the CPUs and tasks |
| 319 | involved in the stall. These stack traces can help you locate the cause |
| 320 | of the stall, keeping in mind that the CPU detecting the stall will have |
| 321 | an interrupt frame that is mainly devoted to detecting the stall. |
| 322 | |
Paul E. McKenney | 24cd7fd | 2012-01-20 17:35:55 -0800 | [diff] [blame] | 323 | |
| 324 | Multiple Warnings From One Stall |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 325 | ================================ |
Paul E. McKenney | 24cd7fd | 2012-01-20 17:35:55 -0800 | [diff] [blame] | 326 | |
Paul E. McKenney | 99c0974 | 2021-07-14 11:46:55 -0700 | [diff] [blame] | 327 | If a stall lasts long enough, multiple stall-warning messages will |
| 328 | be printed for it. The second and subsequent messages are printed at |
Paul E. McKenney | 24cd7fd | 2012-01-20 17:35:55 -0800 | [diff] [blame] | 329 | longer intervals, so that the time between (say) the first and second |
| 330 | message will be about three times the interval between the beginning |
Paul E. McKenney | 99c0974 | 2021-07-14 11:46:55 -0700 | [diff] [blame] | 331 | of the stall and the first message. It can be helpful to compare the |
| 332 | stack dumps for the different messages for the same stalled grace period. |
Paul E. McKenney | 24cd7fd | 2012-01-20 17:35:55 -0800 | [diff] [blame] | 333 | |
| 334 | |
Paul E. McKenney | 99a930b | 2015-06-30 14:54:09 -0700 | [diff] [blame] | 335 | Stall Warnings for Expedited Grace Periods |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 336 | ========================================== |
Paul E. McKenney | 99a930b | 2015-06-30 14:54:09 -0700 | [diff] [blame] | 337 | |
| 338 | If an expedited grace period detects a stall, it will place a message |
Mauro Carvalho Chehab | f2286ab | 2020-04-21 19:04:10 +0200 | [diff] [blame] | 339 | like the following in dmesg:: |
Paul E. McKenney | 99a930b | 2015-06-30 14:54:09 -0700 | [diff] [blame] | 340 | |
Paul E. McKenney | d3cf517 | 2017-08-17 12:29:22 -0700 | [diff] [blame] | 341 | INFO: rcu_sched detected expedited stalls on CPUs/tasks: { 7-... } 21119 jiffies s: 73 root: 0x2/. |
Paul E. McKenney | 99a930b | 2015-06-30 14:54:09 -0700 | [diff] [blame] | 342 | |
Paul E. McKenney | d3cf517 | 2017-08-17 12:29:22 -0700 | [diff] [blame] | 343 | This indicates that CPU 7 has failed to respond to a reschedule IPI. |
| 344 | The three periods (".") following the CPU number indicate that the CPU |
| 345 | is online (otherwise the first period would instead have been "O"), |
| 346 | that the CPU was online at the beginning of the expedited grace period |
| 347 | (otherwise the second period would have instead been "o"), and that |
| 348 | the CPU has been online at least once since boot (otherwise, the third |
| 349 | period would instead have been "N"). The number before the "jiffies" |
| 350 | indicates that the expedited grace period has been going on for 21,119 |
| 351 | jiffies. The number following the "s:" indicates that the expedited |
| 352 | grace-period sequence counter is 73. The fact that this last value is |
| 353 | odd indicates that an expedited grace period is in flight. The number |
| 354 | following "root:" is a bitmask that indicates which children of the root |
| 355 | rcu_node structure correspond to CPUs and/or tasks that are blocking the |
| 356 | current expedited grace period. If the tree had more than one level, |
| 357 | additional hex numbers would be printed for the states of the other |
| 358 | rcu_node structures in the tree. |
| 359 | |
| 360 | As with normal grace periods, PREEMPT_RCU builds can be stalled by |
| 361 | tasks as well as by CPUs, and that the tasks will be indicated by PID, |
| 362 | for example, "P3421". |
Paul E. McKenney | 99a930b | 2015-06-30 14:54:09 -0700 | [diff] [blame] | 363 | |
| 364 | It is entirely possible to see stall warnings from normal and from |
Paul E. McKenney | d3cf517 | 2017-08-17 12:29:22 -0700 | [diff] [blame] | 365 | expedited grace periods at about the same time during the same run. |