You can clone with
===============================================================Softlockup detector and hardlockup detector (aka nmi_watchdog)===============================================================The Linux kernel can act as a watchdog to detect both soft and hardlockups.A 'softlockup' is defined as a bug that causes the kernel to loop inkernel mode for more than 20 seconds (see "Implementation" below fordetails), without giving other tasks a chance to run. The currentstack trace is displayed upon detection and, by default, the systemwill stay locked up. Alternatively, the kernel can be configured topanic; a sysctl, "kernel.softlockup_panic", a kernel parameter,"softlockup_panic" (see "Documentation/kernel-parameters.txt" fordetails), and a compile option, "BOOTPARAM_HARDLOCKUP_PANIC", areprovided for this.A 'hardlockup' is defined as a bug that causes the CPU to loop inkernel mode for more than 10 seconds (see "Implementation" below fordetails), without letting other interrupts have a chance to run.Similarly to the softlockup case, the current stack trace is displayedupon detection and the system will stay locked up unless the defaultbehavior is changed, which can be done through a compile time knob,"BOOTPARAM_HARDLOCKUP_PANIC", and a kernel parameter, "nmi_watchdog"(see "Documentation/kernel-parameters.txt" for details).The panic option can be used in combination with panic_timeout (thistimeout is set through the confusingly named "kernel.panic" sysctl),to cause the system to reboot automatically after a specified amountof time.=== Implementation ===The soft and hard lockup detectors are built on top of the hrtimer andperf subsystems, respectively. A direct consequence of this is that,in principle, they should work in any architecture where thesesubsystems are present.A periodic hrtimer runs to generate interrupts and kick the watchdogtask. An NMI perf event is generated every "watchdog_thresh"(compile-time initialized to 10 and configurable through sysctl of thesame name) seconds to check for hardlockups. If any CPU in the systemdoes not receive any hrtimer interrupt during that time the'hardlockup detector' (the handler for the NMI perf event) willgenerate a kernel warning or call panic, depending on theconfiguration.The watchdog task is a high priority kernel thread that updates atimestamp every time it is scheduled. If that timestamp is not updatedfor 2*watchdog_thresh seconds (the softlockup threshold) the'softlockup detector' (coded inside the hrtimer callback function)will dump useful debug information to the system log, after which itwill call panic if it was instructed to do so or resume execution ofother kernel code.The period of the hrtimer is 2*watchdog_thresh/5, which means it hastwo or three chances to generate an interrupt before the hardlockupdetector kicks in.As explained above, a kernel knob is provided that allowsadministrators to configure the period of the hrtimer and the perfevent. The right value for a particular environment is a trade-offbetween fast response to lockups and detection overhead.