Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/include/linux/nmi.h |
| 3 | */ |
| 4 | #ifndef LINUX_NMI_H |
| 5 | #define LINUX_NMI_H |
| 6 | |
Michal Schmidt | 9938406 | 2006-09-29 01:59:03 -0700 | [diff] [blame] | 7 | #include <linux/sched.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #include <asm/irq.h> |
| 9 | |
| 10 | /** |
| 11 | * touch_nmi_watchdog - restart NMI watchdog timeout. |
| 12 | * |
| 13 | * If the architecture supports the NMI watchdog, touch_nmi_watchdog() |
| 14 | * may be used to reset the timeout - for code which intentionally |
| 15 | * disables interrupts for a long time. This call is stateless. |
| 16 | */ |
Colin Cross | 49ed1f8 | 2013-01-11 13:51:48 -0800 | [diff] [blame] | 17 | #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR_NMI) |
Andrew Morton | bb81a09 | 2006-12-07 02:14:01 +0100 | [diff] [blame] | 18 | #include <asm/nmi.h> |
Colin Cross | 49ed1f8 | 2013-01-11 13:51:48 -0800 | [diff] [blame] | 19 | #endif |
| 20 | |
| 21 | #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR) |
Don Zickus | 96a84c2 | 2010-11-29 17:07:16 -0500 | [diff] [blame] | 22 | extern void touch_nmi_watchdog(void); |
| 23 | #else |
Ingo Molnar | 5d0e600 | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 24 | static inline void touch_nmi_watchdog(void) |
| 25 | { |
| 26 | touch_softlockup_watchdog(); |
| 27 | } |
Don Zickus | 96a84c2 | 2010-11-29 17:07:16 -0500 | [diff] [blame] | 28 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | |
Ulrich Obergfell | 6e7458a | 2014-10-13 15:55:35 -0700 | [diff] [blame] | 30 | #if defined(CONFIG_HARDLOCKUP_DETECTOR) |
Ulrich Obergfell | 692297d | 2015-04-14 15:44:19 -0700 | [diff] [blame] | 31 | extern void hardlockup_detector_disable(void); |
Ulrich Obergfell | 6e7458a | 2014-10-13 15:55:35 -0700 | [diff] [blame] | 32 | #else |
Guenter Roeck | aacfbe6 | 2015-09-04 15:45:12 -0700 | [diff] [blame] | 33 | static inline void hardlockup_detector_disable(void) {} |
Ulrich Obergfell | 6e7458a | 2014-10-13 15:55:35 -0700 | [diff] [blame] | 34 | #endif |
| 35 | |
Ingo Molnar | 47cab6a | 2009-08-03 09:31:54 +0200 | [diff] [blame] | 36 | /* |
| 37 | * Create trigger_all_cpu_backtrace() out of the arch-provided |
| 38 | * base function. Return whether such support was available, |
| 39 | * to allow calling code to fall back to some other mechanism: |
| 40 | */ |
Chris Metcalf | 9a01c3e | 2016-10-07 17:02:45 -0700 | [diff] [blame] | 41 | #ifdef arch_trigger_cpumask_backtrace |
Ingo Molnar | 47cab6a | 2009-08-03 09:31:54 +0200 | [diff] [blame] | 42 | static inline bool trigger_all_cpu_backtrace(void) |
| 43 | { |
Chris Metcalf | 9a01c3e | 2016-10-07 17:02:45 -0700 | [diff] [blame] | 44 | arch_trigger_cpumask_backtrace(cpu_online_mask, false); |
Ingo Molnar | 47cab6a | 2009-08-03 09:31:54 +0200 | [diff] [blame] | 45 | return true; |
| 46 | } |
Chris Metcalf | 9a01c3e | 2016-10-07 17:02:45 -0700 | [diff] [blame] | 47 | |
Aaron Tomlin | f3aca3d | 2014-06-23 13:22:05 -0700 | [diff] [blame] | 48 | static inline bool trigger_allbutself_cpu_backtrace(void) |
| 49 | { |
Chris Metcalf | 9a01c3e | 2016-10-07 17:02:45 -0700 | [diff] [blame] | 50 | arch_trigger_cpumask_backtrace(cpu_online_mask, true); |
| 51 | return true; |
| 52 | } |
| 53 | |
| 54 | static inline bool trigger_cpumask_backtrace(struct cpumask *mask) |
| 55 | { |
| 56 | arch_trigger_cpumask_backtrace(mask, false); |
| 57 | return true; |
| 58 | } |
| 59 | |
| 60 | static inline bool trigger_single_cpu_backtrace(int cpu) |
| 61 | { |
| 62 | arch_trigger_cpumask_backtrace(cpumask_of(cpu), false); |
Aaron Tomlin | f3aca3d | 2014-06-23 13:22:05 -0700 | [diff] [blame] | 63 | return true; |
| 64 | } |
Russell King | b2c0b2c | 2014-09-03 23:57:13 +0100 | [diff] [blame] | 65 | |
| 66 | /* generic implementation */ |
Chris Metcalf | 9a01c3e | 2016-10-07 17:02:45 -0700 | [diff] [blame] | 67 | void nmi_trigger_cpumask_backtrace(const cpumask_t *mask, |
| 68 | bool exclude_self, |
Russell King | b2c0b2c | 2014-09-03 23:57:13 +0100 | [diff] [blame] | 69 | void (*raise)(cpumask_t *mask)); |
| 70 | bool nmi_cpu_backtrace(struct pt_regs *regs); |
| 71 | |
Ingo Molnar | 47cab6a | 2009-08-03 09:31:54 +0200 | [diff] [blame] | 72 | #else |
| 73 | static inline bool trigger_all_cpu_backtrace(void) |
| 74 | { |
| 75 | return false; |
| 76 | } |
Aaron Tomlin | f3aca3d | 2014-06-23 13:22:05 -0700 | [diff] [blame] | 77 | static inline bool trigger_allbutself_cpu_backtrace(void) |
| 78 | { |
| 79 | return false; |
| 80 | } |
Chris Metcalf | 9a01c3e | 2016-10-07 17:02:45 -0700 | [diff] [blame] | 81 | static inline bool trigger_cpumask_backtrace(struct cpumask *mask) |
| 82 | { |
| 83 | return false; |
| 84 | } |
| 85 | static inline bool trigger_single_cpu_backtrace(int cpu) |
| 86 | { |
| 87 | return false; |
| 88 | } |
Andrew Morton | bb81a09 | 2006-12-07 02:14:01 +0100 | [diff] [blame] | 89 | #endif |
| 90 | |
Don Zickus | 58687ac | 2010-05-07 17:11:44 -0400 | [diff] [blame] | 91 | #ifdef CONFIG_LOCKUP_DETECTOR |
Mandeep Singh Baines | 4eec42f | 2011-05-22 22:10:23 -0700 | [diff] [blame] | 92 | u64 hw_nmi_get_sample_period(int watchdog_thresh); |
Ulrich Obergfell | 84d56e6 | 2015-04-14 15:43:55 -0700 | [diff] [blame] | 93 | extern int nmi_watchdog_enabled; |
| 94 | extern int soft_watchdog_enabled; |
Frederic Weisbecker | 3c00ea8 | 2013-05-19 20:45:15 +0200 | [diff] [blame] | 95 | extern int watchdog_user_enabled; |
Mandeep Singh Baines | 586692a | 2011-05-22 22:10:22 -0700 | [diff] [blame] | 96 | extern int watchdog_thresh; |
Chris Metcalf | fe4ba3c | 2015-06-24 16:55:45 -0700 | [diff] [blame] | 97 | extern unsigned long *watchdog_cpumask_bits; |
Aaron Tomlin | ed23587 | 2014-06-23 13:22:05 -0700 | [diff] [blame] | 98 | extern int sysctl_softlockup_all_cpu_backtrace; |
Jiri Kosina | 5553787 | 2015-11-05 18:44:41 -0800 | [diff] [blame] | 99 | extern int sysctl_hardlockup_all_cpu_backtrace; |
Don Zickus | 504d7cf | 2010-02-12 17:19:19 -0500 | [diff] [blame] | 100 | struct ctl_table; |
Ulrich Obergfell | 83a80a3 | 2015-04-14 15:44:08 -0700 | [diff] [blame] | 101 | extern int proc_watchdog(struct ctl_table *, int , |
| 102 | void __user *, size_t *, loff_t *); |
| 103 | extern int proc_nmi_watchdog(struct ctl_table *, int , |
| 104 | void __user *, size_t *, loff_t *); |
| 105 | extern int proc_soft_watchdog(struct ctl_table *, int , |
| 106 | void __user *, size_t *, loff_t *); |
| 107 | extern int proc_watchdog_thresh(struct ctl_table *, int , |
| 108 | void __user *, size_t *, loff_t *); |
Chris Metcalf | fe4ba3c | 2015-06-24 16:55:45 -0700 | [diff] [blame] | 109 | extern int proc_watchdog_cpumask(struct ctl_table *, int, |
| 110 | void __user *, size_t *, loff_t *); |
Ulrich Obergfell | ec6a906 | 2015-09-04 15:45:28 -0700 | [diff] [blame] | 111 | extern int lockup_detector_suspend(void); |
| 112 | extern void lockup_detector_resume(void); |
Ulrich Obergfell | 999bbe4 | 2015-09-04 15:45:25 -0700 | [diff] [blame] | 113 | #else |
Ulrich Obergfell | ec6a906 | 2015-09-04 15:45:28 -0700 | [diff] [blame] | 114 | static inline int lockup_detector_suspend(void) |
Ulrich Obergfell | 999bbe4 | 2015-09-04 15:45:25 -0700 | [diff] [blame] | 115 | { |
| 116 | return 0; |
| 117 | } |
| 118 | |
Ulrich Obergfell | ec6a906 | 2015-09-04 15:45:28 -0700 | [diff] [blame] | 119 | static inline void lockup_detector_resume(void) |
Ulrich Obergfell | 999bbe4 | 2015-09-04 15:45:25 -0700 | [diff] [blame] | 120 | { |
| 121 | } |
Don Zickus | 84e478c | 2010-02-05 21:47:05 -0500 | [diff] [blame] | 122 | #endif |
| 123 | |
Tomasz Nowicki | 44a69f6 | 2014-07-22 11:20:12 +0200 | [diff] [blame] | 124 | #ifdef CONFIG_HAVE_ACPI_APEI_NMI |
| 125 | #include <asm/nmi.h> |
| 126 | #endif |
| 127 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | #endif |