nmi.h 4.2 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6
/*
 *  linux/include/linux/nmi.h
 */
#ifndef LINUX_NMI_H
#define LINUX_NMI_H

7
#include <linux/sched.h>
L
Linus Torvalds 已提交
8 9
#include <asm/irq.h>

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/*
 * The run state of the lockup detectors is controlled by the content of the
 * 'watchdog_enabled' variable. Each lockup detector has its dedicated bit -
 * bit 0 for the hard lockup detector and bit 1 for the soft lockup detector.
 *
 * 'watchdog_user_enabled', 'nmi_watchdog_enabled' and 'soft_watchdog_enabled'
 * are variables that are only used as an 'interface' between the parameters
 * in /proc/sys/kernel and the internal state bits in 'watchdog_enabled'. The
 * 'watchdog_thresh' variable is handled differently because its value is not
 * boolean, and the lockup detectors are 'suspended' while 'watchdog_thresh'
 * is equal zero.
 */
#define NMI_WATCHDOG_ENABLED_BIT   0
#define SOFT_WATCHDOG_ENABLED_BIT  1
#define NMI_WATCHDOG_ENABLED      (1 << NMI_WATCHDOG_ENABLED_BIT)
#define SOFT_WATCHDOG_ENABLED     (1 << SOFT_WATCHDOG_ENABLED_BIT)

L
Linus Torvalds 已提交
27 28 29 30 31 32 33
/**
 * touch_nmi_watchdog - restart NMI watchdog timeout.
 * 
 * If the architecture supports the NMI watchdog, touch_nmi_watchdog()
 * may be used to reset the timeout - for code which intentionally
 * disables interrupts for a long time. This call is stateless.
 */
34
#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
A
Andrew Morton 已提交
35
#include <asm/nmi.h>
36 37
extern void touch_nmi_watchdog(void);
#else
38 39 40 41
static inline void touch_nmi_watchdog(void)
{
	touch_softlockup_watchdog();
}
42
#endif
L
Linus Torvalds 已提交
43

44
#if defined(CONFIG_HARDLOCKUP_DETECTOR)
45
extern void hardlockup_detector_disable(void);
46
#else
47
static inline void hardlockup_detector_disable(void) {}
48 49
#endif

50 51 52 53 54
/*
 * Create trigger_all_cpu_backtrace() out of the arch-provided
 * base function. Return whether such support was available,
 * to allow calling code to fall back to some other mechanism:
 */
55
#ifdef arch_trigger_cpumask_backtrace
56 57
static inline bool trigger_all_cpu_backtrace(void)
{
58
	arch_trigger_cpumask_backtrace(cpu_online_mask, false);
59 60
	return true;
}
61

62 63
static inline bool trigger_allbutself_cpu_backtrace(void)
{
64 65 66 67 68 69 70 71 72 73 74 75 76
	arch_trigger_cpumask_backtrace(cpu_online_mask, true);
	return true;
}

static inline bool trigger_cpumask_backtrace(struct cpumask *mask)
{
	arch_trigger_cpumask_backtrace(mask, false);
	return true;
}

static inline bool trigger_single_cpu_backtrace(int cpu)
{
	arch_trigger_cpumask_backtrace(cpumask_of(cpu), false);
77 78
	return true;
}
79 80

/* generic implementation */
81 82
void nmi_trigger_cpumask_backtrace(const cpumask_t *mask,
				   bool exclude_self,
83 84 85
				   void (*raise)(cpumask_t *mask));
bool nmi_cpu_backtrace(struct pt_regs *regs);

86 87 88 89 90
#else
static inline bool trigger_all_cpu_backtrace(void)
{
	return false;
}
91 92 93 94
static inline bool trigger_allbutself_cpu_backtrace(void)
{
	return false;
}
95 96 97 98 99 100 101 102
static inline bool trigger_cpumask_backtrace(struct cpumask *mask)
{
	return false;
}
static inline bool trigger_single_cpu_backtrace(int cpu)
{
	return false;
}
A
Andrew Morton 已提交
103 104
#endif

105
#ifdef CONFIG_LOCKUP_DETECTOR
106
u64 hw_nmi_get_sample_period(int watchdog_thresh);
107 108
extern int nmi_watchdog_enabled;
extern int soft_watchdog_enabled;
109
extern int watchdog_user_enabled;
110
extern int watchdog_thresh;
111
extern unsigned long watchdog_enabled;
112
extern unsigned long *watchdog_cpumask_bits;
113
extern atomic_t watchdog_park_in_progress;
114
#ifdef CONFIG_SMP
115
extern int sysctl_softlockup_all_cpu_backtrace;
116
extern int sysctl_hardlockup_all_cpu_backtrace;
117 118 119 120 121
#else
#define sysctl_softlockup_all_cpu_backtrace 0
#define sysctl_hardlockup_all_cpu_backtrace 0
#endif
extern bool is_hardlockup(void);
122
struct ctl_table;
123 124 125 126 127 128 129 130
extern int proc_watchdog(struct ctl_table *, int ,
			 void __user *, size_t *, loff_t *);
extern int proc_nmi_watchdog(struct ctl_table *, int ,
			     void __user *, size_t *, loff_t *);
extern int proc_soft_watchdog(struct ctl_table *, int ,
			      void __user *, size_t *, loff_t *);
extern int proc_watchdog_thresh(struct ctl_table *, int ,
				void __user *, size_t *, loff_t *);
131 132
extern int proc_watchdog_cpumask(struct ctl_table *, int,
				 void __user *, size_t *, loff_t *);
133 134
extern int lockup_detector_suspend(void);
extern void lockup_detector_resume(void);
135
#else
136
static inline int lockup_detector_suspend(void)
137 138 139 140
{
	return 0;
}

141
static inline void lockup_detector_resume(void)
142 143
{
}
144 145
#endif

146 147 148 149
#ifdef CONFIG_HAVE_ACPI_APEI_NMI
#include <asm/nmi.h>
#endif

L
Linus Torvalds 已提交
150
#endif