1 /* SPDX-License-Identifier: GPL-2.0 */ << 2 /* 1 /* 3 * linux/include/linux/nmi.h 2 * linux/include/linux/nmi.h 4 */ 3 */ 5 #ifndef LINUX_NMI_H 4 #ifndef LINUX_NMI_H 6 #define LINUX_NMI_H 5 #define LINUX_NMI_H 7 6 8 #include <linux/sched.h> << 9 #include <asm/irq.h> 7 #include <asm/irq.h> 10 8 11 /* Arch specific watchdogs might need to share << 12 #if defined(CONFIG_HARDLOCKUP_DETECTOR_ARCH) | << 13 #include <asm/nmi.h> << 14 #endif << 15 << 16 #ifdef CONFIG_LOCKUP_DETECTOR << 17 void lockup_detector_init(void); << 18 void lockup_detector_retry_init(void); << 19 void lockup_detector_soft_poweroff(void); << 20 void lockup_detector_cleanup(void); << 21 << 22 extern int watchdog_user_enabled; << 23 extern int watchdog_thresh; << 24 extern unsigned long watchdog_enabled; << 25 << 26 extern struct cpumask watchdog_cpumask; << 27 extern unsigned long *watchdog_cpumask_bits; << 28 #ifdef CONFIG_SMP << 29 extern int sysctl_softlockup_all_cpu_backtrace << 30 extern int sysctl_hardlockup_all_cpu_backtrace << 31 #else << 32 #define sysctl_softlockup_all_cpu_backtrace 0 << 33 #define sysctl_hardlockup_all_cpu_backtrace 0 << 34 #endif /* !CONFIG_SMP */ << 35 << 36 #else /* CONFIG_LOCKUP_DETECTOR */ << 37 static inline void lockup_detector_init(void) << 38 static inline void lockup_detector_retry_init( << 39 static inline void lockup_detector_soft_powero << 40 static inline void lockup_detector_cleanup(voi << 41 #endif /* !CONFIG_LOCKUP_DETECTOR */ << 42 << 43 #ifdef CONFIG_SOFTLOCKUP_DETECTOR << 44 extern void touch_softlockup_watchdog_sched(vo << 45 extern void touch_softlockup_watchdog(void); << 46 extern void touch_softlockup_watchdog_sync(voi << 47 extern void touch_all_softlockup_watchdogs(voi << 48 extern unsigned int softlockup_panic; << 49 << 50 extern int lockup_detector_online_cpu(unsigned << 51 extern int lockup_detector_offline_cpu(unsigne << 52 #else /* CONFIG_SOFTLOCKUP_DETECTOR */ << 53 static inline void touch_softlockup_watchdog_s << 54 static inline void touch_softlockup_watchdog(v << 55 static inline void touch_softlockup_watchdog_s << 56 static inline void touch_all_softlockup_watchd << 57 << 58 #define lockup_detector_online_cpu NULL << 59 #define lockup_detector_offline_cpu NULL << 60 #endif /* CONFIG_SOFTLOCKUP_DETECTOR */ << 61 << 62 #ifdef CONFIG_DETECT_HUNG_TASK << 63 void reset_hung_task_detector(void); << 64 #else << 65 static inline void reset_hung_task_detector(vo << 66 #endif << 67 << 68 /* << 69 * The run state of the lockup detectors is co << 70 * 'watchdog_enabled' variable. Each lockup de << 71 * bit 0 for the hard lockup detector and bit << 72 * << 73 * 'watchdog_user_enabled', 'watchdog_hardlock << 74 * 'watchdog_softlockup_user_enabled' are vari << 75 * 'interface' between the parameters in /proc << 76 * state bits in 'watchdog_enabled'. The 'watc << 77 * handled differently because its value is no << 78 * detectors are 'suspended' while 'watchdog_t << 79 */ << 80 #define WATCHDOG_HARDLOCKUP_ENABLED_BIT 0 << 81 #define WATCHDOG_SOFTOCKUP_ENABLED_BIT 1 << 82 #define WATCHDOG_HARDLOCKUP_ENABLED (1 << << 83 #define WATCHDOG_SOFTOCKUP_ENABLED (1 << << 84 << 85 #if defined(CONFIG_HARDLOCKUP_DETECTOR) << 86 extern void hardlockup_detector_disable(void); << 87 extern unsigned int hardlockup_panic; << 88 #else << 89 static inline void hardlockup_detector_disable << 90 #endif << 91 << 92 /* Sparc64 has special implemetantion that is << 93 #if defined(CONFIG_HARDLOCKUP_DETECTOR) || def << 94 void arch_touch_nmi_watchdog(void); << 95 #else << 96 static inline void arch_touch_nmi_watchdog(voi << 97 #endif << 98 << 99 #if defined(CONFIG_HARDLOCKUP_DETECTOR_COUNTS_ << 100 void watchdog_hardlockup_touch_cpu(unsigned in << 101 void watchdog_hardlockup_check(unsigned int cp << 102 #endif << 103 << 104 #if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF) << 105 extern void hardlockup_detector_perf_stop(void << 106 extern void hardlockup_detector_perf_restart(v << 107 extern void hardlockup_detector_perf_cleanup(v << 108 extern void hardlockup_config_perf_event(const << 109 #else << 110 static inline void hardlockup_detector_perf_st << 111 static inline void hardlockup_detector_perf_re << 112 static inline void hardlockup_detector_perf_cl << 113 static inline void hardlockup_config_perf_even << 114 #endif << 115 << 116 void watchdog_hardlockup_stop(void); << 117 void watchdog_hardlockup_start(void); << 118 int watchdog_hardlockup_probe(void); << 119 void watchdog_hardlockup_enable(unsigned int c << 120 void watchdog_hardlockup_disable(unsigned int << 121 << 122 void lockup_detector_reconfigure(void); << 123 << 124 #ifdef CONFIG_HARDLOCKUP_DETECTOR_BUDDY << 125 void watchdog_buddy_check_hardlockup(int hrtim << 126 #else << 127 static inline void watchdog_buddy_check_hardlo << 128 #endif << 129 << 130 /** 9 /** 131 * touch_nmi_watchdog - manually reset the har !! 10 * touch_nmi_watchdog - restart NMI watchdog timeout. 132 * !! 11 * 133 * If we support detecting hardlockups, touch_ !! 12 * If the architecture supports the NMI watchdog, touch_nmi_watchdog() 134 * used to pet the watchdog (reset the timeout !! 13 * may be used to reset the timeout - for code which intentionally 135 * intentionally disables interrupts for a lon !! 14 * disables interrupts for a long time. This call is stateless. 136 * << 137 * Though this function has "nmi" in the name, << 138 * not be backed by NMIs. This function will l << 139 * touch_hardlockup_watchdog() in the future. << 140 */ 15 */ 141 static inline void touch_nmi_watchdog(void) !! 16 #ifdef ARCH_HAS_NMI_WATCHDOG 142 { !! 17 extern void touch_nmi_watchdog(void); 143 /* << 144 * Pass on to the hardlockup detector << 145 * the hardlockup detector may not be << 146 * and the arch_touch_nmi_watchdog() f << 147 * in the future. << 148 */ << 149 arch_touch_nmi_watchdog(); << 150 << 151 touch_softlockup_watchdog(); << 152 } << 153 << 154 /* << 155 * Create trigger_all_cpu_backtrace() out of t << 156 * base function. Return whether such support << 157 * to allow calling code to fall back to some << 158 */ << 159 #ifdef arch_trigger_cpumask_backtrace << 160 static inline bool trigger_all_cpu_backtrace(v << 161 { << 162 arch_trigger_cpumask_backtrace(cpu_onl << 163 return true; << 164 } << 165 << 166 static inline bool trigger_allbutcpu_cpu_backt << 167 { << 168 arch_trigger_cpumask_backtrace(cpu_onl << 169 return true; << 170 } << 171 << 172 static inline bool trigger_cpumask_backtrace(s << 173 { << 174 arch_trigger_cpumask_backtrace(mask, - << 175 return true; << 176 } << 177 << 178 static inline bool trigger_single_cpu_backtrac << 179 { << 180 arch_trigger_cpumask_backtrace(cpumask << 181 return true; << 182 } << 183 << 184 /* generic implementation */ << 185 void nmi_trigger_cpumask_backtrace(const cpuma << 186 int exclude << 187 void (*rais << 188 bool nmi_cpu_backtrace(struct pt_regs *regs); << 189 << 190 #else << 191 static inline bool trigger_all_cpu_backtrace(v << 192 { << 193 return false; << 194 } << 195 static inline bool trigger_allbutcpu_cpu_backt << 196 { << 197 return false; << 198 } << 199 static inline bool trigger_cpumask_backtrace(s << 200 { << 201 return false; << 202 } << 203 static inline bool trigger_single_cpu_backtrac << 204 { << 205 return false; << 206 } << 207 #endif << 208 << 209 #ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF << 210 u64 hw_nmi_get_sample_period(int watchdog_thre << 211 bool arch_perf_nmi_is_available(void); << 212 #endif << 213 << 214 #if defined(CONFIG_HARDLOCKUP_CHECK_TIMESTAMP) << 215 defined(CONFIG_HARDLOCKUP_DETECTOR_PERF) << 216 void watchdog_update_hrtimer_threshold(u64 per << 217 #else << 218 static inline void watchdog_update_hrtimer_thr << 219 #endif << 220 << 221 #ifdef CONFIG_HAVE_ACPI_APEI_NMI << 222 #include <asm/nmi.h> << 223 #endif << 224 << 225 #ifdef CONFIG_NMI_CHECK_CPU << 226 void nmi_backtrace_stall_snap(const struct cpu << 227 void nmi_backtrace_stall_check(const struct cp << 228 #else 18 #else 229 static inline void nmi_backtrace_stall_snap(co !! 19 # define touch_nmi_watchdog() do { } while(0) 230 static inline void nmi_backtrace_stall_check(c << 231 #endif 20 #endif 232 21 233 #endif 22 #endif 234 23
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.