2008-10-23 12:26:29 +07:00
|
|
|
#ifndef _ASM_X86_NMI_H
|
|
|
|
#define _ASM_X86_NMI_H
|
2008-03-20 00:25:36 +07:00
|
|
|
|
2014-02-04 00:02:09 +07:00
|
|
|
#include <linux/irq_work.h>
|
2008-03-20 00:25:36 +07:00
|
|
|
#include <linux/pm.h>
|
|
|
|
#include <asm/irq.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
|
x86, nmi_watchdog: Remove ARCH_HAS_NMI_WATCHDOG and rely on CONFIG_HARDLOCKUP_DETECTOR
The x86 arch has shifted its use of the nmi_watchdog from a
local implementation to the global one provide by
kernel/watchdog.c. This shift has caused a whole bunch of
compile problems under different config options. I attempt to
simplify things with the patch below.
In order to simplify things, I had to come to terms with the
meaning of two terms ARCH_HAS_NMI_WATCHDOG and
CONFIG_HARDLOCKUP_DETECTOR. Basically they mean the same thing,
the former on a local level and the latter on a global level.
With the old x86 nmi watchdog gone, there is no need to rely on
defining the ARCH_HAS_NMI_WATCHDOG variable because it doesn't
make sense any more. x86 will now use the global
implementation.
The changes below do a few things. First it changes the few
places that relied on ARCH_HAS_NMI_WATCHDOG to use
CONFIG_X86_LOCAL_APIC (the former was an alias for the latter
anyway, so nothing unusual here). Those pieces of code were
relying more on local apic functionality the nmi watchdog
functionality, so the change should make sense.
Second, I removed the x86 implementation of
touch_nmi_watchdog(). It isn't need now, instead x86 will rely
on kernel/watchdog.c's implementation.
Third, I removed the #define ARCH_HAS_NMI_WATCHDOG itself from
x86. And tweaked the include/linux/nmi.h file to tell users to
look for an externally defined touch_nmi_watchdog in the case of
ARCH_HAS_NMI_WATCHDOG _or_ CONFIG_HARDLOCKUP_DETECTOR. This
changes removes some of the ugliness in that file.
Finally, I added a Kconfig dependency for
CONFIG_HARDLOCKUP_DETECTOR that said you can't have
ARCH_HAS_NMI_WATCHDOG _and_ CONFIG_HARDLOCKUP_DETECTOR. You can
only have one nmi_watchdog.
Tested with
ARCH=i386: allnoconfig, defconfig, allyesconfig, (various broken
configs) ARCH=x86_64: allnoconfig, defconfig, allyesconfig,
(various broken configs)
Hopefully, after this patch I won't get any more compile broken
emails. :-)
v3:
changed a couple of 'linux/nmi.h' -> 'asm/nmi.h' to pick-up correct function
prototypes when CONFIG_HARDLOCKUP_DETECTOR is not set.
Signed-off-by: Don Zickus <dzickus@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: fweisbec@gmail.com
LKML-Reference: <1293044403-14117-1-git-send-email-dzickus@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-12-23 02:00:03 +07:00
|
|
|
#ifdef CONFIG_X86_LOCAL_APIC
|
2008-03-20 00:25:36 +07:00
|
|
|
|
|
|
|
extern int avail_to_resrv_perfctr_nmi_bit(unsigned int);
|
|
|
|
extern int reserve_perfctr_nmi(unsigned int);
|
|
|
|
extern void release_perfctr_nmi(unsigned int);
|
|
|
|
extern int reserve_evntsel_nmi(unsigned int);
|
|
|
|
extern void release_evntsel_nmi(unsigned int);
|
|
|
|
|
|
|
|
struct ctl_table;
|
2009-09-24 05:57:19 +07:00
|
|
|
extern int proc_nmi_enabled(struct ctl_table *, int ,
|
2008-03-20 00:25:36 +07:00
|
|
|
void __user *, size_t *, loff_t *);
|
|
|
|
extern int unknown_nmi_panic;
|
|
|
|
|
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 18:41:15 +07:00
|
|
|
#endif /* CONFIG_X86_LOCAL_APIC */
|
2008-03-20 00:25:36 +07:00
|
|
|
|
2011-10-01 02:06:20 +07:00
|
|
|
#define NMI_FLAG_FIRST 1
|
|
|
|
|
|
|
|
enum {
|
|
|
|
NMI_LOCAL=0,
|
|
|
|
NMI_UNKNOWN,
|
2012-03-30 03:11:16 +07:00
|
|
|
NMI_SERR,
|
|
|
|
NMI_IO_CHECK,
|
2011-10-01 02:06:20 +07:00
|
|
|
NMI_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
#define NMI_DONE 0
|
|
|
|
#define NMI_HANDLED 1
|
|
|
|
|
|
|
|
typedef int (*nmi_handler_t)(unsigned int, struct pt_regs *);
|
|
|
|
|
2012-03-30 03:11:17 +07:00
|
|
|
struct nmiaction {
|
|
|
|
struct list_head list;
|
|
|
|
nmi_handler_t handler;
|
2014-02-04 00:02:09 +07:00
|
|
|
u64 max_duration;
|
|
|
|
struct irq_work irq_work;
|
2012-04-28 03:40:55 +07:00
|
|
|
unsigned long flags;
|
2012-03-30 03:11:17 +07:00
|
|
|
const char *name;
|
|
|
|
};
|
|
|
|
|
2012-06-19 02:56:33 +07:00
|
|
|
#define register_nmi_handler(t, fn, fg, n, init...) \
|
2012-03-30 03:11:17 +07:00
|
|
|
({ \
|
2012-06-19 02:56:33 +07:00
|
|
|
static struct nmiaction init fn##_na = { \
|
2012-03-30 03:11:17 +07:00
|
|
|
.handler = (fn), \
|
|
|
|
.name = (n), \
|
|
|
|
.flags = (fg), \
|
|
|
|
}; \
|
2012-06-19 02:56:33 +07:00
|
|
|
__register_nmi_handler((t), &fn##_na); \
|
2012-06-06 21:05:42 +07:00
|
|
|
})
|
|
|
|
|
2012-03-30 03:11:17 +07:00
|
|
|
int __register_nmi_handler(unsigned int, struct nmiaction *);
|
2011-10-01 02:06:20 +07:00
|
|
|
|
|
|
|
void unregister_nmi_handler(unsigned int, const char *);
|
|
|
|
|
2008-03-20 00:25:36 +07:00
|
|
|
void stop_nmi(void);
|
|
|
|
void restart_nmi(void);
|
2011-10-01 02:06:22 +07:00
|
|
|
void local_touch_nmi(void);
|
2008-03-20 00:25:36 +07:00
|
|
|
|
2008-10-23 12:26:29 +07:00
|
|
|
#endif /* _ASM_X86_NMI_H */
|