title: About Linux NMI watchdog
body: <p>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 &quot;nmi_watchdog=1&quot; into grub.cfg. And then check the <em>/proc/interrupt</em>, 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!</p>
  <p>Then I read the Documentation/nmi_watchdog.txt, it says:</p>
  <blockquote>
  <p>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 &quot;<strong>cycles unhalted</strong>&quot; event.</p>
  </blockquote>
  <p>What's the &quot;<strong>cycles unhalted</strong>&quot; event?</p>
  <p>It added:</p>
  <blockquote>
  <p>but if your system locks up on anything but the &quot;hlt&quot; processor
  instruction, the watchdog will trigger very soon as the &quot;cycles
  unhalted&quot; event will happen every clock tick...If it locks up on
  &quot;hlt&quot;, then you are out of luck -- the event will not happen at all
  and the watchdog <strong>won't</strong> trigger.</p>
  </blockquote>
  <p>Seems like that watchdog won't trigger if processor executes &quot;hlt&quot; instruction, then I search &quot;hlt&quot; in &quot;<em>Intel 64 and IA-32 Architectures Software Developer's Manual, Volumn 2A</em>&quot;, it describes it as follow:</p>
  <blockquote>
  <p>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 <strong>resume</strong>
  execution.</p>
  </blockquote>
  <p>Then I am lost...</p>
  <p>My question is:</p>
  <ul>
  <li><strong>How</strong> does Linux NMI watchdog work?</li>
  <li><strong>Who</strong> trigger the NMI?</li>
  </ul>
  <p>My OS is Ubuntu 10.04 LTS, Linux-2.6.32.21, CPU Pentium 4 Dual-core 3.20 GHz.</p>
  <p>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 <em>performance monitoring counter interrupt</em> and <em>inter-processor interrupt</em> (be provided by APIC) to send NMI instead of NMI watchdog.</p>