sched: encapsulate priority changes in a sched_set_prio static function
[deliverable/linux.git] / kernel / panic.c
index fa400852bf6ca318b4b1e843f8b4f6967ce262b3..535c96510a448f351dc89f3a36c01b2372f0decf 100644 (file)
@@ -73,6 +73,26 @@ void __weak nmi_panic_self_stop(struct pt_regs *regs)
 
 atomic_t panic_cpu = ATOMIC_INIT(PANIC_CPU_INVALID);
 
+/*
+ * A variant of panic() called from NMI context. We return if we've already
+ * panicked on this CPU. If another CPU already panicked, loop in
+ * nmi_panic_self_stop() which can provide architecture dependent code such
+ * as saving register state for crash dump.
+ */
+void nmi_panic(struct pt_regs *regs, const char *msg)
+{
+       int old_cpu, cpu;
+
+       cpu = raw_smp_processor_id();
+       old_cpu = atomic_cmpxchg(&panic_cpu, PANIC_CPU_INVALID, cpu);
+
+       if (old_cpu == PANIC_CPU_INVALID)
+               panic("%s", msg);
+       else if (old_cpu != cpu)
+               nmi_panic_self_stop(regs);
+}
+EXPORT_SYMBOL(nmi_panic);
+
 /**
  *     panic - halt the system
  *     @fmt: The text string to print
This page took 0.027168 seconds and 5 git commands to generate.