Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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
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
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>
73extern void touch_nmi_watchdog(void);
74#else
75static inline void touch_nmi_watchdog(void)
76{
77 touch_softlockup_watchdog();
78}
79#endif
80
81#if defined(CONFIG_HARDLOCKUP_DETECTOR)
82extern void hardlockup_detector_disable(void);
83#else
84static 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
93static inline bool trigger_all_cpu_backtrace(void)
94{
95 arch_trigger_cpumask_backtrace(cpu_online_mask, false);
96 return true;
97}
98
99static inline bool trigger_allbutself_cpu_backtrace(void)
100{
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);
114 return true;
115}
116
117/* generic implementation */
118void nmi_trigger_cpumask_backtrace(const cpumask_t *mask,
119 bool exclude_self,
120 void (*raise)(cpumask_t *mask));
121bool nmi_cpu_backtrace(struct pt_regs *regs);
122
123#else
124static inline bool trigger_all_cpu_backtrace(void)
125{
126 return false;
127}
128static inline bool trigger_allbutself_cpu_backtrace(void)
129{
130 return false;
131}
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}
140#endif
141
142#ifdef CONFIG_LOCKUP_DETECTOR
143u64 hw_nmi_get_sample_period(int watchdog_thresh);
144extern int nmi_watchdog_enabled;
145extern int soft_watchdog_enabled;
146extern int watchdog_user_enabled;
147extern int watchdog_thresh;
148extern unsigned long watchdog_enabled;
149extern unsigned long *watchdog_cpumask_bits;
150extern atomic_t watchdog_park_in_progress;
151#ifdef CONFIG_SMP
152extern int sysctl_softlockup_all_cpu_backtrace;
153extern 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
158extern bool is_hardlockup(void);
159struct ctl_table;
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 *);
168extern int proc_watchdog_cpumask(struct ctl_table *, int,
169 void __user *, size_t *, loff_t *);
170extern int lockup_detector_suspend(void);
171extern void lockup_detector_resume(void);
172#else
173static inline int lockup_detector_suspend(void)
174{
175 return 0;
176}
177
178static 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