Pull percpu-dtc into release branch
[pandora-kernel.git] / arch / i386 / kernel / nmi.c
index 0fc4997..84c3497 100644 (file)
@@ -13,7 +13,6 @@
  *  Mikael Pettersson  : PM converted to driver model. Disable/enable API.
  */
 
-#include <linux/config.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
@@ -23,6 +22,8 @@
 #include <linux/percpu.h>
 #include <linux/dmi.h>
 #include <linux/kprobes.h>
+#include <linux/cpumask.h>
+#include <linux/kernel_stat.h>
 
 #include <asm/smp.h>
 #include <asm/nmi.h>
@@ -40,14 +41,17 @@ int nmi_watchdog_enabled;
  *   different subsystems this reservation system just tries to coordinate
  *   things a little
  */
-static DEFINE_PER_CPU(unsigned long, perfctr_nmi_owner);
-static DEFINE_PER_CPU(unsigned long, evntsel_nmi_owner[3]);
 
 /* this number is calculated from Intel's MSR_P4_CRU_ESCR5 register and it's
  * offset from MSR_P4_BSU_ESCR0.  It will be the max for all platforms (for now)
  */
 #define NMI_MAX_COUNTER_BITS 66
+#define NMI_MAX_COUNTER_LONGS BITS_TO_LONGS(NMI_MAX_COUNTER_BITS)
 
+static DEFINE_PER_CPU(unsigned long, perfctr_nmi_owner[NMI_MAX_COUNTER_LONGS]);
+static DEFINE_PER_CPU(unsigned long, evntsel_nmi_owner[NMI_MAX_COUNTER_LONGS]);
+
+static cpumask_t backtrace_mask = CPU_MASK_NONE;
 /* nmi_active:
  * >0: the lapic NMI watchdog is active, but can be disabled
  * <0: the lapic NMI watchdog has not been set up, and cannot
@@ -119,71 +123,137 @@ static inline unsigned int nmi_evntsel_msr_to_bit(unsigned int msr)
 /* checks for a bit availability (hack for oprofile) */
 int avail_to_resrv_perfctr_nmi_bit(unsigned int counter)
 {
+       int cpu;
        BUG_ON(counter > NMI_MAX_COUNTER_BITS);
-
-       return (!test_bit(counter, &__get_cpu_var(perfctr_nmi_owner)));
+       for_each_possible_cpu (cpu) {
+               if (test_bit(counter, &per_cpu(perfctr_nmi_owner, cpu)[0]))
+                       return 0;
+       }
+       return 1;
 }
 
 /* checks the an msr for availability */
 int avail_to_resrv_perfctr_nmi(unsigned int msr)
 {
        unsigned int counter;
+       int cpu;
 
        counter = nmi_perfctr_msr_to_bit(msr);
        BUG_ON(counter > NMI_MAX_COUNTER_BITS);
 
-       return (!test_bit(counter, &__get_cpu_var(perfctr_nmi_owner)));
+       for_each_possible_cpu (cpu) {
+               if (test_bit(counter, &per_cpu(perfctr_nmi_owner, cpu)[0]))
+                       return 0;
+       }
+       return 1;
 }
 
-int reserve_perfctr_nmi(unsigned int msr)
+static int __reserve_perfctr_nmi(int cpu, unsigned int msr)
 {
        unsigned int counter;
+       if (cpu < 0)
+               cpu = smp_processor_id();
 
        counter = nmi_perfctr_msr_to_bit(msr);
        BUG_ON(counter > NMI_MAX_COUNTER_BITS);
 
-       if (!test_and_set_bit(counter, &__get_cpu_var(perfctr_nmi_owner)))
+       if (!test_and_set_bit(counter, &per_cpu(perfctr_nmi_owner, cpu)[0]))
                return 1;
        return 0;
 }
 
-void release_perfctr_nmi(unsigned int msr)
+static void __release_perfctr_nmi(int cpu, unsigned int msr)
 {
        unsigned int counter;
+       if (cpu < 0)
+               cpu = smp_processor_id();
 
        counter = nmi_perfctr_msr_to_bit(msr);
        BUG_ON(counter > NMI_MAX_COUNTER_BITS);
 
-       clear_bit(counter, &__get_cpu_var(perfctr_nmi_owner));
+       clear_bit(counter, &per_cpu(perfctr_nmi_owner, cpu)[0]);
 }
 
-int reserve_evntsel_nmi(unsigned int msr)
+int reserve_perfctr_nmi(unsigned int msr)
+{
+       int cpu, i;
+       for_each_possible_cpu (cpu) {
+               if (!__reserve_perfctr_nmi(cpu, msr)) {
+                       for_each_possible_cpu (i) {
+                               if (i >= cpu)
+                                       break;
+                               __release_perfctr_nmi(i, msr);
+                       }
+                       return 0;
+               }
+       }
+       return 1;
+}
+
+void release_perfctr_nmi(unsigned int msr)
+{
+       int cpu;
+       for_each_possible_cpu (cpu) {
+               __release_perfctr_nmi(cpu, msr);
+       }
+}
+
+int __reserve_evntsel_nmi(int cpu, unsigned int msr)
 {
        unsigned int counter;
+       if (cpu < 0)
+               cpu = smp_processor_id();
 
        counter = nmi_evntsel_msr_to_bit(msr);
        BUG_ON(counter > NMI_MAX_COUNTER_BITS);
 
-       if (!test_and_set_bit(counter, &__get_cpu_var(evntsel_nmi_owner)[0]))
+       if (!test_and_set_bit(counter, &per_cpu(evntsel_nmi_owner, cpu)[0]))
                return 1;
        return 0;
 }
 
-void release_evntsel_nmi(unsigned int msr)
+static void __release_evntsel_nmi(int cpu, unsigned int msr)
 {
        unsigned int counter;
+       if (cpu < 0)
+               cpu = smp_processor_id();
 
        counter = nmi_evntsel_msr_to_bit(msr);
        BUG_ON(counter > NMI_MAX_COUNTER_BITS);
 
-       clear_bit(counter, &__get_cpu_var(evntsel_nmi_owner)[0]);
+       clear_bit(counter, &per_cpu(evntsel_nmi_owner, cpu)[0]);
+}
+
+int reserve_evntsel_nmi(unsigned int msr)
+{
+       int cpu, i;
+       for_each_possible_cpu (cpu) {
+               if (!__reserve_evntsel_nmi(cpu, msr)) {
+                       for_each_possible_cpu (i) {
+                               if (i >= cpu)
+                                       break;
+                               __release_evntsel_nmi(i, msr);
+                       }
+                       return 0;
+               }
+       }
+       return 1;
+}
+
+void release_evntsel_nmi(unsigned int msr)
+{
+       int cpu;
+       for_each_possible_cpu (cpu) {
+               __release_evntsel_nmi(cpu, msr);
+       }
 }
 
 static __cpuinit inline int nmi_known_cpu(void)
 {
        switch (boot_cpu_data.x86_vendor) {
        case X86_VENDOR_AMD:
-               return ((boot_cpu_data.x86 == 15) || (boot_cpu_data.x86 == 6));
+               return ((boot_cpu_data.x86 == 15) || (boot_cpu_data.x86 == 6)
+                       || (boot_cpu_data.x86 == 16));
        case X86_VENDOR_INTEL:
                if (cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON))
                        return 1;
@@ -193,6 +263,8 @@ static __cpuinit inline int nmi_known_cpu(void)
        return 0;
 }
 
+static int endflag __initdata = 0;
+
 #ifdef CONFIG_SMP
 /* The performance counters used by NMI_LOCAL_APIC don't trigger when
  * the CPU is idle. To make sure the NMI watchdog really ticks on all
@@ -200,7 +272,6 @@ static __cpuinit inline int nmi_known_cpu(void)
  */
 static __init void nmi_cpu_busy(void *data)
 {
-       volatile int *endflag = data;
        local_irq_enable_in_hardirq();
        /* Intentionally don't use cpu_relax here. This is
           to make sure that the performance counter really ticks,
@@ -208,25 +279,38 @@ static __init void nmi_cpu_busy(void *data)
           pause instruction. On a real HT machine this is fine because
           all other CPUs are busy with "useless" delay loops and don't
           care if they get somewhat less cycles. */
-       while (*endflag == 0)
-               barrier();
+       while (endflag == 0)
+               mb();
 }
 #endif
 
+static unsigned int adjust_for_32bit_ctr(unsigned int hz)
+{
+       u64 counter_val;
+       unsigned int retval = hz;
+
+       /*
+        * On Intel CPUs with P6/ARCH_PERFMON only 32 bits in the counter
+        * are writable, with higher bits sign extending from bit 31.
+        * So, we can only program the counter with 31 bit values and
+        * 32nd bit should be 1, for 33.. to be 1.
+        * Find the appropriate nmi_hz
+        */
+       counter_val = (u64)cpu_khz * 1000;
+       do_div(counter_val, retval);
+       if (counter_val > 0x7fffffffULL) {
+               u64 count = (u64)cpu_khz * 1000;
+               do_div(count, 0x7fffffffUL);
+               retval = count + 1;
+       }
+       return retval;
+}
+
 static int __init check_nmi_watchdog(void)
 {
-       volatile int endflag = 0;
        unsigned int *prev_nmi_count;
        int cpu;
 
-       /* Enable NMI watchdog for newer systems.
-           Actually it should be safe for most systems before 2004 too except
-          for some IBM systems that corrupt registers when NMI happens
-          during SMM. Unfortunately we don't have more exact information
-          on these and use this coarse check. */
-       if (nmi_watchdog == NMI_DEFAULT && dmi_get_year(DMI_BIOS_DATE) >= 2004)
-               nmi_watchdog = NMI_LOCAL_APIC;
-
        if ((nmi_watchdog == NMI_NONE) || (nmi_watchdog == NMI_DEFAULT))
                return 0;
 
@@ -245,7 +329,7 @@ static int __init check_nmi_watchdog(void)
        for_each_possible_cpu(cpu)
                prev_nmi_count[cpu] = per_cpu(irq_stat, cpu).__nmi_count;
        local_irq_enable();
-       mdelay((10*1000)/nmi_hz); // wait 10 ticks
+       mdelay((20*1000)/nmi_hz); // wait 20 ticks
 
        for_each_possible_cpu(cpu) {
 #ifdef CONFIG_SMP
@@ -279,18 +363,10 @@ static int __init check_nmi_watchdog(void)
                struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
 
                nmi_hz = 1;
-               /*
-                * On Intel CPUs with ARCH_PERFMON only 32 bits in the counter
-                * are writable, with higher bits sign extending from bit 31.
-                * So, we can only program the counter with 31 bit values and
-                * 32nd bit should be 1, for 33.. to be 1.
-                * Find the appropriate nmi_hz
-                */
-               if (wd->perfctr_msr == MSR_ARCH_PERFMON_PERFCTR0 &&
-                       ((u64)cpu_khz * 1000) > 0x7fffffffULL) {
-                       u64 count = (u64)cpu_khz * 1000;
-                       do_div(count, 0x7fffffffUL);
-                       nmi_hz = count + 1;
+
+               if (wd->perfctr_msr == MSR_P6_PERFCTR0 ||
+                   wd->perfctr_msr == MSR_ARCH_PERFMON_PERFCTR0) {
+                       nmi_hz = adjust_for_32bit_ctr(nmi_hz);
                }
        }
 
@@ -308,13 +384,7 @@ static int __init setup_nmi_watchdog(char *str)
 
        if ((nmi >= NMI_INVALID) || (nmi < NMI_NONE))
                return 0;
-       /*
-        * If any other x86 CPU has a local APIC, then
-        * please test the NMI stuff there and send me the
-        * missing bits. Right now Intel P6/P4 and AMD K7 only.
-        */
-       if ((nmi == NMI_LOCAL_APIC) && (nmi_known_cpu() == 0))
-               return 0;  /* no lapic support */
+
        nmi_watchdog = nmi;
        return 1;
 }
@@ -373,6 +443,34 @@ void enable_timer_nmi_watchdog(void)
        }
 }
 
+static void __acpi_nmi_disable(void *__unused)
+{
+       apic_write_around(APIC_LVT0, APIC_DM_NMI | APIC_LVT_MASKED);
+}
+
+/*
+ * Disable timer based NMIs on all CPUs:
+ */
+void acpi_nmi_disable(void)
+{
+       if (atomic_read(&nmi_active) && nmi_watchdog == NMI_IO_APIC)
+               on_each_cpu(__acpi_nmi_disable, NULL, 0, 1);
+}
+
+static void __acpi_nmi_enable(void *__unused)
+{
+       apic_write_around(APIC_LVT0, APIC_DM_NMI);
+}
+
+/*
+ * Enable timer based NMIs on all CPUs:
+ */
+void acpi_nmi_enable(void)
+{
+       if (atomic_read(&nmi_active) && nmi_watchdog == NMI_IO_APIC)
+               on_each_cpu(__acpi_nmi_enable, NULL, 0, 1);
+}
+
 #ifdef CONFIG_PM
 
 static int nmi_pm_active; /* nmi_active before suspend */
@@ -446,6 +544,17 @@ static void write_watchdog_counter(unsigned int perfctr_msr, const char *descr)
        wrmsrl(perfctr_msr, 0 - count);
 }
 
+static void write_watchdog_counter32(unsigned int perfctr_msr,
+               const char *descr)
+{
+       u64 count = (u64)cpu_khz * 1000;
+
+       do_div(count, nmi_hz);
+       if(descr)
+               Dprintk("setting %s to -0x%08Lx\n", descr, count);
+       wrmsr(perfctr_msr, (u32)(-count), 0);
+}
+
 /* Note that these events don't tick when the CPU idles. This means
    the frequency varies with CPU load. */
 
@@ -464,10 +573,10 @@ static int setup_k7_watchdog(void)
 
        perfctr_msr = MSR_K7_PERFCTR0;
        evntsel_msr = MSR_K7_EVNTSEL0;
-       if (!reserve_perfctr_nmi(perfctr_msr))
+       if (!__reserve_perfctr_nmi(-1, perfctr_msr))
                goto fail;
 
-       if (!reserve_evntsel_nmi(evntsel_msr))
+       if (!__reserve_evntsel_nmi(-1, evntsel_msr))
                goto fail1;
 
        wrmsrl(perfctr_msr, 0UL);
@@ -490,7 +599,7 @@ static int setup_k7_watchdog(void)
        wd->check_bit = 1ULL<<63;
        return 1;
 fail1:
-       release_perfctr_nmi(perfctr_msr);
+       __release_perfctr_nmi(-1, perfctr_msr);
 fail:
        return 0;
 }
@@ -501,8 +610,8 @@ static void stop_k7_watchdog(void)
 
        wrmsr(wd->evntsel_msr, 0, 0);
 
-       release_evntsel_nmi(wd->evntsel_msr);
-       release_perfctr_nmi(wd->perfctr_msr);
+       __release_evntsel_nmi(-1, wd->evntsel_msr);
+       __release_perfctr_nmi(-1, wd->perfctr_msr);
 }
 
 #define P6_EVNTSEL0_ENABLE     (1 << 22)
@@ -520,10 +629,10 @@ static int setup_p6_watchdog(void)
 
        perfctr_msr = MSR_P6_PERFCTR0;
        evntsel_msr = MSR_P6_EVNTSEL0;
-       if (!reserve_perfctr_nmi(perfctr_msr))
+       if (!__reserve_perfctr_nmi(-1, perfctr_msr))
                goto fail;
 
-       if (!reserve_evntsel_nmi(evntsel_msr))
+       if (!__reserve_evntsel_nmi(-1, evntsel_msr))
                goto fail1;
 
        wrmsrl(perfctr_msr, 0UL);
@@ -535,7 +644,8 @@ static int setup_p6_watchdog(void)
 
        /* setup the timer */
        wrmsr(evntsel_msr, evntsel, 0);
-       write_watchdog_counter(perfctr_msr, "P6_PERFCTR0");
+       nmi_hz = adjust_for_32bit_ctr(nmi_hz);
+       write_watchdog_counter32(perfctr_msr, "P6_PERFCTR0");
        apic_write(APIC_LVTPC, APIC_DM_NMI);
        evntsel |= P6_EVNTSEL0_ENABLE;
        wrmsr(evntsel_msr, evntsel, 0);
@@ -546,7 +656,7 @@ static int setup_p6_watchdog(void)
        wd->check_bit = 1ULL<<39;
        return 1;
 fail1:
-       release_perfctr_nmi(perfctr_msr);
+       __release_perfctr_nmi(-1, perfctr_msr);
 fail:
        return 0;
 }
@@ -557,8 +667,8 @@ static void stop_p6_watchdog(void)
 
        wrmsr(wd->evntsel_msr, 0, 0);
 
-       release_evntsel_nmi(wd->evntsel_msr);
-       release_perfctr_nmi(wd->perfctr_msr);
+       __release_evntsel_nmi(-1, wd->evntsel_msr);
+       __release_perfctr_nmi(-1, wd->perfctr_msr);
 }
 
 /* Note that these events don't tick when the CPU idles. This means
@@ -624,10 +734,10 @@ static int setup_p4_watchdog(void)
                cccr_val = P4_CCCR_OVF_PMI1 | P4_CCCR_ESCR_SELECT(4);
        }
 
-       if (!reserve_perfctr_nmi(perfctr_msr))
+       if (!__reserve_perfctr_nmi(-1, perfctr_msr))
                goto fail;
 
-       if (!reserve_evntsel_nmi(evntsel_msr))
+       if (!__reserve_evntsel_nmi(-1, evntsel_msr))
                goto fail1;
 
        evntsel = P4_ESCR_EVENT_SELECT(0x3F)
@@ -651,7 +761,7 @@ static int setup_p4_watchdog(void)
        wd->check_bit = 1ULL<<39;
        return 1;
 fail1:
-       release_perfctr_nmi(perfctr_msr);
+       __release_perfctr_nmi(-1, perfctr_msr);
 fail:
        return 0;
 }
@@ -663,8 +773,8 @@ static void stop_p4_watchdog(void)
        wrmsr(wd->cccr_msr, 0, 0);
        wrmsr(wd->evntsel_msr, 0, 0);
 
-       release_evntsel_nmi(wd->evntsel_msr);
-       release_perfctr_nmi(wd->perfctr_msr);
+       __release_evntsel_nmi(-1, wd->evntsel_msr);
+       __release_perfctr_nmi(-1, wd->perfctr_msr);
 }
 
 #define ARCH_PERFMON_NMI_EVENT_SEL     ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL
@@ -692,10 +802,10 @@ static int setup_intel_arch_watchdog(void)
        perfctr_msr = MSR_ARCH_PERFMON_PERFCTR0;
        evntsel_msr = MSR_ARCH_PERFMON_EVENTSEL0;
 
-       if (!reserve_perfctr_nmi(perfctr_msr))
+       if (!__reserve_perfctr_nmi(-1, perfctr_msr))
                goto fail;
 
-       if (!reserve_evntsel_nmi(evntsel_msr))
+       if (!__reserve_evntsel_nmi(-1, evntsel_msr))
                goto fail1;
 
        wrmsrl(perfctr_msr, 0UL);
@@ -708,7 +818,8 @@ static int setup_intel_arch_watchdog(void)
 
        /* setup the timer */
        wrmsr(evntsel_msr, evntsel, 0);
-       write_watchdog_counter(perfctr_msr, "INTEL_ARCH_PERFCTR0");
+       nmi_hz = adjust_for_32bit_ctr(nmi_hz);
+       write_watchdog_counter32(perfctr_msr, "INTEL_ARCH_PERFCTR0");
        apic_write(APIC_LVTPC, APIC_DM_NMI);
        evntsel |= ARCH_PERFMON_EVENTSEL0_ENABLE;
        wrmsr(evntsel_msr, evntsel, 0);
@@ -719,7 +830,7 @@ static int setup_intel_arch_watchdog(void)
        wd->check_bit = 1ULL << (eax.split.bit_width - 1);
        return 1;
 fail1:
-       release_perfctr_nmi(perfctr_msr);
+       __release_perfctr_nmi(-1, perfctr_msr);
 fail:
        return 0;
 }
@@ -742,8 +853,8 @@ static void stop_intel_arch_watchdog(void)
                return;
 
        wrmsr(wd->evntsel_msr, 0, 0);
-       release_evntsel_nmi(wd->evntsel_msr);
-       release_perfctr_nmi(wd->perfctr_msr);
+       __release_evntsel_nmi(-1, wd->evntsel_msr);
+       __release_perfctr_nmi(-1, wd->perfctr_msr);
 }
 
 void setup_apic_nmi_watchdog (void *unused)
@@ -766,7 +877,8 @@ void setup_apic_nmi_watchdog (void *unused)
        if (nmi_watchdog == NMI_LOCAL_APIC) {
                switch (boot_cpu_data.x86_vendor) {
                case X86_VENDOR_AMD:
-                       if (boot_cpu_data.x86 != 6 && boot_cpu_data.x86 != 15)
+                       if (boot_cpu_data.x86 != 6 && boot_cpu_data.x86 != 15 &&
+                               boot_cpu_data.x86 != 16)
                                return;
                        if (!setup_k7_watchdog())
                                return;
@@ -868,14 +980,16 @@ static unsigned int
 
 void touch_nmi_watchdog (void)
 {
-       int i;
+       if (nmi_watchdog > 0) {
+               unsigned cpu;
 
-       /*
-        * Just reset the alert counters, (other CPUs might be
-        * spinning on locks we hold):
-        */
-       for_each_possible_cpu(i)
-               alert_counter[i] = 0;
+               /*
+                * Just reset the alert counters, (other CPUs might be
+                * spinning on locks we hold):
+                */
+               for_each_present_cpu (cpu)
+                       alert_counter[cpu] = 0;
+       }
 
        /*
         * Tickle the softlockup detector too:
@@ -908,9 +1022,23 @@ __kprobes int nmi_watchdog_tick(struct pt_regs * regs, unsigned reason)
                touched = 1;
        }
 
-       sum = per_cpu(irq_stat, cpu).apic_timer_irqs;
+       if (cpu_isset(cpu, backtrace_mask)) {
+               static DEFINE_SPINLOCK(lock);   /* Serialise the printks */
 
-       /* if the apic timer isn't firing, this cpu isn't doing much */
+               spin_lock(&lock);
+               printk("NMI backtrace for cpu %d\n", cpu);
+               dump_stack();
+               spin_unlock(&lock);
+               cpu_clear(cpu, backtrace_mask);
+       }
+
+       /*
+        * Take the local apic timer and PIT/HPET into account. We don't
+        * know which one is active, when we have highres/dyntick on
+        */
+       sum = per_cpu(irq_stat, cpu).apic_timer_irqs + kstat_irqs(0);
+
+       /* if the none of the timers isn't firing, this cpu isn't doing much */
        if (!touched && last_irq_sums[cpu] == sum) {
                /*
                 * Ayiee, looks like this CPU is stuck ...
@@ -948,6 +1076,8 @@ __kprobes int nmi_watchdog_tick(struct pt_regs * regs, unsigned reason)
                                dummy &= ~P4_CCCR_OVF;
                                wrmsrl(wd->cccr_msr, dummy);
                                apic_write(APIC_LVTPC, APIC_DM_NMI);
+                               /* start the cycle over again */
+                               write_watchdog_counter(wd->perfctr_msr, NULL);
                        }
                        else if (wd->perfctr_msr == MSR_P6_PERFCTR0 ||
                                 wd->perfctr_msr == MSR_ARCH_PERFMON_PERFCTR0) {
@@ -956,9 +1086,12 @@ __kprobes int nmi_watchdog_tick(struct pt_regs * regs, unsigned reason)
                                 * other P6 variant.
                                 * ArchPerfom/Core Duo also needs this */
                                apic_write(APIC_LVTPC, APIC_DM_NMI);
+                               /* P6/ARCH_PERFMON has 32 bit counter write */
+                               write_watchdog_counter32(wd->perfctr_msr, NULL);
+                       } else {
+                               /* start the cycle over again */
+                               write_watchdog_counter(wd->perfctr_msr, NULL);
                        }
-                       /* start the cycle over again */
-                       write_watchdog_counter(wd->perfctr_msr, NULL);
                        rc = 1;
                } else if (nmi_watchdog == NMI_IO_APIC) {
                        /* don't know how to accurately check for this.
@@ -1034,6 +1167,19 @@ int proc_nmi_enabled(struct ctl_table *table, int write, struct file *file,
 
 #endif
 
+void __trigger_all_cpu_backtrace(void)
+{
+       int i;
+
+       backtrace_mask = cpu_online_map;
+       /* Wait for up to 10 seconds for all CPUs to do the backtrace */
+       for (i = 0; i < 10 * 1000; i++) {
+               if (cpus_empty(backtrace_mask))
+                       break;
+               mdelay(1);
+       }
+}
+
 EXPORT_SYMBOL(nmi_active);
 EXPORT_SYMBOL(nmi_watchdog);
 EXPORT_SYMBOL(avail_to_resrv_perfctr_nmi);