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