2010-02-06 10:47:04 +08:00
|
|
|
/*
|
|
|
|
* HW NMI watchdog support
|
|
|
|
*
|
|
|
|
* started by Don Zickus, Copyright (C) 2010 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* Arch specific calls to support NMI watchdog
|
|
|
|
*
|
|
|
|
* Bits copied from original nmi.c file
|
|
|
|
*
|
|
|
|
*/
|
2010-05-13 15:12:39 +08:00
|
|
|
#include <asm/apic.h>
|
x86: Fix trigger_all_cpu_backtrace() implementation
The following change fixes the x86 implementation of
trigger_all_cpu_backtrace(), which was previously (accidentally,
as far as I can tell) disabled to always return false as on
architectures that do not implement this function.
trigger_all_cpu_backtrace(), as defined in include/linux/nmi.h,
should call arch_trigger_all_cpu_backtrace() if available, or
return false if the underlying arch doesn't implement this
function.
x86 did provide a suitable arch_trigger_all_cpu_backtrace()
implementation, but it wasn't actually being used because it was
declared in asm/nmi.h, which linux/nmi.h doesn't include. Also,
linux/nmi.h couldn't easily be fixed by including asm/nmi.h,
because that file is not available on all architectures.
I am proposing to fix this by moving the x86 definition of
arch_trigger_all_cpu_backtrace() to asm/irq.h.
Tested via: echo l > /proc/sysrq-trigger
Before the change, this uses a fallback implementation which
shows backtraces on active CPUs (using
smp_call_function_interrupt() )
After the change, this shows NMI backtraces on all CPUs
Signed-off-by: Michel Lespinasse <walken@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/1370518875-1346-1-git-send-email-walken@google.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2013-06-06 19:41:15 +08:00
|
|
|
#include <asm/nmi.h>
|
2010-02-06 10:47:04 +08:00
|
|
|
|
|
|
|
#include <linux/cpumask.h>
|
2010-05-08 05:11:48 +08:00
|
|
|
#include <linux/kdebug.h>
|
|
|
|
#include <linux/notifier.h>
|
|
|
|
#include <linux/kprobes.h>
|
2010-02-06 10:47:04 +08:00
|
|
|
#include <linux/nmi.h>
|
|
|
|
#include <linux/module.h>
|
2011-03-25 22:20:14 +08:00
|
|
|
#include <linux/delay.h>
|
2010-02-06 10:47:04 +08:00
|
|
|
|
2010-11-13 00:22:23 +08:00
|
|
|
#ifdef CONFIG_HARDLOCKUP_DETECTOR
|
2011-05-23 13:10:23 +08:00
|
|
|
u64 hw_nmi_get_sample_period(int watchdog_thresh)
|
2010-02-13 06:19:19 +08:00
|
|
|
{
|
2011-05-23 13:10:23 +08:00
|
|
|
return (u64)(cpu_khz) * 1000 * watchdog_thresh;
|
2010-02-13 06:19:19 +08:00
|
|
|
}
|
2010-11-13 00:22:23 +08:00
|
|
|
#endif
|
2010-02-13 06:19:19 +08:00
|
|
|
|
2010-12-09 16:47:34 +08:00
|
|
|
#ifdef arch_trigger_all_cpu_backtrace
|
2015-07-11 04:47:36 +08:00
|
|
|
static void nmi_raise_cpu_backtrace(cpumask_t *mask)
|
2014-06-20 05:33:32 +08:00
|
|
|
{
|
2015-07-11 04:47:36 +08:00
|
|
|
apic->send_IPI_mask(mask, NMI_VECTOR);
|
2014-06-20 05:33:32 +08:00
|
|
|
}
|
|
|
|
|
2014-06-24 04:22:05 +08:00
|
|
|
void arch_trigger_all_cpu_backtrace(bool include_self)
|
2010-02-06 10:47:04 +08:00
|
|
|
{
|
2015-07-11 04:47:36 +08:00
|
|
|
nmi_trigger_all_cpu_backtrace(include_self, nmi_raise_cpu_backtrace);
|
2014-06-20 05:33:32 +08:00
|
|
|
}
|
|
|
|
|
2014-04-17 16:18:14 +08:00
|
|
|
static int
|
2011-10-01 03:06:21 +08:00
|
|
|
arch_trigger_all_cpu_backtrace_handler(unsigned int cmd, struct pt_regs *regs)
|
2010-05-08 05:11:48 +08:00
|
|
|
{
|
2015-07-11 04:47:36 +08:00
|
|
|
if (nmi_cpu_backtrace(regs))
|
2011-10-01 03:06:21 +08:00
|
|
|
return NMI_HANDLED;
|
2010-05-08 05:11:48 +08:00
|
|
|
|
2011-10-01 03:06:21 +08:00
|
|
|
return NMI_DONE;
|
2010-05-08 05:11:48 +08:00
|
|
|
}
|
2014-04-17 16:18:14 +08:00
|
|
|
NOKPROBE_SYMBOL(arch_trigger_all_cpu_backtrace_handler);
|
2010-05-08 05:11:48 +08:00
|
|
|
|
|
|
|
static int __init register_trigger_all_cpu_backtrace(void)
|
|
|
|
{
|
2011-10-01 03:06:21 +08:00
|
|
|
register_nmi_handler(NMI_LOCAL, arch_trigger_all_cpu_backtrace_handler,
|
|
|
|
0, "arch_bt");
|
2010-05-08 05:11:48 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
early_initcall(register_trigger_all_cpu_backtrace);
|
2010-02-19 10:56:52 +08:00
|
|
|
#endif
|