]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - include/linux/nmi.h
Merge tag 'efi-urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi into...
[mirror_ubuntu-artful-kernel.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
LT
8#include <asm/irq.h>
9
d151b27d
IM
10#ifdef CONFIG_LOCKUP_DETECTOR
11extern void touch_softlockup_watchdog_sched(void);
12extern void touch_softlockup_watchdog(void);
13extern void touch_softlockup_watchdog_sync(void);
14extern void touch_all_softlockup_watchdogs(void);
15extern int proc_dowatchdog_thresh(struct ctl_table *table, int write,
16 void __user *buffer,
17 size_t *lenp, loff_t *ppos);
18extern unsigned int softlockup_panic;
19extern unsigned int hardlockup_panic;
20void lockup_detector_init(void);
21#else
22static inline void touch_softlockup_watchdog_sched(void)
23{
24}
25static inline void touch_softlockup_watchdog(void)
26{
27}
28static inline void touch_softlockup_watchdog_sync(void)
29{
30}
31static inline void touch_all_softlockup_watchdogs(void)
32{
33}
34static inline void lockup_detector_init(void)
35{
36}
37#endif
38
39#ifdef CONFIG_DETECT_HUNG_TASK
40void reset_hung_task_detector(void);
41#else
42static inline void reset_hung_task_detector(void)
43{
44}
45#endif
46
249e52e3
BM
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
1da177e4
LT
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 */
d314d74c 71#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
bb81a09e 72#include <asm/nmi.h>
96a84c20
DZ
73extern void touch_nmi_watchdog(void);
74#else
5d0e600d
IM
75static inline void touch_nmi_watchdog(void)
76{
77 touch_softlockup_watchdog();
78}
96a84c20 79#endif
1da177e4 80
6e7458a6 81#if defined(CONFIG_HARDLOCKUP_DETECTOR)
692297d8 82extern void hardlockup_detector_disable(void);
6e7458a6 83#else
aacfbe6a 84static inline void hardlockup_detector_disable(void) {}
6e7458a6
UO
85#endif
86
47cab6a7
IM
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 */
9a01c3ed 92#ifdef arch_trigger_cpumask_backtrace
47cab6a7
IM
93static inline bool trigger_all_cpu_backtrace(void)
94{
9a01c3ed 95 arch_trigger_cpumask_backtrace(cpu_online_mask, false);
47cab6a7
IM
96 return true;
97}
9a01c3ed 98
f3aca3d0
AT
99static inline bool trigger_allbutself_cpu_backtrace(void)
100{
9a01c3ed
CM
101 arch_trigger_cpumask_backtrace(cpu_online_mask, true);
102 return true;
103}
104
105static inline bool trigger_cpumask_backtrace(struct cpumask *mask)
106{
107 arch_trigger_cpumask_backtrace(mask, false);
108 return true;
109}
110
111static inline bool trigger_single_cpu_backtrace(int cpu)
112{
113 arch_trigger_cpumask_backtrace(cpumask_of(cpu), false);
f3aca3d0
AT
114 return true;
115}
b2c0b2cb
RK
116
117/* generic implementation */
9a01c3ed
CM
118void nmi_trigger_cpumask_backtrace(const cpumask_t *mask,
119 bool exclude_self,
b2c0b2cb
RK
120 void (*raise)(cpumask_t *mask));
121bool nmi_cpu_backtrace(struct pt_regs *regs);
122
47cab6a7
IM
123#else
124static inline bool trigger_all_cpu_backtrace(void)
125{
126 return false;
127}
f3aca3d0
AT
128static inline bool trigger_allbutself_cpu_backtrace(void)
129{
130 return false;
131}
9a01c3ed
CM
132static inline bool trigger_cpumask_backtrace(struct cpumask *mask)
133{
134 return false;
135}
136static inline bool trigger_single_cpu_backtrace(int cpu)
137{
138 return false;
139}
bb81a09e
AM
140#endif
141
58687acb 142#ifdef CONFIG_LOCKUP_DETECTOR
4eec42f3 143u64 hw_nmi_get_sample_period(int watchdog_thresh);
84d56e66
UO
144extern int nmi_watchdog_enabled;
145extern int soft_watchdog_enabled;
3c00ea82 146extern int watchdog_user_enabled;
586692a5 147extern int watchdog_thresh;
249e52e3 148extern unsigned long watchdog_enabled;
fe4ba3c3 149extern unsigned long *watchdog_cpumask_bits;
b94f5118 150extern atomic_t watchdog_park_in_progress;
249e52e3 151#ifdef CONFIG_SMP
ed235875 152extern int sysctl_softlockup_all_cpu_backtrace;
55537871 153extern int sysctl_hardlockup_all_cpu_backtrace;
249e52e3
BM
154#else
155#define sysctl_softlockup_all_cpu_backtrace 0
156#define sysctl_hardlockup_all_cpu_backtrace 0
157#endif
158extern bool is_hardlockup(void);
504d7cf1 159struct ctl_table;
83a80a39
UO
160extern int proc_watchdog(struct ctl_table *, int ,
161 void __user *, size_t *, loff_t *);
162extern int proc_nmi_watchdog(struct ctl_table *, int ,
163 void __user *, size_t *, loff_t *);
164extern int proc_soft_watchdog(struct ctl_table *, int ,
165 void __user *, size_t *, loff_t *);
166extern int proc_watchdog_thresh(struct ctl_table *, int ,
167 void __user *, size_t *, loff_t *);
fe4ba3c3
CM
168extern int proc_watchdog_cpumask(struct ctl_table *, int,
169 void __user *, size_t *, loff_t *);
ec6a9066
UO
170extern int lockup_detector_suspend(void);
171extern void lockup_detector_resume(void);
999bbe49 172#else
ec6a9066 173static inline int lockup_detector_suspend(void)
999bbe49
UO
174{
175 return 0;
176}
177
ec6a9066 178static inline void lockup_detector_resume(void)
999bbe49
UO
179{
180}
84e478c6
DZ
181#endif
182
44a69f61
TN
183#ifdef CONFIG_HAVE_ACPI_APEI_NMI
184#include <asm/nmi.h>
185#endif
186
1da177e4 187#endif