Skip to content

Commit 05a4a95

Browse files
npiggintorvalds
authored andcommitted
kernel/watchdog: split up config options
Split SOFTLOCKUP_DETECTOR from LOCKUP_DETECTOR, and split HARDLOCKUP_DETECTOR_PERF from HARDLOCKUP_DETECTOR. LOCKUP_DETECTOR implies the general boot, sysctl, and programming interfaces for the lockup detectors. An architecture that wants to use a hard lockup detector must define HAVE_HARDLOCKUP_DETECTOR_PERF or HAVE_HARDLOCKUP_DETECTOR_ARCH. Alternatively an arch can define HAVE_NMI_WATCHDOG, which provides the minimum arch_touch_nmi_watchdog, and it otherwise does its own thing and does not implement the LOCKUP_DETECTOR interfaces. sparc is unusual in that it has started to implement some of the interfaces, but not fully yet. It should probably be converted to a full HAVE_HARDLOCKUP_DETECTOR_ARCH. [npiggin@gmail.com: fix] Link: http://lkml.kernel.org/r/20170617223522.66c0ad88@roar.ozlabs.ibm.com Link: http://lkml.kernel.org/r/20170616065715.18390-4-npiggin@gmail.com Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Reviewed-by: Don Zickus <dzickus@redhat.com> Reviewed-by: Babu Moger <babu.moger@oracle.com> Tested-by: Babu Moger <babu.moger@oracle.com> [sparc] Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent f2e0cff commit 05a4a95

File tree

11 files changed

+251
-162
lines changed

11 files changed

+251
-162
lines changed

arch/Kconfig

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,6 @@ config HAVE_KPROBES_ON_FTRACE
198198
config HAVE_NMI
199199
bool
200200

201-
config HAVE_NMI_WATCHDOG
202-
depends on HAVE_NMI
203-
bool
204201
#
205202
# An arch should select this if it provides all these things:
206203
#
@@ -288,6 +285,28 @@ config HAVE_PERF_EVENTS_NMI
288285
subsystem. Also has support for calculating CPU cycle events
289286
to determine how many clock cycles in a given period.
290287

288+
config HAVE_HARDLOCKUP_DETECTOR_PERF
289+
bool
290+
depends on HAVE_PERF_EVENTS_NMI
291+
help
292+
The arch chooses to use the generic perf-NMI-based hardlockup
293+
detector. Must define HAVE_PERF_EVENTS_NMI.
294+
295+
config HAVE_NMI_WATCHDOG
296+
depends on HAVE_NMI
297+
bool
298+
help
299+
The arch provides a low level NMI watchdog. It provides
300+
asm/nmi.h, and defines its own arch_touch_nmi_watchdog().
301+
302+
config HAVE_HARDLOCKUP_DETECTOR_ARCH
303+
bool
304+
select HAVE_NMI_WATCHDOG
305+
help
306+
The arch chooses to provide its own hardlockup detector, which is
307+
a superset of the HAVE_NMI_WATCHDOG. It also conforms to config
308+
interfaces and parameters provided by hardlockup detector subsystem.
309+
291310
config HAVE_PERF_REGS
292311
bool
293312
help

arch/powerpc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ config PPC
197197
select HAVE_OPTPROBES if PPC64
198198
select HAVE_PERF_EVENTS
199199
select HAVE_PERF_EVENTS_NMI if PPC64
200+
select HAVE_HARDLOCKUP_DETECTOR_PERF if HAVE_PERF_EVENTS_NMI
200201
select HAVE_PERF_REGS
201202
select HAVE_PERF_USER_STACK_DUMP
202203
select HAVE_RCU_TABLE_FREE if SMP

arch/powerpc/kernel/setup_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ struct ppc_pci_io ppc_pci_io;
752752
EXPORT_SYMBOL(ppc_pci_io);
753753
#endif
754754

755-
#ifdef CONFIG_HARDLOCKUP_DETECTOR
755+
#ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF
756756
u64 hw_nmi_get_sample_period(int watchdog_thresh)
757757
{
758758
return ppc_proc_freq * watchdog_thresh;

arch/x86/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ config X86
162162
select HAVE_PCSPKR_PLATFORM
163163
select HAVE_PERF_EVENTS
164164
select HAVE_PERF_EVENTS_NMI
165+
select HAVE_HARDLOCKUP_DETECTOR_PERF if HAVE_PERF_EVENTS_NMI
165166
select HAVE_PERF_REGS
166167
select HAVE_PERF_USER_STACK_DUMP
167168
select HAVE_REGS_AND_STACK_ACCESS_API

arch/x86/kernel/apic/hw_nmi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <linux/init.h>
2020
#include <linux/delay.h>
2121

22-
#ifdef CONFIG_HARDLOCKUP_DETECTOR
22+
#ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF
2323
u64 hw_nmi_get_sample_period(int watchdog_thresh)
2424
{
2525
return (u64)(cpu_khz) * 1000 * watchdog_thresh;

include/linux/nmi.h

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,21 @@
1111
#endif
1212

1313
#ifdef CONFIG_LOCKUP_DETECTOR
14+
void lockup_detector_init(void);
15+
#else
16+
static inline void lockup_detector_init(void)
17+
{
18+
}
19+
#endif
20+
21+
#ifdef CONFIG_SOFTLOCKUP_DETECTOR
1422
extern void touch_softlockup_watchdog_sched(void);
1523
extern void touch_softlockup_watchdog(void);
1624
extern void touch_softlockup_watchdog_sync(void);
1725
extern void touch_all_softlockup_watchdogs(void);
1826
extern unsigned int softlockup_panic;
19-
extern unsigned int hardlockup_panic;
20-
void lockup_detector_init(void);
27+
extern int soft_watchdog_enabled;
28+
extern atomic_t watchdog_park_in_progress;
2129
#else
2230
static inline void touch_softlockup_watchdog_sched(void)
2331
{
@@ -31,9 +39,6 @@ static inline void touch_softlockup_watchdog_sync(void)
3139
static inline void touch_all_softlockup_watchdogs(void)
3240
{
3341
}
34-
static inline void lockup_detector_init(void)
35-
{
36-
}
3742
#endif
3843

3944
#ifdef CONFIG_DETECT_HUNG_TASK
@@ -63,15 +68,18 @@ static inline void reset_hung_task_detector(void)
6368

6469
#if defined(CONFIG_HARDLOCKUP_DETECTOR)
6570
extern void hardlockup_detector_disable(void);
71+
extern unsigned int hardlockup_panic;
6672
#else
6773
static inline void hardlockup_detector_disable(void) {}
6874
#endif
6975

70-
#if defined(CONFIG_HARDLOCKUP_DETECTOR) || defined(CONFIG_HAVE_NMI_WATCHDOG)
76+
#if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF)
7177
extern void arch_touch_nmi_watchdog(void);
7278
#else
79+
#if !defined(CONFIG_HAVE_NMI_WATCHDOG)
7380
static inline void arch_touch_nmi_watchdog(void) {}
7481
#endif
82+
#endif
7583

7684
/**
7785
* touch_nmi_watchdog - restart NMI watchdog timeout.
@@ -141,15 +149,18 @@ static inline bool trigger_single_cpu_backtrace(int cpu)
141149
}
142150
#endif
143151

144-
#ifdef CONFIG_LOCKUP_DETECTOR
152+
#ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF
145153
u64 hw_nmi_get_sample_period(int watchdog_thresh);
154+
#endif
155+
156+
#ifdef CONFIG_LOCKUP_DETECTOR
146157
extern int nmi_watchdog_enabled;
147-
extern int soft_watchdog_enabled;
148158
extern int watchdog_user_enabled;
149159
extern int watchdog_thresh;
150160
extern unsigned long watchdog_enabled;
161+
extern struct cpumask watchdog_cpumask;
151162
extern unsigned long *watchdog_cpumask_bits;
152-
extern atomic_t watchdog_park_in_progress;
163+
extern int __read_mostly watchdog_suspended;
153164
#ifdef CONFIG_SMP
154165
extern int sysctl_softlockup_all_cpu_backtrace;
155166
extern int sysctl_hardlockup_all_cpu_backtrace;

kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ obj-$(CONFIG_KPROBES) += kprobes.o
8282
obj-$(CONFIG_KGDB) += debug/
8383
obj-$(CONFIG_DETECT_HUNG_TASK) += hung_task.o
8484
obj-$(CONFIG_LOCKUP_DETECTOR) += watchdog.o
85-
obj-$(CONFIG_HARDLOCKUP_DETECTOR) += watchdog_hld.o
85+
obj-$(CONFIG_HARDLOCKUP_DETECTOR_PERF) += watchdog_hld.o
8686
obj-$(CONFIG_SECCOMP) += seccomp.o
8787
obj-$(CONFIG_RELAY) += relay.o
8888
obj-$(CONFIG_SYSCTL) += utsname_sysctl.o

kernel/sysctl.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,14 @@ static struct ctl_table kern_table[] = {
900900
.extra2 = &zero,
901901
#endif
902902
},
903+
{
904+
.procname = "watchdog_cpumask",
905+
.data = &watchdog_cpumask_bits,
906+
.maxlen = NR_CPUS,
907+
.mode = 0644,
908+
.proc_handler = proc_watchdog_cpumask,
909+
},
910+
#ifdef CONFIG_SOFTLOCKUP_DETECTOR
903911
{
904912
.procname = "soft_watchdog",
905913
.data = &soft_watchdog_enabled,
@@ -909,13 +917,6 @@ static struct ctl_table kern_table[] = {
909917
.extra1 = &zero,
910918
.extra2 = &one,
911919
},
912-
{
913-
.procname = "watchdog_cpumask",
914-
.data = &watchdog_cpumask_bits,
915-
.maxlen = NR_CPUS,
916-
.mode = 0644,
917-
.proc_handler = proc_watchdog_cpumask,
918-
},
919920
{
920921
.procname = "softlockup_panic",
921922
.data = &softlockup_panic,
@@ -925,27 +926,29 @@ static struct ctl_table kern_table[] = {
925926
.extra1 = &zero,
926927
.extra2 = &one,
927928
},
928-
#ifdef CONFIG_HARDLOCKUP_DETECTOR
929+
#ifdef CONFIG_SMP
929930
{
930-
.procname = "hardlockup_panic",
931-
.data = &hardlockup_panic,
931+
.procname = "softlockup_all_cpu_backtrace",
932+
.data = &sysctl_softlockup_all_cpu_backtrace,
932933
.maxlen = sizeof(int),
933934
.mode = 0644,
934935
.proc_handler = proc_dointvec_minmax,
935936
.extra1 = &zero,
936937
.extra2 = &one,
937938
},
939+
#endif /* CONFIG_SMP */
938940
#endif
939-
#ifdef CONFIG_SMP
941+
#ifdef CONFIG_HARDLOCKUP_DETECTOR
940942
{
941-
.procname = "softlockup_all_cpu_backtrace",
942-
.data = &sysctl_softlockup_all_cpu_backtrace,
943+
.procname = "hardlockup_panic",
944+
.data = &hardlockup_panic,
943945
.maxlen = sizeof(int),
944946
.mode = 0644,
945947
.proc_handler = proc_dointvec_minmax,
946948
.extra1 = &zero,
947949
.extra2 = &one,
948950
},
951+
#ifdef CONFIG_SMP
949952
{
950953
.procname = "hardlockup_all_cpu_backtrace",
951954
.data = &sysctl_hardlockup_all_cpu_backtrace,
@@ -957,6 +960,8 @@ static struct ctl_table kern_table[] = {
957960
},
958961
#endif /* CONFIG_SMP */
959962
#endif
963+
#endif
964+
960965
#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
961966
{
962967
.procname = "unknown_nmi_panic",

0 commit comments

Comments
 (0)