stallwarn.txt 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. sixty seconds.
  13. This configuration parameter may be changed at runtime via the
  14. /sys/module/rcutree/parameters/rcu_cpu_stall_timeout, however
  15. this parameter is checked only at the beginning of a cycle.
  16. So if you are 30 seconds into a 70-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/rcutree/parameters/rcu_cpu_stall_suppress.
  23. CONFIG_RCU_CPU_STALL_VERBOSE
  24. This kernel configuration parameter causes the stall warning to
  25. also dump the stacks of any tasks that are blocking the current
  26. RCU-preempt grace period.
  27. RCU_CPU_STALL_INFO
  28. This kernel configuration parameter causes the stall warning to
  29. print out additional per-CPU diagnostic information, including
  30. information on scheduling-clock ticks and RCU's idle-CPU tracking.
  31. RCU_STALL_DELAY_DELTA
  32. Although the lockdep facility is extremely useful, it does add
  33. some overhead. Therefore, under CONFIG_PROVE_RCU, the
  34. RCU_STALL_DELAY_DELTA macro allows five extra seconds before
  35. giving an RCU CPU stall warning message.
  36. RCU_STALL_RAT_DELAY
  37. The CPU stall detector tries to make the offending CPU print its
  38. own warnings, as this often gives better-quality stack traces.
  39. However, if the offending CPU does not detect its own stall in
  40. the number of jiffies specified by RCU_STALL_RAT_DELAY, then
  41. some other CPU will complain. This delay is normally set to
  42. two jiffies.
  43. When a CPU detects that it is stalling, it will print a message similar
  44. to the following:
  45. INFO: rcu_sched_state detected stall on CPU 5 (t=2500 jiffies)
  46. This message indicates that CPU 5 detected that it was causing a stall,
  47. and that the stall was affecting RCU-sched. This message will normally be
  48. followed by a stack dump of the offending CPU. On TREE_RCU kernel builds,
  49. RCU and RCU-sched are implemented by the same underlying mechanism,
  50. while on TREE_PREEMPT_RCU kernel builds, RCU is instead implemented
  51. by rcu_preempt_state.
  52. On the other hand, if the offending CPU fails to print out a stall-warning
  53. message quickly enough, some other CPU will print a message similar to
  54. the following:
  55. INFO: rcu_bh_state detected stalls on CPUs/tasks: { 3 5 } (detected by 2, 2502 jiffies)
  56. This message indicates that CPU 2 detected that CPUs 3 and 5 were both
  57. causing stalls, and that the stall was affecting RCU-bh. This message
  58. will normally be followed by stack dumps for each CPU. Please note that
  59. TREE_PREEMPT_RCU builds can be stalled by tasks as well as by CPUs,
  60. and that the tasks will be indicated by PID, for example, "P3421".
  61. It is even possible for a rcu_preempt_state stall to be caused by both
  62. CPUs -and- tasks, in which case the offending CPUs and tasks will all
  63. be called out in the list.
  64. Finally, if the grace period ends just as the stall warning starts
  65. printing, there will be a spurious stall-warning message:
  66. INFO: rcu_bh_state detected stalls on CPUs/tasks: { } (detected by 4, 2502 jiffies)
  67. This is rare, but does happen from time to time in real life.
  68. If the CONFIG_RCU_CPU_STALL_INFO kernel configuration parameter is set,
  69. more information is printed with the stall-warning message, for example:
  70. INFO: rcu_preempt detected stall on CPU
  71. 0: (63959 ticks this GP) idle=241/3fffffffffffffff/0 softirq=82/543
  72. (t=65000 jiffies)
  73. In kernels with CONFIG_RCU_FAST_NO_HZ, even more information is
  74. printed:
  75. INFO: rcu_preempt detected stall on CPU
  76. 0: (64628 ticks this GP) idle=dd5/3fffffffffffffff/0 softirq=82/543 last_accelerate: a345/d342 nonlazy_posted: 25 .D
  77. (t=65000 jiffies)
  78. The "(64628 ticks this GP)" indicates that this CPU has taken more
  79. than 64,000 scheduling-clock interrupts during the current stalled
  80. grace period. If the CPU was not yet aware of the current grace
  81. period (for example, if it was offline), then this part of the message
  82. indicates how many grace periods behind the CPU is.
  83. The "idle=" portion of the message prints the dyntick-idle state.
  84. The hex number before the first "/" is the low-order 12 bits of the
  85. dynticks counter, which will have an even-numbered value if the CPU is
  86. in dyntick-idle mode and an odd-numbered value otherwise. The hex
  87. number between the two "/"s is the value of the nesting, which will
  88. be a small positive number if in the idle loop and a very large positive
  89. number (as shown above) otherwise.
  90. The "softirq=" portion of the message tracks the number of RCU softirq
  91. handlers that the stalled CPU has executed. The number before the "/"
  92. is the number that had executed since boot at the time that this CPU
  93. last noted the beginning of a grace period, which might be the current
  94. (stalled) grace period, or it might be some earlier grace period (for
  95. example, if the CPU might have been in dyntick-idle mode for an extended
  96. time period. The number after the "/" is the number that have executed
  97. since boot until the current time. If this latter number stays constant
  98. across repeated stall-warning messages, it is possible that RCU's softirq
  99. handlers are no longer able to execute on this CPU. This can happen if
  100. the stalled CPU is spinning with interrupts are disabled, or, in -rt
  101. kernels, if a high-priority process is starving RCU's softirq handler.
  102. For CONFIG_RCU_FAST_NO_HZ kernels, the "last_accelerate:" prints the
  103. low-order 16 bits (in hex) of the jiffies counter when this CPU last
  104. invoked rcu_try_advance_all_cbs() from rcu_needs_cpu() or last invoked
  105. rcu_accelerate_cbs() from rcu_prepare_for_idle(). The "nonlazy_posted:"
  106. prints the number of non-lazy callbacks posted since the last call to
  107. rcu_needs_cpu(). Finally, an "L" indicates that there are currently
  108. no non-lazy callbacks ("." is printed otherwise, as shown above) and
  109. "D" indicates that dyntick-idle processing is enabled ("." is printed
  110. otherwise, for example, if disabled via the "nohz=" kernel boot parameter).
  111. Multiple Warnings From One Stall
  112. If a stall lasts long enough, multiple stall-warning messages will be
  113. printed for it. The second and subsequent messages are printed at
  114. longer intervals, so that the time between (say) the first and second
  115. message will be about three times the interval between the beginning
  116. of the stall and the first message.
  117. What Causes RCU CPU Stall Warnings?
  118. So your kernel printed an RCU CPU stall warning. The next question is
  119. "What caused it?" The following problems can result in RCU CPU stall
  120. warnings:
  121. o A CPU looping in an RCU read-side critical section.
  122. o A CPU looping with interrupts disabled. This condition can
  123. result in RCU-sched and RCU-bh stalls.
  124. o A CPU looping with preemption disabled. This condition can
  125. result in RCU-sched stalls and, if ksoftirqd is in use, RCU-bh
  126. stalls.
  127. o A CPU looping with bottom halves disabled. This condition can
  128. result in RCU-sched and RCU-bh stalls.
  129. o For !CONFIG_PREEMPT kernels, a CPU looping anywhere in the kernel
  130. without invoking schedule().
  131. o A CPU-bound real-time task in a CONFIG_PREEMPT kernel, which might
  132. happen to preempt a low-priority task in the middle of an RCU
  133. read-side critical section. This is especially damaging if
  134. that low-priority task is not permitted to run on any other CPU,
  135. in which case the next RCU grace period can never complete, which
  136. will eventually cause the system to run out of memory and hang.
  137. While the system is in the process of running itself out of
  138. memory, you might see stall-warning messages.
  139. o A CPU-bound real-time task in a CONFIG_PREEMPT_RT kernel that
  140. is running at a higher priority than the RCU softirq threads.
  141. This will prevent RCU callbacks from ever being invoked,
  142. and in a CONFIG_TREE_PREEMPT_RCU kernel will further prevent
  143. RCU grace periods from ever completing. Either way, the
  144. system will eventually run out of memory and hang. In the
  145. CONFIG_TREE_PREEMPT_RCU case, you might see stall-warning
  146. messages.
  147. o A hardware or software issue shuts off the scheduler-clock
  148. interrupt on a CPU that is not in dyntick-idle mode. This
  149. problem really has happened, and seems to be most likely to
  150. result in RCU CPU stall warnings for CONFIG_NO_HZ_COMMON=n kernels.
  151. o A bug in the RCU implementation.
  152. o A hardware failure. This is quite unlikely, but has occurred
  153. at least once in real life. A CPU failed in a running system,
  154. becoming unresponsive, but not causing an immediate crash.
  155. This resulted in a series of RCU CPU stall warnings, eventually
  156. leading the realization that the CPU had failed.
  157. The RCU, RCU-sched, and RCU-bh implementations have CPU stall warning.
  158. SRCU does not have its own CPU stall warnings, but its calls to
  159. synchronize_sched() will result in RCU-sched detecting RCU-sched-related
  160. CPU stalls. Please note that RCU only detects CPU stalls when there is
  161. a grace period in progress. No grace period, no CPU stall warnings.
  162. To diagnose the cause of the stall, inspect the stack traces.
  163. The offending function will usually be near the top of the stack.
  164. If you have a series of stall warnings from a single extended stall,
  165. comparing the stack traces can often help determine where the stall
  166. is occurring, which will usually be in the function nearest the top of
  167. that portion of the stack which remains the same from trace to trace.
  168. If you can reliably trigger the stall, ftrace can be quite helpful.
  169. RCU bugs can often be debugged with the help of CONFIG_RCU_TRACE
  170. and with RCU's event tracing.