]>
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 | ||
249e52e3 BM |
10 | /* |
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. | |
14 | * | |
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' | |
20 | * is equal zero. | |
21 | */ | |
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) | |
26 | ||
1da177e4 LT |
27 | /** |
28 | * touch_nmi_watchdog - restart NMI watchdog timeout. | |
29 | * | |
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. | |
33 | */ | |
d314d74c | 34 | #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR) |
bb81a09e | 35 | #include <asm/nmi.h> |
96a84c20 DZ |
36 | extern void touch_nmi_watchdog(void); |
37 | #else | |
5d0e600d IM |
38 | static inline void touch_nmi_watchdog(void) |
39 | { | |
40 | touch_softlockup_watchdog(); | |
41 | } | |
96a84c20 | 42 | #endif |
1da177e4 | 43 | |
6e7458a6 | 44 | #if defined(CONFIG_HARDLOCKUP_DETECTOR) |
692297d8 | 45 | extern void hardlockup_detector_disable(void); |
6e7458a6 | 46 | #else |
aacfbe6a | 47 | static inline void hardlockup_detector_disable(void) {} |
6e7458a6 UO |
48 | #endif |
49 | ||
47cab6a7 IM |
50 | /* |
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: | |
54 | */ | |
9a01c3ed | 55 | #ifdef arch_trigger_cpumask_backtrace |
47cab6a7 IM |
56 | static inline bool trigger_all_cpu_backtrace(void) |
57 | { | |
9a01c3ed | 58 | arch_trigger_cpumask_backtrace(cpu_online_mask, false); |
47cab6a7 IM |
59 | return true; |
60 | } | |
9a01c3ed | 61 | |
f3aca3d0 AT |
62 | static inline bool trigger_allbutself_cpu_backtrace(void) |
63 | { | |
9a01c3ed CM |
64 | arch_trigger_cpumask_backtrace(cpu_online_mask, true); |
65 | return true; | |
66 | } | |
67 | ||
68 | static inline bool trigger_cpumask_backtrace(struct cpumask *mask) | |
69 | { | |
70 | arch_trigger_cpumask_backtrace(mask, false); | |
71 | return true; | |
72 | } | |
73 | ||
74 | static inline bool trigger_single_cpu_backtrace(int cpu) | |
75 | { | |
76 | arch_trigger_cpumask_backtrace(cpumask_of(cpu), false); | |
f3aca3d0 AT |
77 | return true; |
78 | } | |
b2c0b2cb RK |
79 | |
80 | /* generic implementation */ | |
9a01c3ed CM |
81 | void nmi_trigger_cpumask_backtrace(const cpumask_t *mask, |
82 | bool exclude_self, | |
b2c0b2cb RK |
83 | void (*raise)(cpumask_t *mask)); |
84 | bool nmi_cpu_backtrace(struct pt_regs *regs); | |
85 | ||
47cab6a7 IM |
86 | #else |
87 | static inline bool trigger_all_cpu_backtrace(void) | |
88 | { | |
89 | return false; | |
90 | } | |
f3aca3d0 AT |
91 | static inline bool trigger_allbutself_cpu_backtrace(void) |
92 | { | |
93 | return false; | |
94 | } | |
9a01c3ed CM |
95 | static inline bool trigger_cpumask_backtrace(struct cpumask *mask) |
96 | { | |
97 | return false; | |
98 | } | |
99 | static inline bool trigger_single_cpu_backtrace(int cpu) | |
100 | { | |
101 | return false; | |
102 | } | |
bb81a09e AM |
103 | #endif |
104 | ||
58687acb | 105 | #ifdef CONFIG_LOCKUP_DETECTOR |
4eec42f3 | 106 | u64 hw_nmi_get_sample_period(int watchdog_thresh); |
84d56e66 UO |
107 | extern int nmi_watchdog_enabled; |
108 | extern int soft_watchdog_enabled; | |
3c00ea82 | 109 | extern int watchdog_user_enabled; |
586692a5 | 110 | extern int watchdog_thresh; |
249e52e3 | 111 | extern unsigned long watchdog_enabled; |
fe4ba3c3 | 112 | extern unsigned long *watchdog_cpumask_bits; |
b94f5118 | 113 | extern atomic_t watchdog_park_in_progress; |
249e52e3 | 114 | #ifdef CONFIG_SMP |
ed235875 | 115 | extern int sysctl_softlockup_all_cpu_backtrace; |
55537871 | 116 | extern int sysctl_hardlockup_all_cpu_backtrace; |
249e52e3 BM |
117 | #else |
118 | #define sysctl_softlockup_all_cpu_backtrace 0 | |
119 | #define sysctl_hardlockup_all_cpu_backtrace 0 | |
120 | #endif | |
121 | extern bool is_hardlockup(void); | |
504d7cf1 | 122 | struct ctl_table; |
83a80a39 UO |
123 | extern int proc_watchdog(struct ctl_table *, int , |
124 | void __user *, size_t *, loff_t *); | |
125 | extern int proc_nmi_watchdog(struct ctl_table *, int , | |
126 | void __user *, size_t *, loff_t *); | |
127 | extern int proc_soft_watchdog(struct ctl_table *, int , | |
128 | void __user *, size_t *, loff_t *); | |
129 | extern int proc_watchdog_thresh(struct ctl_table *, int , | |
130 | void __user *, size_t *, loff_t *); | |
fe4ba3c3 CM |
131 | extern int proc_watchdog_cpumask(struct ctl_table *, int, |
132 | void __user *, size_t *, loff_t *); | |
ec6a9066 UO |
133 | extern int lockup_detector_suspend(void); |
134 | extern void lockup_detector_resume(void); | |
999bbe49 | 135 | #else |
ec6a9066 | 136 | static inline int lockup_detector_suspend(void) |
999bbe49 UO |
137 | { |
138 | return 0; | |
139 | } | |
140 | ||
ec6a9066 | 141 | static inline void lockup_detector_resume(void) |
999bbe49 UO |
142 | { |
143 | } | |
84e478c6 DZ |
144 | #endif |
145 | ||
44a69f61 TN |
146 | #ifdef CONFIG_HAVE_ACPI_APEI_NMI |
147 | #include <asm/nmi.h> | |
148 | #endif | |
149 | ||
1da177e4 | 150 | #endif |