]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - include/linux/nmi.h
Merge branch 'utilities' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux
[karo-tx-linux.git] / include / linux / nmi.h
1 /*
2  *  linux/include/linux/nmi.h
3  */
4 #ifndef LINUX_NMI_H
5 #define LINUX_NMI_H
6
7 #include <linux/sched.h>
8 #include <asm/irq.h>
9
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
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
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  */
71 #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
72 #include <asm/nmi.h>
73 extern void touch_nmi_watchdog(void);
74 #else
75 static inline void touch_nmi_watchdog(void)
76 {
77         touch_softlockup_watchdog();
78 }
79 #endif
80
81 #if defined(CONFIG_HARDLOCKUP_DETECTOR)
82 extern void hardlockup_detector_disable(void);
83 #else
84 static inline void hardlockup_detector_disable(void) {}
85 #endif
86
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  */
92 #ifdef arch_trigger_cpumask_backtrace
93 static inline bool trigger_all_cpu_backtrace(void)
94 {
95         arch_trigger_cpumask_backtrace(cpu_online_mask, false);
96         return true;
97 }
98
99 static inline bool trigger_allbutself_cpu_backtrace(void)
100 {
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);
114         return true;
115 }
116
117 /* generic implementation */
118 void nmi_trigger_cpumask_backtrace(const cpumask_t *mask,
119                                    bool exclude_self,
120                                    void (*raise)(cpumask_t *mask));
121 bool nmi_cpu_backtrace(struct pt_regs *regs);
122
123 #else
124 static inline bool trigger_all_cpu_backtrace(void)
125 {
126         return false;
127 }
128 static inline bool trigger_allbutself_cpu_backtrace(void)
129 {
130         return false;
131 }
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 }
140 #endif
141
142 #ifdef CONFIG_LOCKUP_DETECTOR
143 u64 hw_nmi_get_sample_period(int watchdog_thresh);
144 extern int nmi_watchdog_enabled;
145 extern int soft_watchdog_enabled;
146 extern int watchdog_user_enabled;
147 extern int watchdog_thresh;
148 extern unsigned long watchdog_enabled;
149 extern unsigned long *watchdog_cpumask_bits;
150 extern atomic_t watchdog_park_in_progress;
151 #ifdef CONFIG_SMP
152 extern int sysctl_softlockup_all_cpu_backtrace;
153 extern int sysctl_hardlockup_all_cpu_backtrace;
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);
159 struct ctl_table;
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 *);
168 extern int proc_watchdog_cpumask(struct ctl_table *, int,
169                                  void __user *, size_t *, loff_t *);
170 extern int lockup_detector_suspend(void);
171 extern void lockup_detector_resume(void);
172 #else
173 static inline int lockup_detector_suspend(void)
174 {
175         return 0;
176 }
177
178 static inline void lockup_detector_resume(void)
179 {
180 }
181 #endif
182
183 #ifdef CONFIG_HAVE_ACPI_APEI_NMI
184 #include <asm/nmi.h>
185 #endif
186
187 #endif