Skip to content

Commit 249e52e

Browse files
Babu Mogertorvalds
authored andcommitted
kernel/watchdog.c: move shared definitions to nmi.h
Patch series "Clean up watchdog handlers", v2. This is an attempt to cleanup watchdog handlers. Right now, kernel/watchdog.c implements both softlockup and hardlockup detectors. Softlockup code is generic. Hardlockup code is arch specific. Some architectures don't use hardlockup detectors. They use their own watchdog detectors. To make both these combination work, we have numerous #ifdefs in kernel/watchdog.c. We are trying here to make these handlers independent of each other. Also provide an interface for architectures to implement their own handlers. watchdog_nmi_enable and watchdog_nmi_disable will be defined as weak such that architectures can override its definitions. Thanks to Don Zickus for his suggestions. Here are our previous discussions http://www.spinics.net/lists/sparclinux/msg16543.html http://www.spinics.net/lists/sparclinux/msg16441.html This patch (of 3): Move shared macros and definitions to nmi.h so that watchdog.c, new file watchdog_hld.c or any other architecture specific handler can use those definitions. Link: http://lkml.kernel.org/r/1478034826-43888-2-git-send-email-babu.moger@oracle.com Signed-off-by: Babu Moger <babu.moger@oracle.com> Acked-by: Don Zickus <dzickus@redhat.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Kosina <jkosina@suse.cz> Cc: Andi Kleen <andi@firstfloor.org> Cc: Yaowei Bai <baiyaowei@cmss.chinamobile.com> Cc: Aaron Tomlin <atomlin@redhat.com> Cc: Ulrich Obergfell <uobergfe@redhat.com> Cc: Tejun Heo <tj@kernel.org> Cc: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com> Cc: Josh Hunt <johunt@akamai.com> Cc: "David S. Miller" <davem@davemloft.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 2272279 commit 249e52e

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

include/linux/nmi.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@
77
#include <linux/sched.h>
88
#include <asm/irq.h>
99

10+
/*
11+
* The run state of the lockup detectors is controlled by the content of the
12+
* 'watchdog_enabled' variable. Each lockup detector has its dedicated bit -
13+
* bit 0 for the hard lockup detector and bit 1 for the soft lockup detector.
14+
*
15+
* 'watchdog_user_enabled', 'nmi_watchdog_enabled' and 'soft_watchdog_enabled'
16+
* are variables that are only used as an 'interface' between the parameters
17+
* in /proc/sys/kernel and the internal state bits in 'watchdog_enabled'. The
18+
* 'watchdog_thresh' variable is handled differently because its value is not
19+
* boolean, and the lockup detectors are 'suspended' while 'watchdog_thresh'
20+
* is equal zero.
21+
*/
22+
#define NMI_WATCHDOG_ENABLED_BIT 0
23+
#define SOFT_WATCHDOG_ENABLED_BIT 1
24+
#define NMI_WATCHDOG_ENABLED (1 << NMI_WATCHDOG_ENABLED_BIT)
25+
#define SOFT_WATCHDOG_ENABLED (1 << SOFT_WATCHDOG_ENABLED_BIT)
26+
1027
/**
1128
* touch_nmi_watchdog - restart NMI watchdog timeout.
1229
*
@@ -91,9 +108,16 @@ extern int nmi_watchdog_enabled;
91108
extern int soft_watchdog_enabled;
92109
extern int watchdog_user_enabled;
93110
extern int watchdog_thresh;
111+
extern unsigned long watchdog_enabled;
94112
extern unsigned long *watchdog_cpumask_bits;
113+
#ifdef CONFIG_SMP
95114
extern int sysctl_softlockup_all_cpu_backtrace;
96115
extern int sysctl_hardlockup_all_cpu_backtrace;
116+
#else
117+
#define sysctl_softlockup_all_cpu_backtrace 0
118+
#define sysctl_hardlockup_all_cpu_backtrace 0
119+
#endif
120+
extern bool is_hardlockup(void);
97121
struct ctl_table;
98122
extern int proc_watchdog(struct ctl_table *, int ,
99123
void __user *, size_t *, loff_t *);

kernel/watchdog.c

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,12 @@
2727
#include <linux/perf_event.h>
2828
#include <linux/kthread.h>
2929

30-
/*
31-
* The run state of the lockup detectors is controlled by the content of the
32-
* 'watchdog_enabled' variable. Each lockup detector has its dedicated bit -
33-
* bit 0 for the hard lockup detector and bit 1 for the soft lockup detector.
34-
*
35-
* 'watchdog_user_enabled', 'nmi_watchdog_enabled' and 'soft_watchdog_enabled'
36-
* are variables that are only used as an 'interface' between the parameters
37-
* in /proc/sys/kernel and the internal state bits in 'watchdog_enabled'. The
38-
* 'watchdog_thresh' variable is handled differently because its value is not
39-
* boolean, and the lockup detectors are 'suspended' while 'watchdog_thresh'
40-
* is equal zero.
41-
*/
42-
#define NMI_WATCHDOG_ENABLED_BIT 0
43-
#define SOFT_WATCHDOG_ENABLED_BIT 1
44-
#define NMI_WATCHDOG_ENABLED (1 << NMI_WATCHDOG_ENABLED_BIT)
45-
#define SOFT_WATCHDOG_ENABLED (1 << SOFT_WATCHDOG_ENABLED_BIT)
46-
4730
static DEFINE_MUTEX(watchdog_proc_mutex);
4831

49-
#ifdef CONFIG_HARDLOCKUP_DETECTOR
50-
static unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED|NMI_WATCHDOG_ENABLED;
32+
#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
33+
unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED|NMI_WATCHDOG_ENABLED;
5134
#else
52-
static unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED;
35+
unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED;
5336
#endif
5437
int __read_mostly nmi_watchdog_enabled;
5538
int __read_mostly soft_watchdog_enabled;
@@ -59,9 +42,6 @@ int __read_mostly watchdog_thresh = 10;
5942
#ifdef CONFIG_SMP
6043
int __read_mostly sysctl_softlockup_all_cpu_backtrace;
6144
int __read_mostly sysctl_hardlockup_all_cpu_backtrace;
62-
#else
63-
#define sysctl_softlockup_all_cpu_backtrace 0
64-
#define sysctl_hardlockup_all_cpu_backtrace 0
6545
#endif
6646
static struct cpumask watchdog_cpumask __read_mostly;
6747
unsigned long *watchdog_cpumask_bits = cpumask_bits(&watchdog_cpumask);
@@ -289,7 +269,7 @@ void touch_softlockup_watchdog_sync(void)
289269

290270
#ifdef CONFIG_HARDLOCKUP_DETECTOR
291271
/* watchdog detector functions */
292-
static bool is_hardlockup(void)
272+
bool is_hardlockup(void)
293273
{
294274
unsigned long hrint = __this_cpu_read(hrtimer_interrupts);
295275

0 commit comments

Comments
 (0)