2 * HW NMI watchdog support
4 * started by Don Zickus, Copyright (C) 2010 Red Hat, Inc.
6 * Arch specific calls to support NMI watchdog
8 * Bits copied from original nmi.c file
13 #include <linux/cpumask.h>
14 #include <linux/kdebug.h>
15 #include <linux/notifier.h>
16 #include <linux/kprobes.h>
17 #include <linux/nmi.h>
18 #include <linux/module.h>
20 /* For reliability, we're prepared to waste bits here. */
21 static DECLARE_BITMAP(backtrace_mask, NR_CPUS) __read_mostly;
23 u64 hw_nmi_get_sample_period(void)
25 return (u64)(cpu_khz) * 1000 * 60;
28 #ifdef ARCH_HAS_NMI_WATCHDOG
29 void arch_trigger_all_cpu_backtrace(void)
33 cpumask_copy(to_cpumask(backtrace_mask), cpu_online_mask);
35 printk(KERN_INFO "sending NMI to all CPUs:\n");
36 apic->send_IPI_all(NMI_VECTOR);
38 /* Wait for up to 10 seconds for all CPUs to do the backtrace */
39 for (i = 0; i < 10 * 1000; i++) {
40 if (cpumask_empty(to_cpumask(backtrace_mask)))
47 arch_trigger_all_cpu_backtrace_handler(struct notifier_block *self,
48 unsigned long cmd, void *__args)
50 struct die_args *args = __args;
52 int cpu = smp_processor_id();
65 if (cpumask_test_cpu(cpu, to_cpumask(backtrace_mask))) {
66 static arch_spinlock_t lock = __ARCH_SPIN_LOCK_UNLOCKED;
68 arch_spin_lock(&lock);
69 printk(KERN_WARNING "NMI backtrace for cpu %d\n", cpu);
72 arch_spin_unlock(&lock);
73 cpumask_clear_cpu(cpu, to_cpumask(backtrace_mask));
80 static __read_mostly struct notifier_block backtrace_notifier = {
81 .notifier_call = arch_trigger_all_cpu_backtrace_handler,
86 static int __init register_trigger_all_cpu_backtrace(void)
88 register_die_notifier(&backtrace_notifier);
91 early_initcall(register_trigger_all_cpu_backtrace);
94 /* STUB calls to mimic old nmi_watchdog behaviour */
95 #if defined(CONFIG_X86_LOCAL_APIC)
96 unsigned int nmi_watchdog = NMI_NONE;
97 EXPORT_SYMBOL(nmi_watchdog);
98 void acpi_nmi_enable(void) { return; }
99 void acpi_nmi_disable(void) { return; }
101 atomic_t nmi_active = ATOMIC_INIT(0); /* oprofile uses this */
102 EXPORT_SYMBOL(nmi_active);
103 int unknown_nmi_panic;
104 void cpu_nmi_set_wd_enabled(void) { return; }
105 void stop_apic_nmi_watchdog(void *unused) { return; }
106 void setup_apic_nmi_watchdog(void *unused) { return; }
107 int __init check_nmi_watchdog(void) { return 0; }