lockup-watchdogs.txt 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. ===============================================================
  2. Softlockup detector and hardlockup detector (aka nmi_watchdog)
  3. ===============================================================
  4. The Linux kernel can act as a watchdog to detect both soft and hard
  5. lockups.
  6. A 'softlockup' is defined as a bug that causes the kernel to loop in
  7. kernel mode for more than 20 seconds (see "Implementation" below for
  8. details), without giving other tasks a chance to run. The current
  9. stack trace is displayed upon detection and, by default, the system
  10. will stay locked up. Alternatively, the kernel can be configured to
  11. panic; a sysctl, "kernel.softlockup_panic", a kernel parameter,
  12. "softlockup_panic" (see "Documentation/kernel-parameters.txt" for
  13. details), and a compile option, "BOOTPARAM_HARDLOCKUP_PANIC", are
  14. provided for this.
  15. A 'hardlockup' is defined as a bug that causes the CPU to loop in
  16. kernel mode for more than 10 seconds (see "Implementation" below for
  17. details), without letting other interrupts have a chance to run.
  18. Similarly to the softlockup case, the current stack trace is displayed
  19. upon detection and the system will stay locked up unless the default
  20. behavior is changed, which can be done through a compile time knob,
  21. "BOOTPARAM_HARDLOCKUP_PANIC", and a kernel parameter, "nmi_watchdog"
  22. (see "Documentation/kernel-parameters.txt" for details).
  23. The panic option can be used in combination with panic_timeout (this
  24. timeout is set through the confusingly named "kernel.panic" sysctl),
  25. to cause the system to reboot automatically after a specified amount
  26. of time.
  27. === Implementation ===
  28. The soft and hard lockup detectors are built on top of the hrtimer and
  29. perf subsystems, respectively. A direct consequence of this is that,
  30. in principle, they should work in any architecture where these
  31. subsystems are present.
  32. A periodic hrtimer runs to generate interrupts and kick the watchdog
  33. task. An NMI perf event is generated every "watchdog_thresh"
  34. (compile-time initialized to 10 and configurable through sysctl of the
  35. same name) seconds to check for hardlockups. If any CPU in the system
  36. does not receive any hrtimer interrupt during that time the
  37. 'hardlockup detector' (the handler for the NMI perf event) will
  38. generate a kernel warning or call panic, depending on the
  39. configuration.
  40. The watchdog task is a high priority kernel thread that updates a
  41. timestamp every time it is scheduled. If that timestamp is not updated
  42. for 2*watchdog_thresh seconds (the softlockup threshold) the
  43. 'softlockup detector' (coded inside the hrtimer callback function)
  44. will dump useful debug information to the system log, after which it
  45. will call panic if it was instructed to do so or resume execution of
  46. other kernel code.
  47. The period of the hrtimer is 2*watchdog_thresh/5, which means it has
  48. two or three chances to generate an interrupt before the hardlockup
  49. detector kicks in.
  50. As explained above, a kernel knob is provided that allows
  51. administrators to configure the period of the hrtimer and the perf
  52. event. The right value for a particular environment is a trade-off
  53. between fast response to lockups and detection overhead.