About Linux NMI watchdog
Asked Answered
R

2

30

Now I encounter a problem about Linux NMI Watchdog. I want to use Linux NMI watchdog to detect and recovery OS hang. So, I add "nmi_watchdog=1" into grub.cfg. And then check the /proc/interrupt, NMI were triggered per second. But after I load a module with deadlock (double-acquire spinlock), system were hanged totally, and nothing occurs (never panic!). It looks like that NMI watchdog did not work!

Then I read the Documentation/nmi_watchdog.txt, it says:

Be aware that when using local APIC, the frequency of NMI interrupts it generates, depends on the system load. The local APIC NMI watchdog, lacking a better source, uses the "cycles unhalted" event.

What's the "cycles unhalted" event?

It added:

but if your system locks up on anything but the "hlt" processor instruction, the watchdog will trigger very soon as the "cycles unhalted" event will happen every clock tick...If it locks up on "hlt", then you are out of luck -- the event will not happen at all and the watchdog won't trigger.

Seems like that watchdog won't trigger if processor executes "hlt" instruction, then I search "hlt" in "Intel 64 and IA-32 Architectures Software Developer's Manual, Volumn 2A", it describes it as follow:

Stops instruction execution and places the processor in a HALT state. An enabled interrupt (including NMI and SMI), a debug exception, the BINIT# signal, the INIT# signal, or the RESET# signal will resume execution.

Then I am lost...

My question is:

  • How does Linux NMI watchdog work?
  • Who trigger the NMI?

My OS is Ubuntu 10.04 LTS, Linux-2.6.32.21, CPU Pentium 4 Dual-core 3.20 GHz.

I didn't read the whole source code about NMI watchdog(no time), if I couldn't understand how NMI watchdog work, I want use performance monitoring counter interrupt and inter-processor interrupt (be provided by APIC) to send NMI instead of NMI watchdog.

Radloff answered 26/3, 2012 at 2:35 Comment(2)
nice stuff NMI watchdog, add this to my tools of tradeGonna
Linux kernel implementation watchdog_nmi_enable().Sayyid
Z
9

The answer depends on your hardware.

Non-maskable interrupts (NMI) can be triggered 2 ways: 1) when the kernel reaches a halting state that can't be interrupted by another method, and 2) by hardware -- using an NMI button.

On the front of some Dell servers, for example, you will see a small circle with a zig-zag line inside it. This is the NMI symbol. Nearby there is a hole. Insert a pin to trigger the interrupt. If your kernel is built to support it, this will dump a kernel panic trace to the console, then reboot the system.

This can happen very fast. So if you don't have a console attached to save the output to a file, it might look like only a reboot.

Zoara answered 18/7, 2013 at 23:17 Comment(0)
A
3

As I know, nmi_watchdog would only triggered for non-interruptible hangs. I found an code example by google: http://oslearn.blogspot.in/2011/04/use-nmi-watchdog.html

If your deadlock is not non-interruptiable, you can try enable sysRq to trigger some trace (Alt-printscreen-t) or crash (Alt-printscreen-c) to get more information.

Anecdotal answered 16/4, 2012 at 2:19 Comment(3)
Thanks. I read the all sources about nmi_watchdog (in linux-2.6.32) already, and now I know how it work :)Radloff
The code from the original link was reposted on kernelnewbies. It only works on uniprocessor systems. A reply in that thread includes code that works on multicore and SMP systems.Dissident
The blog behind the link is non public (anymore) "This blog is open to invited readers only"Vollmer

© 2022 - 2024 — McMap. All rights reserved.