Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 205392
b: refs/heads/master
c: 7cbb7e7
h: refs/heads/master
v: v3
  • Loading branch information
Don Zickus authored and Frederic Weisbecker committed May 12, 2010
1 parent 9269a48 commit 70bdfaf
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f69bcf60c3f17aa367e16eef7bc6ab001ea6d58a
refs/heads/master: 7cbb7e7fa46f6e5229438ac9e4a5c72ec0d53e0b
65 changes: 51 additions & 14 deletions trunk/arch/x86/kernel/apic/hw_nmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#include <linux/cpumask.h>
#include <linux/kernel_stat.h>
#include <asm/mce.h>
#include <linux/kdebug.h>
#include <linux/notifier.h>
#include <linux/kprobes.h>


#include <linux/nmi.h>
#include <linux/module.h>
Expand Down Expand Up @@ -54,20 +58,6 @@ int hw_nmi_is_cpu_stuck(struct pt_regs *regs)
unsigned int sum;
int cpu = smp_processor_id();

/* FIXME: cheap hack for this check, probably should get its own
* die_notifier handler
*/
if (cpumask_test_cpu(cpu, to_cpumask(backtrace_mask))) {
static DEFINE_SPINLOCK(lock); /* Serialise the printks */

spin_lock(&lock);
printk(KERN_WARNING "NMI backtrace for cpu %d\n", cpu);
show_regs(regs);
dump_stack();
spin_unlock(&lock);
cpumask_clear_cpu(cpu, to_cpumask(backtrace_mask));
}

/* if we are doing an mce, just assume the cpu is not stuck */
/* Could check oops_in_progress here too, but it's safer not to */
if (mce_in_progress())
Expand Down Expand Up @@ -109,6 +99,53 @@ void arch_trigger_all_cpu_backtrace(void)
mdelay(1);
}
}

static int __kprobes
arch_trigger_all_cpu_backtrace_handler(struct notifier_block *self,
unsigned long cmd, void *__args)
{
struct die_args *args = __args;
struct pt_regs *regs;
int cpu = smp_processor_id();

switch (cmd) {
case DIE_NMI:
case DIE_NMI_IPI:
break;

default:
return NOTIFY_DONE;
}

regs = args->regs;

if (cpumask_test_cpu(cpu, to_cpumask(backtrace_mask))) {
static arch_spinlock_t lock = __ARCH_SPIN_LOCK_UNLOCKED;

arch_spin_lock(&lock);
printk(KERN_WARNING "NMI backtrace for cpu %d\n", cpu);
show_regs(regs);
dump_stack();
arch_spin_unlock(&lock);
cpumask_clear_cpu(cpu, to_cpumask(backtrace_mask));
return NOTIFY_STOP;
}

return NOTIFY_DONE;
}

static __read_mostly struct notifier_block backtrace_notifier = {
.notifier_call = arch_trigger_all_cpu_backtrace_handler,
.next = NULL,
.priority = 1
};

static int __init register_trigger_all_cpu_backtrace(void)
{
register_die_notifier(&backtrace_notifier);
return 0;
}
early_initcall(register_trigger_all_cpu_backtrace);
#endif

/* STUB calls to mimic old nmi_watchdog behaviour */
Expand Down

0 comments on commit 70bdfaf

Please sign in to comment.