stallwarn.txt 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. Using RCU's CPU Stall Detector
  2. The rcu_cpu_stall_suppress module parameter enables RCU's CPU stall
  3. detector, which detects conditions that unduly delay RCU grace periods.
  4. This module parameter enables CPU stall detection by default, but
  5. may be overridden via boot-time parameter or at runtime via sysfs.
  6. The stall detector's idea of what constitutes "unduly delayed" is
  7. controlled by a set of kernel configuration variables and cpp macros:
  8. CONFIG_RCU_CPU_STALL_TIMEOUT
  9. This kernel configuration parameter defines the period of time
  10. that RCU will wait from the beginning of a grace period until it
  11. issues an RCU CPU stall warning. This time period is normally
  12. 21 seconds.
  13. This configuration parameter may be changed at runtime via the
  14. /sys/module/rcupdate/parameters/rcu_cpu_stall_timeout, however
  15. this parameter is checked only at the beginning of a cycle.
  16. So if you are 10 seconds into a 40-second stall, setting this
  17. sysfs parameter to (say) five will shorten the timeout for the
  18. -next- stall, or the following warning for the current stall
  19. (assuming the stall lasts long enough). It will not affect the
  20. timing of the next warning for the current stall.
  21. Stall-warning messages may be enabled and disabled completely via
  22. /sys/module/rcupdate/parameters/rcu_cpu_stall_suppress.
  23. CONFIG_RCU_CPU_STALL_INFO
  24. This kernel configuration parameter causes the stall warning to
  25. print out additional per-CPU diagnostic information, including
  26. information on scheduling-clock ticks and RCU's idle-CPU tracking.
  27. RCU_STALL_DELAY_DELTA
  28. Although the lockdep facility is extremely useful, it does add
  29. some overhead. Therefore, under CONFIG_PROVE_RCU, the
  30. RCU_STALL_DELAY_DELTA macro allows five extra seconds before
  31. giving an RCU CPU stall warning message. (This is a cpp
  32. macro, not a kernel configuration parameter.)
  33. RCU_STALL_RAT_DELAY
  34. The CPU stall detector tries to make the offending CPU print its
  35. own warnings, as this often gives better-quality stack traces.
  36. However, if the offending CPU does not detect its own stall in
  37. the number of jiffies specified by RCU_STALL_RAT_DELAY, then
  38. some other CPU will complain. This delay is normally set to
  39. two jiffies. (This is a cpp macro, not a kernel configuration
  40. parameter.)
  41. rcupdate.rcu_task_stall_timeout
  42. This boot/sysfs parameter controls the RCU-tasks stall warning
  43. interval. A value of zero or less suppresses RCU-tasks stall
  44. warnings. A positive value sets the stall-warning interval
  45. in jiffies. An RCU-tasks stall warning starts wtih the line:
  46. INFO: rcu_tasks detected stalls on tasks:
  47. And continues with the output of sched_show_task() for each
  48. task stalling the current RCU-tasks grace period.
  49. For non-RCU-tasks flavors of RCU, when a CPU detects that it is stalling,
  50. it will print a message similar to the following:
  51. INFO: rcu_sched_state detected stall on CPU 5 (t=2500 jiffies)
  52. This message indicates that CPU 5 detected that it was causing a stall,
  53. and that the stall was affecting RCU-sched. This message will normally be
  54. followed by a stack dump of the offending CPU. On TREE_RCU kernel builds,
  55. RCU and RCU-sched are implemented by the same underlying mechanism,
  56. while on PREEMPT_RCU kernel builds, RCU is instead implemented
  57. by rcu_preempt_state.
  58. On the other hand, if the offending CPU fails to print out a stall-warning
  59. message quickly enough, some other CPU will print a message similar to
  60. the following:
  61. INFO: rcu_bh_state detected stalls on CPUs/tasks: { 3 5 } (detected by 2, 2502 jiffies)
  62. This message indicates that CPU 2 detected that CPUs 3 and 5 were both
  63. causing stalls, and that the stall was affecting RCU-bh. This message
  64. will normally be followed by stack dumps for each CPU. Please note that
  65. PREEMPT_RCU builds can be stalled by tasks as well as by CPUs,
  66. and that the tasks will be indicated by PID, for example, "P3421".
  67. It is even possible for a rcu_preempt_state stall to be caused by both
  68. CPUs -and- tasks, in which case the offending CPUs and tasks will all
  69. be called out in the list.
  70. Finally, if the grace period ends just as the stall warning starts
  71. printing, there will be a spurious stall-warning message:
  72. INFO: rcu_bh_state detected stalls on CPUs/tasks: { } (detected by 4, 2502 jiffies)
  73. This is rare, but does happen from time to time in real life. It is also
  74. possible for a zero-jiffy stall to be flagged in this case, depending
  75. on how the stall warning and the grace-period initialization happen to
  76. interact. Please note that it is not possible to entirely eliminate this
  77. sort of false positive without resorting to things like stop_machine(),
  78. which is overkill for this sort of problem.
  79. If the CONFIG_RCU_CPU_STALL_INFO kernel configuration parameter is set,
  80. more information is printed with the stall-warning message, for example:
  81. INFO: rcu_preempt detected stall on CPU
  82. 0: (63959 ticks this GP) idle=241/3fffffffffffffff/0 softirq=82/543
  83. (t=65000 jiffies)
  84. In kernels with CONFIG_RCU_FAST_NO_HZ, even more information is
  85. printed:
  86. INFO: rcu_preempt detected stall on CPU
  87. 0: (64628 ticks this GP) idle=dd5/3fffffffffffffff/0 softirq=82/543 last_accelerate: a345/d342 nonlazy_posted: 25 .D
  88. (t=65000 jiffies)
  89. The "(64628 ticks this GP)" indicates that this CPU has taken more
  90. than 64,000 scheduling-clock interrupts during the current stalled
  91. grace period. If the CPU was not yet aware of the current grace
  92. period (for example, if it was offline), then this part of the message
  93. indicates how many grace periods behind the CPU is.
  94. The "idle=" portion of the message prints the dyntick-idle state.
  95. The hex number before the first "/" is the low-order 12 bits of the
  96. dynticks counter, which will have an even-numbered value if the CPU is
  97. in dyntick-idle mode and an odd-numbered value otherwise. The hex
  98. number between the two "/"s is the value of the nesting, which will
  99. be a small positive number if in the idle loop and a very large positive
  100. number (as shown above) otherwise.
  101. The "softirq=" portion of the message tracks the number of RCU softirq
  102. handlers that the stalled CPU has executed. The number before the "/"
  103. is the number that had executed since boot at the time that this CPU
  104. last noted the beginning of a grace period, which might be the current
  105. (stalled) grace period, or it might be some earlier grace period (for
  106. example, if the CPU might have been in dyntick-idle mode for an extended
  107. time period. The number after the "/" is the number that have executed
  108. since boot until the current time. If this latter number stays constant
  109. across repeated stall-warning messages, it is possible that RCU's softirq
  110. handlers are no longer able to execute on this CPU. This can happen if
  111. the stalled CPU is spinning with interrupts are disabled, or, in -rt
  112. kernels, if a high-priority process is starving RCU's softirq handler.
  113. For CONFIG_RCU_FAST_NO_HZ kernels, the "last_accelerate:" prints the
  114. low-order 16 bits (in hex) of the jiffies counter when this CPU last
  115. invoked rcu_try_advance_all_cbs() from rcu_needs_cpu() or last invoked
  116. rcu_accelerate_cbs() from rcu_prepare_for_idle(). The "nonlazy_posted:"
  117. prints the number of non-lazy callbacks posted since the last call to
  118. rcu_needs_cpu(). Finally, an "L" indicates that there are currently
  119. no non-lazy callbacks ("." is printed otherwise, as shown above) and
  120. "D" indicates that dyntick-idle processing is enabled ("." is printed
  121. otherwise, for example, if disabled via the "nohz=" kernel boot parameter).
  122. If the relevant grace-period kthread has been unable to run prior to
  123. the stall warning, the following additional line is printed:
  124. rcu_preempt kthread starved for 2023 jiffies!
  125. Starving the grace-period kthreads of CPU time can of course result in
  126. RCU CPU stall warnings even when all CPUs and tasks have passed through
  127. the required quiescent states.
  128. Multiple Warnings From One Stall
  129. If a stall lasts long enough, multiple stall-warning messages will be
  130. printed for it. The second and subsequent messages are printed at
  131. longer intervals, so that the time between (say) the first and second
  132. message will be about three times the interval between the beginning
  133. of the stall and the first message.
  134. What Causes RCU CPU Stall Warnings?
  135. So your kernel printed an RCU CPU stall warning. The next question is
  136. "What caused it?" The following problems can result in RCU CPU stall
  137. warnings:
  138. o A CPU looping in an RCU read-side critical section.
  139. o A CPU looping with interrupts disabled. This condition can
  140. result in RCU-sched and RCU-bh stalls.
  141. o A CPU looping with preemption disabled. This condition can
  142. result in RCU-sched stalls and, if ksoftirqd is in use, RCU-bh
  143. stalls.
  144. o A CPU looping with bottom halves disabled. This condition can
  145. result in RCU-sched and RCU-bh stalls.
  146. o For !CONFIG_PREEMPT kernels, a CPU looping anywhere in the
  147. kernel without invoking schedule(). Note that cond_resched()
  148. does not necessarily prevent RCU CPU stall warnings. Therefore,
  149. if the looping in the kernel is really expected and desirable
  150. behavior, you might need to replace some of the cond_resched()
  151. calls with calls to cond_resched_rcu_qs().
  152. o Anything that prevents RCU's grace-period kthreads from running.
  153. This can result in the "All QSes seen" console-log message.
  154. This message will include information on when the kthread last
  155. ran and how often it should be expected to run.
  156. o A CPU-bound real-time task in a CONFIG_PREEMPT kernel, which might
  157. happen to preempt a low-priority task in the middle of an RCU
  158. read-side critical section. This is especially damaging if
  159. that low-priority task is not permitted to run on any other CPU,
  160. in which case the next RCU grace period can never complete, which
  161. will eventually cause the system to run out of memory and hang.
  162. While the system is in the process of running itself out of
  163. memory, you might see stall-warning messages.
  164. o A CPU-bound real-time task in a CONFIG_PREEMPT_RT kernel that
  165. is running at a higher priority than the RCU softirq threads.
  166. This will prevent RCU callbacks from ever being invoked,
  167. and in a CONFIG_PREEMPT_RCU kernel will further prevent
  168. RCU grace periods from ever completing. Either way, the
  169. system will eventually run out of memory and hang. In the
  170. CONFIG_PREEMPT_RCU case, you might see stall-warning
  171. messages.
  172. o A hardware or software issue shuts off the scheduler-clock
  173. interrupt on a CPU that is not in dyntick-idle mode. This
  174. problem really has happened, and seems to be most likely to
  175. result in RCU CPU stall warnings for CONFIG_NO_HZ_COMMON=n kernels.
  176. o A bug in the RCU implementation.
  177. o A hardware failure. This is quite unlikely, but has occurred
  178. at least once in real life. A CPU failed in a running system,
  179. becoming unresponsive, but not causing an immediate crash.
  180. This resulted in a series of RCU CPU stall warnings, eventually
  181. leading the realization that the CPU had failed.
  182. The RCU, RCU-sched, RCU-bh, and RCU-tasks implementations have CPU stall
  183. warning. Note that SRCU does -not- have CPU stall warnings. Please note
  184. that RCU only detects CPU stalls when there is a grace period in progress.
  185. No grace period, no CPU stall warnings.
  186. To diagnose the cause of the stall, inspect the stack traces.
  187. The offending function will usually be near the top of the stack.
  188. If you have a series of stall warnings from a single extended stall,
  189. comparing the stack traces can often help determine where the stall
  190. is occurring, which will usually be in the function nearest the top of
  191. that portion of the stack which remains the same from trace to trace.
  192. If you can reliably trigger the stall, ftrace can be quite helpful.
  193. RCU bugs can often be debugged with the help of CONFIG_RCU_TRACE
  194. and with RCU's event tracing. For information on RCU's event tracing,
  195. see include/trace/events/rcu.h.