Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * linux/include/linux/nmi.h | |
3 | */ | |
4 | #ifndef LINUX_NMI_H | |
5 | #define LINUX_NMI_H | |
6 | ||
9938406a | 7 | #include <linux/sched.h> |
1da177e4 | 8 | #include <asm/irq.h> |
f2e0cff8 NP |
9 | #if defined(CONFIG_HAVE_NMI_WATCHDOG) |
10 | #include <asm/nmi.h> | |
11 | #endif | |
1da177e4 | 12 | |
d151b27d | 13 | #ifdef CONFIG_LOCKUP_DETECTOR |
05a4a952 | 14 | void lockup_detector_init(void); |
6554fd8c | 15 | void lockup_detector_soft_poweroff(void); |
941154bd | 16 | void lockup_detector_cleanup(void); |
05a4a952 | 17 | #else |
6554fd8c TG |
18 | static inline void lockup_detector_init(void) { } |
19 | static inline void lockup_detector_soft_poweroff(void) { } | |
941154bd | 20 | static inline void lockup_detector_cleanup(void) { } |
05a4a952 NP |
21 | #endif |
22 | ||
23 | #ifdef CONFIG_SOFTLOCKUP_DETECTOR | |
d151b27d IM |
24 | extern void touch_softlockup_watchdog_sched(void); |
25 | extern void touch_softlockup_watchdog(void); | |
26 | extern void touch_softlockup_watchdog_sync(void); | |
27 | extern void touch_all_softlockup_watchdogs(void); | |
d151b27d | 28 | extern unsigned int softlockup_panic; |
05a4a952 | 29 | extern int soft_watchdog_enabled; |
d151b27d IM |
30 | #else |
31 | static inline void touch_softlockup_watchdog_sched(void) | |
32 | { | |
33 | } | |
34 | static inline void touch_softlockup_watchdog(void) | |
35 | { | |
36 | } | |
37 | static inline void touch_softlockup_watchdog_sync(void) | |
38 | { | |
39 | } | |
40 | static inline void touch_all_softlockup_watchdogs(void) | |
41 | { | |
42 | } | |
d151b27d IM |
43 | #endif |
44 | ||
45 | #ifdef CONFIG_DETECT_HUNG_TASK | |
46 | void reset_hung_task_detector(void); | |
47 | #else | |
48 | static inline void reset_hung_task_detector(void) | |
49 | { | |
50 | } | |
51 | #endif | |
52 | ||
249e52e3 BM |
53 | /* |
54 | * The run state of the lockup detectors is controlled by the content of the | |
55 | * 'watchdog_enabled' variable. Each lockup detector has its dedicated bit - | |
56 | * bit 0 for the hard lockup detector and bit 1 for the soft lockup detector. | |
57 | * | |
58 | * 'watchdog_user_enabled', 'nmi_watchdog_enabled' and 'soft_watchdog_enabled' | |
59 | * are variables that are only used as an 'interface' between the parameters | |
60 | * in /proc/sys/kernel and the internal state bits in 'watchdog_enabled'. The | |
61 | * 'watchdog_thresh' variable is handled differently because its value is not | |
62 | * boolean, and the lockup detectors are 'suspended' while 'watchdog_thresh' | |
63 | * is equal zero. | |
64 | */ | |
65 | #define NMI_WATCHDOG_ENABLED_BIT 0 | |
66 | #define SOFT_WATCHDOG_ENABLED_BIT 1 | |
67 | #define NMI_WATCHDOG_ENABLED (1 << NMI_WATCHDOG_ENABLED_BIT) | |
68 | #define SOFT_WATCHDOG_ENABLED (1 << SOFT_WATCHDOG_ENABLED_BIT) | |
69 | ||
f2e0cff8 NP |
70 | #if defined(CONFIG_HARDLOCKUP_DETECTOR) |
71 | extern void hardlockup_detector_disable(void); | |
05a4a952 | 72 | extern unsigned int hardlockup_panic; |
f2e0cff8 NP |
73 | #else |
74 | static inline void hardlockup_detector_disable(void) {} | |
75 | #endif | |
76 | ||
05a4a952 | 77 | #if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF) |
f2e0cff8 | 78 | extern void arch_touch_nmi_watchdog(void); |
d0b6e0a8 PZ |
79 | extern void hardlockup_detector_perf_stop(void); |
80 | extern void hardlockup_detector_perf_restart(void); | |
941154bd TG |
81 | extern void hardlockup_detector_perf_disable(void); |
82 | extern void hardlockup_detector_perf_cleanup(void); | |
f2e0cff8 | 83 | #else |
d0b6e0a8 PZ |
84 | static inline void hardlockup_detector_perf_stop(void) { } |
85 | static inline void hardlockup_detector_perf_restart(void) { } | |
941154bd TG |
86 | static inline void hardlockup_detector_perf_disable(void) { } |
87 | static inline void hardlockup_detector_perf_cleanup(void) { } | |
05a4a952 | 88 | #if !defined(CONFIG_HAVE_NMI_WATCHDOG) |
f2e0cff8 NP |
89 | static inline void arch_touch_nmi_watchdog(void) {} |
90 | #endif | |
05a4a952 | 91 | #endif |
f2e0cff8 | 92 | |
1da177e4 LT |
93 | /** |
94 | * touch_nmi_watchdog - restart NMI watchdog timeout. | |
95 | * | |
96 | * If the architecture supports the NMI watchdog, touch_nmi_watchdog() | |
97 | * may be used to reset the timeout - for code which intentionally | |
98 | * disables interrupts for a long time. This call is stateless. | |
99 | */ | |
5d0e600d IM |
100 | static inline void touch_nmi_watchdog(void) |
101 | { | |
f2e0cff8 | 102 | arch_touch_nmi_watchdog(); |
5d0e600d IM |
103 | touch_softlockup_watchdog(); |
104 | } | |
6e7458a6 | 105 | |
47cab6a7 IM |
106 | /* |
107 | * Create trigger_all_cpu_backtrace() out of the arch-provided | |
108 | * base function. Return whether such support was available, | |
109 | * to allow calling code to fall back to some other mechanism: | |
110 | */ | |
9a01c3ed | 111 | #ifdef arch_trigger_cpumask_backtrace |
47cab6a7 IM |
112 | static inline bool trigger_all_cpu_backtrace(void) |
113 | { | |
9a01c3ed | 114 | arch_trigger_cpumask_backtrace(cpu_online_mask, false); |
47cab6a7 IM |
115 | return true; |
116 | } | |
9a01c3ed | 117 | |
f3aca3d0 AT |
118 | static inline bool trigger_allbutself_cpu_backtrace(void) |
119 | { | |
9a01c3ed CM |
120 | arch_trigger_cpumask_backtrace(cpu_online_mask, true); |
121 | return true; | |
122 | } | |
123 | ||
124 | static inline bool trigger_cpumask_backtrace(struct cpumask *mask) | |
125 | { | |
126 | arch_trigger_cpumask_backtrace(mask, false); | |
127 | return true; | |
128 | } | |
129 | ||
130 | static inline bool trigger_single_cpu_backtrace(int cpu) | |
131 | { | |
132 | arch_trigger_cpumask_backtrace(cpumask_of(cpu), false); | |
f3aca3d0 AT |
133 | return true; |
134 | } | |
b2c0b2cb RK |
135 | |
136 | /* generic implementation */ | |
9a01c3ed CM |
137 | void nmi_trigger_cpumask_backtrace(const cpumask_t *mask, |
138 | bool exclude_self, | |
b2c0b2cb RK |
139 | void (*raise)(cpumask_t *mask)); |
140 | bool nmi_cpu_backtrace(struct pt_regs *regs); | |
141 | ||
47cab6a7 IM |
142 | #else |
143 | static inline bool trigger_all_cpu_backtrace(void) | |
144 | { | |
145 | return false; | |
146 | } | |
f3aca3d0 AT |
147 | static inline bool trigger_allbutself_cpu_backtrace(void) |
148 | { | |
149 | return false; | |
150 | } | |
9a01c3ed CM |
151 | static inline bool trigger_cpumask_backtrace(struct cpumask *mask) |
152 | { | |
153 | return false; | |
154 | } | |
155 | static inline bool trigger_single_cpu_backtrace(int cpu) | |
156 | { | |
157 | return false; | |
158 | } | |
bb81a09e AM |
159 | #endif |
160 | ||
05a4a952 | 161 | #ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF |
4eec42f3 | 162 | u64 hw_nmi_get_sample_period(int watchdog_thresh); |
05a4a952 NP |
163 | #endif |
164 | ||
165 | #ifdef CONFIG_LOCKUP_DETECTOR | |
84d56e66 | 166 | extern int nmi_watchdog_enabled; |
3c00ea82 | 167 | extern int watchdog_user_enabled; |
586692a5 | 168 | extern int watchdog_thresh; |
249e52e3 | 169 | extern unsigned long watchdog_enabled; |
05a4a952 | 170 | extern struct cpumask watchdog_cpumask; |
fe4ba3c3 | 171 | extern unsigned long *watchdog_cpumask_bits; |
249e52e3 | 172 | #ifdef CONFIG_SMP |
ed235875 | 173 | extern int sysctl_softlockup_all_cpu_backtrace; |
55537871 | 174 | extern int sysctl_hardlockup_all_cpu_backtrace; |
249e52e3 BM |
175 | #else |
176 | #define sysctl_softlockup_all_cpu_backtrace 0 | |
177 | #define sysctl_hardlockup_all_cpu_backtrace 0 | |
178 | #endif | |
7edaeb68 TG |
179 | |
180 | #if defined(CONFIG_HARDLOCKUP_CHECK_TIMESTAMP) && \ | |
181 | defined(CONFIG_HARDLOCKUP_DETECTOR) | |
182 | void watchdog_update_hrtimer_threshold(u64 period); | |
183 | #else | |
184 | static inline void watchdog_update_hrtimer_threshold(u64 period) { } | |
185 | #endif | |
186 | ||
249e52e3 | 187 | extern bool is_hardlockup(void); |
504d7cf1 | 188 | struct ctl_table; |
83a80a39 UO |
189 | extern int proc_watchdog(struct ctl_table *, int , |
190 | void __user *, size_t *, loff_t *); | |
191 | extern int proc_nmi_watchdog(struct ctl_table *, int , | |
192 | void __user *, size_t *, loff_t *); | |
193 | extern int proc_soft_watchdog(struct ctl_table *, int , | |
194 | void __user *, size_t *, loff_t *); | |
195 | extern int proc_watchdog_thresh(struct ctl_table *, int , | |
196 | void __user *, size_t *, loff_t *); | |
fe4ba3c3 CM |
197 | extern int proc_watchdog_cpumask(struct ctl_table *, int, |
198 | void __user *, size_t *, loff_t *); | |
84e478c6 DZ |
199 | #endif |
200 | ||
44a69f61 TN |
201 | #ifdef CONFIG_HAVE_ACPI_APEI_NMI |
202 | #include <asm/nmi.h> | |
203 | #endif | |
204 | ||
1da177e4 | 205 | #endif |