Skip to contentSkip to conversation

One watchdog trips the watchdog on all processors

RFC PATCH In review George Dunlap 2 participants 2 messages Jul 17, 2009

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 One watchdog trips the watchdog on all processors

I've been using the watchdog timer recently to debug deadlocks, and found that it only triggers on one cpu. Unfortunately, if your deadlock is not symmetric, it's not often obvious what the other cpu(s) is(are) doing. The attached patch is a hack I put in place to trigger an NMI on all cpus if it's triggered on one. This will cause things to hang instead of reboot, however, so I'm not sure how to integrate it into the normal watchdog-for-reliability functionality (as opposed to watchdog-for-debugging).

-George

xen/arch/x86/nmi.c +44 -1
diff -r 45981aefbe48 xen/arch/x86/nmi.c
@@ -383,10 +383,38 @@
     }
 }
 
+static atomic_t all_panic = ATOMIC_INIT(0);
+static DEFINE_SPINLOCK(panic_lock);
+
+static void do_nmi_trigger_cpu(int cpu)
+{
+    u32 id = cpu_physical_id(cpu);
+
+    printk("Triggering NMI on APIC ID %x\n", id);
+    debugtrace_dump();
+
+    local_irq_disable();
+    apic_wait_icr_idle();
+    apic_icr_write(APIC_DM_NMI | APIC_DEST_PHYSICAL, id);
+    local_irq_enable();
+}
+
 void nmi_watchdog_tick(struct cpu_user_regs * regs)
 {
     unsigned int sum = this_cpu(nmi_timer_ticks);
 
+    if ( atomic_read(&all_panic) )
+    {
+        spin_lock(&panic_lock);
+        console_force_unlock();
+        printk("Sibling watchdog timer fired! Printing state for CPU%d\n",
+               smp_processor_id());
+        show_execution_state(regs);
+        debugtrace_dump();
+        spin_unlock(&panic_lock);
+        while(1);
+    }
+
     if ( (this_cpu(last_irq_sums) == sum) &&
          !atomic_read(&watchdog_disable_count) )
     {
@@ -400,7 +428,22 @@
             console_force_unlock();
             printk("Watchdog timer detects that CPU%d is stuck!\n",
                    smp_processor_id());
-            fatal_trap(TRAP_nmi, regs);
+            show_execution_state(regs);
+            debugtrace_dump();
+            atomic_inc(&all_panic);
+            {
+                int cpu;
+                spin_lock(&panic_lock);
+                for_each_cpu(cpu)
+                {
+                    if ( cpu == smp_processor_id())
+                        continue;
+                    do_nmi_trigger_cpu(cpu);
+                }
+                spin_unlock(&panic_lock);
+            }
+            while(1);
+            //fatal_trap(TRAP_nmi, regs);
         }
     } 
     else 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

Re: [RFC] [PATCH] One watchdog trips the watchdog on allprocessors

xen/arch/x86/nmi.c line 399

Quoted 13 lines
Quoted 1 line
Quoted 1 line

George Dunlap <[email protected]> 17.07.09 14:55 >>>

...

xen/arch/x86/nmi.c +11 -0
+static void do_nmi_trigger_cpu(int cpu)
+{
+    u32 id = cpu_physical_id(cpu);
+
+    printk("Triggering NMI on APIC ID %x\n", id);
+    debugtrace_dump();
+
+    local_irq_disable();
+    apic_wait_icr_idle();
+    apic_icr_write(APIC_DM_NMI | APIC_DEST_PHYSICAL, id);
+    local_irq_enable();

You definitely don't want to enable interrupts inside an NMI. I don't think you need to disable them either, as nothing else should have enabled them.

Quoted 2 lines

...
+ for_each_cpu(cpu)

This is for_each_possible_cpu() now.

Jan