2 * linux/include/linux/nmi.h
7 #include <linux/sched.h>
10 #ifdef CONFIG_LOCKUP_DETECTOR
11 extern void touch_softlockup_watchdog_sched(void);
12 extern void touch_softlockup_watchdog(void);
13 extern void touch_softlockup_watchdog_sync(void);
14 extern void touch_all_softlockup_watchdogs(void);
15 extern unsigned int softlockup_panic;
16 extern unsigned int hardlockup_panic;
17 void lockup_detector_init(void);
19 static inline void touch_softlockup_watchdog_sched(void)
22 static inline void touch_softlockup_watchdog(void)
25 static inline void touch_softlockup_watchdog_sync(void)
28 static inline void touch_all_softlockup_watchdogs(void)
31 static inline void lockup_detector_init(void)
36 #ifdef CONFIG_DETECT_HUNG_TASK
37 void reset_hung_task_detector(void);
39 static inline void reset_hung_task_detector(void)
45 * The run state of the lockup detectors is controlled by the content of the
46 * 'watchdog_enabled' variable. Each lockup detector has its dedicated bit -
47 * bit 0 for the hard lockup detector and bit 1 for the soft lockup detector.
49 * 'watchdog_user_enabled', 'nmi_watchdog_enabled' and 'soft_watchdog_enabled'
50 * are variables that are only used as an 'interface' between the parameters
51 * in /proc/sys/kernel and the internal state bits in 'watchdog_enabled'. The
52 * 'watchdog_thresh' variable is handled differently because its value is not
53 * boolean, and the lockup detectors are 'suspended' while 'watchdog_thresh'
56 #define NMI_WATCHDOG_ENABLED_BIT 0
57 #define SOFT_WATCHDOG_ENABLED_BIT 1
58 #define NMI_WATCHDOG_ENABLED (1 << NMI_WATCHDOG_ENABLED_BIT)
59 #define SOFT_WATCHDOG_ENABLED (1 << SOFT_WATCHDOG_ENABLED_BIT)
62 * touch_nmi_watchdog - restart NMI watchdog timeout.
64 * If the architecture supports the NMI watchdog, touch_nmi_watchdog()
65 * may be used to reset the timeout - for code which intentionally
66 * disables interrupts for a long time. This call is stateless.
68 #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
70 extern void touch_nmi_watchdog(void);
72 static inline void touch_nmi_watchdog(void)
74 touch_softlockup_watchdog();
78 #if defined(CONFIG_HARDLOCKUP_DETECTOR)
79 extern void hardlockup_detector_disable(void);
81 static inline void hardlockup_detector_disable(void) {}
85 * Create trigger_all_cpu_backtrace() out of the arch-provided
86 * base function. Return whether such support was available,
87 * to allow calling code to fall back to some other mechanism:
89 #ifdef arch_trigger_cpumask_backtrace
90 static inline bool trigger_all_cpu_backtrace(void)
92 arch_trigger_cpumask_backtrace(cpu_online_mask, false);
96 static inline bool trigger_allbutself_cpu_backtrace(void)
98 arch_trigger_cpumask_backtrace(cpu_online_mask, true);
102 static inline bool trigger_cpumask_backtrace(struct cpumask *mask)
104 arch_trigger_cpumask_backtrace(mask, false);
108 static inline bool trigger_single_cpu_backtrace(int cpu)
110 arch_trigger_cpumask_backtrace(cpumask_of(cpu), false);
114 /* generic implementation */
115 void nmi_trigger_cpumask_backtrace(const cpumask_t *mask,
117 void (*raise)(cpumask_t *mask));
118 bool nmi_cpu_backtrace(struct pt_regs *regs);
121 static inline bool trigger_all_cpu_backtrace(void)
125 static inline bool trigger_allbutself_cpu_backtrace(void)
129 static inline bool trigger_cpumask_backtrace(struct cpumask *mask)
133 static inline bool trigger_single_cpu_backtrace(int cpu)
139 #ifdef CONFIG_LOCKUP_DETECTOR
140 u64 hw_nmi_get_sample_period(int watchdog_thresh);
141 extern int nmi_watchdog_enabled;
142 extern int soft_watchdog_enabled;
143 extern int watchdog_user_enabled;
144 extern int watchdog_thresh;
145 extern unsigned long watchdog_enabled;
146 extern unsigned long *watchdog_cpumask_bits;
147 extern atomic_t watchdog_park_in_progress;
149 extern int sysctl_softlockup_all_cpu_backtrace;
150 extern int sysctl_hardlockup_all_cpu_backtrace;
152 #define sysctl_softlockup_all_cpu_backtrace 0
153 #define sysctl_hardlockup_all_cpu_backtrace 0
155 extern bool is_hardlockup(void);
157 extern int proc_watchdog(struct ctl_table *, int ,
158 void __user *, size_t *, loff_t *);
159 extern int proc_nmi_watchdog(struct ctl_table *, int ,
160 void __user *, size_t *, loff_t *);
161 extern int proc_soft_watchdog(struct ctl_table *, int ,
162 void __user *, size_t *, loff_t *);
163 extern int proc_watchdog_thresh(struct ctl_table *, int ,
164 void __user *, size_t *, loff_t *);
165 extern int proc_watchdog_cpumask(struct ctl_table *, int,
166 void __user *, size_t *, loff_t *);
167 extern int lockup_detector_suspend(void);
168 extern void lockup_detector_resume(void);
170 static inline int lockup_detector_suspend(void)
175 static inline void lockup_detector_resume(void)
180 #ifdef CONFIG_HAVE_ACPI_APEI_NMI