Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

About Linux NMI watchdog

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.

like image 443
silverbullettt Avatar asked Mar 26 '12 02:03

silverbullettt


People also ask

What is NMI watchdog?

NMI Watchdog is a process that's able to log non-maskable interrupts (i.e. lockups that can't be cleared by any other processor command, such as [RESET]) if/when they happen.

How do I stop watchdog?

Starting and Stopping Watchdog You can write the character V into /dev/watchdog and then close the file. This should stop the watchdog.

How do I turn off watchdog Arch?

To disable watchdog timers (both software and hardware), append nowatchdog to your boot parameters. Either action will speed up your boot and shutdown, because one less module is loaded.

What is nmi watchdog in Windows?

Basically, this is the scenario when you press CTRL+ALT+DELETE on Windows computer. NMI watchdog is available for i386 and amd64 architectures.In order to use the NMI watchdog, operating systems’ kernel must support APIC (Advanced Programmable Interrupt Controller) protocol. When NMI is enabled , system will periodically generate a NMI call.

What is watchdog in Linux kernel?

Linux Kernel Watchdog. The Linux kernel watchdog is used to monitor if a system is running. It is supposed to automatically reboot hanged systems due to unrecoverable software errors. The watchdog module is specific to the hardware or chip being used.

How to enable nmi_watchdog?

However, at least oprofile and the perfctr driver disable the 30 local APIC NMI watchdog automatically. 31 32 To actually enable the NMI watchdog, use the 'nmi_watchdog=N' boot 33 parameter.

How does nmi work in Linux?

When NMI is enabled , system will periodically generate a NMI call. Each NMI invokes a handler in Linux kernel and check the number of interrupts. If the NMIs’ handler detects the number of interrupts hasn’t changed for a certain period of time, it assumes that kernel is hung.Then it invokes a kernel panic.


1 Answers

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.

like image 127
Courtney Schwartz Avatar answered Sep 22 '22 13:09

Courtney Schwartz