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