2 * linux/include/linux/nmi.h
7 #include <linux/sched.h>
11 * The run state of the lockup detectors is controlled by the content of the
12 * 'watchdog_enabled' variable. Each lockup detector has its dedicated bit -
13 * bit 0 for the hard lockup detector and bit 1 for the soft lockup detector.
15 * 'watchdog_user_enabled', 'nmi_watchdog_enabled' and 'soft_watchdog_enabled'
16 * are variables that are only used as an 'interface' between the parameters
17 * in /proc/sys/kernel and the internal state bits in 'watchdog_enabled'. The
18 * 'watchdog_thresh' variable is handled differently because its value is not
19 * boolean, and the lockup detectors are 'suspended' while 'watchdog_thresh'
22 #define NMI_WATCHDOG_ENABLED_BIT 0
23 #define SOFT_WATCHDOG_ENABLED_BIT 1
24 #define NMI_WATCHDOG_ENABLED (1 << NMI_WATCHDOG_ENABLED_BIT)
25 #define SOFT_WATCHDOG_ENABLED (1 << SOFT_WATCHDOG_ENABLED_BIT)
28 * touch_nmi_watchdog - restart NMI watchdog timeout.
30 * If the architecture supports the NMI watchdog, touch_nmi_watchdog()
31 * may be used to reset the timeout - for code which intentionally
32 * disables interrupts for a long time. This call is stateless.
34 #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
36 extern void touch_nmi_watchdog(void);
38 static inline void touch_nmi_watchdog(void)
40 touch_softlockup_watchdog();
44 #if defined(CONFIG_HARDLOCKUP_DETECTOR)
45 extern void hardlockup_detector_disable(void);
47 static inline void hardlockup_detector_disable(void) {}
51 * Create trigger_all_cpu_backtrace() out of the arch-provided
52 * base function. Return whether such support was available,
53 * to allow calling code to fall back to some other mechanism:
55 #ifdef arch_trigger_cpumask_backtrace
56 static inline bool trigger_all_cpu_backtrace(void)
58 arch_trigger_cpumask_backtrace(cpu_online_mask, false);
62 static inline bool trigger_allbutself_cpu_backtrace(void)
64 arch_trigger_cpumask_backtrace(cpu_online_mask, true);
68 static inline bool trigger_cpumask_backtrace(struct cpumask *mask)
70 arch_trigger_cpumask_backtrace(mask, false);
74 static inline bool trigger_single_cpu_backtrace(int cpu)
76 arch_trigger_cpumask_backtrace(cpumask_of(cpu), false);
80 /* generic implementation */
81 void nmi_trigger_cpumask_backtrace(const cpumask_t *mask,
83 void (*raise)(cpumask_t *mask));
84 bool nmi_cpu_backtrace(struct pt_regs *regs);
87 static inline bool trigger_all_cpu_backtrace(void)
91 static inline bool trigger_allbutself_cpu_backtrace(void)
95 static inline bool trigger_cpumask_backtrace(struct cpumask *mask)
99 static inline bool trigger_single_cpu_backtrace(int cpu)
105 #ifdef CONFIG_LOCKUP_DETECTOR
106 u64 hw_nmi_get_sample_period(int watchdog_thresh);
107 extern int nmi_watchdog_enabled;
108 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;
114 extern int sysctl_softlockup_all_cpu_backtrace;
115 extern int sysctl_hardlockup_all_cpu_backtrace;
117 #define sysctl_softlockup_all_cpu_backtrace 0
118 #define sysctl_hardlockup_all_cpu_backtrace 0
120 extern bool is_hardlockup(void);
122 extern int proc_watchdog(struct ctl_table *, int ,
123 void __user *, size_t *, loff_t *);
124 extern int proc_nmi_watchdog(struct ctl_table *, int ,
125 void __user *, size_t *, loff_t *);
126 extern int proc_soft_watchdog(struct ctl_table *, int ,
127 void __user *, size_t *, loff_t *);
128 extern int proc_watchdog_thresh(struct ctl_table *, int ,
129 void __user *, size_t *, loff_t *);
130 extern int proc_watchdog_cpumask(struct ctl_table *, int,
131 void __user *, size_t *, loff_t *);
132 extern int lockup_detector_suspend(void);
133 extern void lockup_detector_resume(void);
135 static inline int lockup_detector_suspend(void)
140 static inline void lockup_detector_resume(void)
145 #ifdef CONFIG_HAVE_ACPI_APEI_NMI