Improve watchdog config for arch watchdogs
Subsystems (6)
Nicholas Piggin
reviewerv3 cover Improve watchdog config for arch watchdogs
Since last time:
- Have the perf based hardlockup detector use arch_touch_nmi_watchdog() rather than hld_touch_nmi_watchdog(). This changes direction slightly to make the perf-based hard lockup detector an alternative that an arch may select, rather than standalone. This better reflects how the code works in practice).
- Hopefully fixed the Kconfig options. There's still a bit of ugliness that will require another pass or two over interfaces and config scheme, but the idea is to make a minimal change to get the powerpc HLD in, which gives a reasonable starting point to improve things further.
Nicholas Piggin (4):
watchdog: remove unused declaration
watchdog: Introduce arch_touch_nmi_watchdog()
watchdog: Split up config options
watchdog: Provide watchdog_reconfigure() for arch watchdogs
arch/blackfin/include/asm/nmi.h | 2 + arch/blackfin/kernel/nmi.c | 2 +- arch/mn10300/include/asm/nmi.h | 2 + arch/mn10300/kernel/mn10300-watchdog-low.S | 8 +- arch/mn10300/kernel/mn10300-watchdog.c | 2 +- arch/powerpc/kernel/setup_64.c | 2 +- arch/sparc/include/asm/nmi.h | 1 + arch/sparc/kernel/nmi.c | 6 +- arch/x86/kernel/apic/hw_nmi.c | 2 +- include/linux/nmi.h | 57 ++++--- kernel/Makefile | 2 +- kernel/sysctl.c | 18 +- kernel/watchdog.c | 263 +++++++++++++++++++---------- kernel/watchdog_hld.c | 37 +--- lib/Kconfig.debug | 29 +++- 15 files changed, 263 insertions(+), 170 deletions(-)
Signature · 1 line
2.11.0
Nicholas Piggin
reviewerPATCH v3 1/4 watchdog: remove unused declaration
--- include/linux/nmi.h | 3 --- 1 file changed, 3 deletions(-)
include/linux/nmi.h +0 -3
@@ -12,9 +12,6 @@ extern void touch_softlockup_watchdog_sched(void);extern void touch_softlockup_watchdog (void );extern void touch_softlockup_watchdog_sync (void );extern void touch_all_softlockup_watchdogs (void ); -extern int proc_dowatchdog_thresh (struct ctl_table *table,int write, -void __user *buffer, -size_t *lenp,loff_t *ppos);extern unsigned int softlockup_panic;extern unsigned int hardlockup_panic;void lockup_detector_init (void );
Signature · 1 line
2.11.0
Nicholas Piggin
reviewerPATCH v3 2/4 watchdog: Introduce arch_touch_nmi_watchdog()
In reply to Nicholas PigginFor architectures that define HAVE_NMI_WATCHDOG, instead of having them provide the complete touch_nmi_watchdog() function, just have them provide arch_touch_nmi_watchdog().
This gives the generic code more flexibility in implementing this function, and arch implementations don't miss out on touching the softlockup watchdog or other generic details.
--- arch/blackfin/include/asm/nmi.h | 2 ++ arch/blackfin/kernel/nmi.c | 2 +- arch/mn10300/include/asm/nmi.h | 2 ++ arch/mn10300/kernel/mn10300-watchdog-low.S | 8 ++++---- arch/mn10300/kernel/mn10300-watchdog.c | 2 +- arch/sparc/include/asm/nmi.h | 1 + arch/sparc/kernel/nmi.c | 6 ++---- include/linux/nmi.h | 27 ++++++++++++++++----------- kernel/watchdog_hld.c | 5 ++--- 9 files changed, 31 insertions(+), 24 deletions(-)
arch/blackfin/include/asm/nmi.h +2 -0
@@ -9,4 +9,6 @@#include <linux/nmi.h> +extern void arch_touch_nmi_watchdog (void ); +#endif
arch/blackfin/kernel/nmi.c +1 -1
@@ -190,7 +190,7 @@ static int __init init_nmi_wdt(void) }device_initcall (init_nmi_wdt); -void touch_nmi_watchdog (void ) +void arch_touch_nmi_watchdog (void ) {atomic_set (&nmi_touched[smp_processor_id ()],1 ); }
arch/mn10300/include/asm/nmi.h +2 -0
@@ -11,4 +11,6 @@#ifndef _ASM_NMI_H#define _ASM_NMI_H +extern void arch_touch_nmi_watchdog (void ); +#endif /* _ASM_NMI_H */
arch/mn10300/kernel/mn10300-watchdog-low.S +4 -4
@@ -50,9 +50,9 @@ watchdog_handler: # we can't inline it) # ############################################################################### - .globl touch_nmi_watchdog - .type touch_nmi_watchdog,@function -touch_nmi_watchdog: + .globl arch_touch_nmi_watchdog + .type arch_touch_nmi_watchdog,@function +arch_touch_nmi_watchdog: clr d0 clr d1 mov watchdog_alert_counter, a0
@@ -63,4 +63,4 @@ touch_nmi_watchdog: lne ret [],0 - .size touch_nmi_watchdog,.-touch_nmi_watchdog + .size arch_touch_nmi_watchdog,.-arch_touch_nmi_watchdog
arch/mn10300/kernel/mn10300-watchdog.c +1 -1
@@ -31,7 +31,7 @@ static unsigned int watchdog;static unsigned int watchdog_hz =1 ;unsigned int watchdog_alert_counter[NR_CPUS ]; -EXPORT_SYMBOL (touch_nmi_watchdog); +EXPORT_SYMBOL (arch_touch_nmi_watchdog);/* * the best way to detect whether a CPU has a 'hard lockup' problem
arch/sparc/include/asm/nmi.h +1 -0
@@ -7,6 +7,7 @@ void nmi_adjust_hz(unsigned int new_hz);extern atomic_t nmi_active; +void arch_touch_nmi_watchdog (void );void start_nmi_watchdog (void *unused);void stop_nmi_watchdog (void *unused);
arch/sparc/kernel/nmi.c +2 -4
@@ -51,7 +51,7 @@ static DEFINE_PER_CPU(unsigned int, last_irq_sum); static DEFINE_PER_CPU(long, alert_counter); static DEFINE_PER_CPU(int, nmi_touch); -void touch_nmi_watchdog (void ) +void arch_touch_nmi_watchdog (void ) {if (atomic_read (&nmi_active)) {int cpu;
@@ -61,10 +61,8 @@ void touch_nmi_watchdog(void)per_cpu (nmi_touch, cpu) =1 ; } } - -touch_softlockup_watchdog (); } -EXPORT_SYMBOL (touch_nmi_watchdog); +EXPORT_SYMBOL (arch_touch_nmi_watchdog);static void die_nmi (const char *str,struct pt_regs *regs,int do_panic) {
include/linux/nmi.h +16 -11
@@ -6,6 +6,9 @@#include <linux/sched.h> #include <asm/irq.h> +#if defined(CONFIG_HAVE_NMI_WATCHDOG ) +#include <asm/nmi.h> +#endif #ifdef CONFIG_LOCKUP_DETECTOR extern void touch_softlockup_watchdog_sched (void );
@@ -58,6 +61,18 @@ static inline void reset_hung_task_detector(void)#define NMI_WATCHDOG_ENABLED (1 << NMI_WATCHDOG_ENABLED_BIT)#define SOFT_WATCHDOG_ENABLED (1 << SOFT_WATCHDOG_ENABLED_BIT) +#if defined(CONFIG_HARDLOCKUP_DETECTOR ) +extern void hardlockup_detector_disable (void ); +#else +static inline void hardlockup_detector_disable (void ) {} +#endif + +#if defined(CONFIG_HARDLOCKUP_DETECTOR ) || defined(CONFIG_HAVE_NMI_WATCHDOG ) +extern void arch_touch_nmi_watchdog (void ); +#else +static inline void arch_touch_nmi_watchdog (void ) {} +#endif +/** * touch_nmi_watchdog - restart NMI watchdog timeout. *
@@ -65,21 +80,11 @@ static inline void reset_hung_task_detector(void)* may be used to reset the timeout - for code which intentionally * disables interrupts for a long time. This call is stateless. */ -#if defined(CONFIG_HAVE_NMI_WATCHDOG ) || defined(CONFIG_HARDLOCKUP_DETECTOR ) -#include <asm/nmi.h> -extern void touch_nmi_watchdog (void ); -#else static inline void touch_nmi_watchdog (void ) { +arch_touch_nmi_watchdog ();touch_softlockup_watchdog (); } -#endif - -#if defined(CONFIG_HARDLOCKUP_DETECTOR ) -extern void hardlockup_detector_disable (void ); -#else -static inline void hardlockup_detector_disable (void ) {} -#endif /* * Create trigger_all_cpu_backtrace() out of the arch-provided
kernel/watchdog_hld.c +2 -3
@@ -56,7 +56,7 @@ static int __init hardlockup_panic_setup(char *str) }__setup ("nmi_watchdog=" , hardlockup_panic_setup); -void touch_nmi_watchdog (void ) +void arch_touch_nmi_watchdog (void ) {/* * Using __raw here because some code paths have
@@ -66,9 +66,8 @@ void touch_nmi_watchdog(void)* going off. */ raw_cpu_write (watchdog_nmi_touch, true); -touch_softlockup_watchdog (); } -EXPORT_SYMBOL (touch_nmi_watchdog); +EXPORT_SYMBOL (arch_touch_nmi_watchdog);static struct perf_event_attr wd_hw_attr = { .type =PERF_TYPE_HARDWARE ,
Signature · 1 line
2.11.0
Nicholas Piggin
reviewerPATCH v3 3/4 watchdog: Split up config options
In reply to Nicholas PigginSplit SOFTLOCKUP_DETECTOR from LOCKUP_DETECTOR, and split HARDLOCKUP_DETECTOR_PERF from HARDLOCKUP_DETECTOR.
LOCKUP_DETECTOR provides the boot, sysctl, and programming interfaces for lockup detectors. An architecture that defines HAVE_NMI_WATCHDOG need not use this this if it has a very basic watchdog or uses its own options and interfaces (e.g., sparc). touch_nmi_watchdog() will continue to call their arch_touch_nmi_watchdog().
HARDLOCKUP_DETECTOR_PERF is the perf-based lockup detector.
HARDLOCKUP_DETECTOR is the framework for arch NMI_WATCHDOG hard lockup detectors that conform to the LOCKUP_DETECTOR interfaces.
--- arch/powerpc/kernel/setup_64.c | 2 +- arch/x86/kernel/apic/hw_nmi.c | 2 +- include/linux/nmi.h | 31 ++++-- kernel/Makefile | 2 +- kernel/sysctl.c | 18 ++-- kernel/watchdog.c | 238 ++++++++++++++++++++++++++--------------- kernel/watchdog_hld.c | 32 ------ lib/Kconfig.debug | 29 +++-- 8 files changed, 211 insertions(+), 143 deletions(-)
arch/powerpc/kernel/setup_64.c +1 -1
@@ -727,7 +727,7 @@ struct ppc_pci_io ppc_pci_io;EXPORT_SYMBOL (ppc_pci_io);#endif -#ifdef CONFIG_HARDLOCKUP_DETECTOR +#ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF u64 hw_nmi_get_sample_period (int watchdog_thresh) {return ppc_proc_freq * watchdog_thresh;
arch/x86/kernel/apic/hw_nmi.c +1 -1
@@ -19,7 +19,7 @@#include <linux/init.h> #include <linux/delay.h> -#ifdef CONFIG_HARDLOCKUP_DETECTOR +#ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF u64 hw_nmi_get_sample_period (int watchdog_thresh) {return (u64)(cpu_khz) *1000 * watchdog_thresh;
include/linux/nmi.h +21 -10
@@ -11,13 +11,21 @@#endif #ifdef CONFIG_LOCKUP_DETECTOR +void lockup_detector_init (void ); +#else +static inline void lockup_detector_init (void ) +{ +} +#endif + +#ifdef CONFIG_SOFTLOCKUP_DETECTOR extern void touch_softlockup_watchdog_sched (void );extern void touch_softlockup_watchdog (void );extern void touch_softlockup_watchdog_sync (void );extern void touch_all_softlockup_watchdogs (void );extern unsigned int softlockup_panic; -extern unsigned int hardlockup_panic; -void lockup_detector_init (void ); +extern int soft_watchdog_enabled; +extern atomic_t watchdog_park_in_progress;#else static inline void touch_softlockup_watchdog_sched (void ) {
@@ -31,9 +39,6 @@ static inline void touch_softlockup_watchdog_sync(void)static inline void touch_all_softlockup_watchdogs (void ) { } -static inline void lockup_detector_init (void ) -{ -}#endif #ifdef CONFIG_DETECT_HUNG_TASK
@@ -63,13 +68,16 @@ static inline void reset_hung_task_detector(void)#if defined(CONFIG_HARDLOCKUP_DETECTOR )extern void hardlockup_detector_disable (void ); +extern unsigned int hardlockup_panic;#else static inline void hardlockup_detector_disable (void ) {}#endif -#if defined(CONFIG_HARDLOCKUP_DETECTOR ) || defined(CONFIG_HAVE_NMI_WATCHDOG ) +#ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF extern void arch_touch_nmi_watchdog (void ); -#else +#endif + +#if !defined(CONFIG_HARDLOCKUP_DETECTOR ) && !defined(CONFIG_HAVE_NMI_WATCHDOG )static inline void arch_touch_nmi_watchdog (void ) {}#endif
@@ -141,15 +149,18 @@ static inline bool trigger_single_cpu_backtrace(int cpu) }#endif -#ifdef CONFIG_LOCKUP_DETECTOR +#ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF u64 hw_nmi_get_sample_period (int watchdog_thresh); +#endif + +#ifdef CONFIG_LOCKUP_DETECTOR extern int nmi_watchdog_enabled; -extern int soft_watchdog_enabled;extern int watchdog_user_enabled;extern int watchdog_thresh;extern unsigned long watchdog_enabled; +extern struct cpumask watchdog_cpumask;extern unsigned long *watchdog_cpumask_bits; -extern atomic_t watchdog_park_in_progress; +extern int __read_mostly watchdog_suspended;#ifdef CONFIG_SMP extern int sysctl_softlockup_all_cpu_backtrace;extern int sysctl_hardlockup_all_cpu_backtrace;
kernel/Makefile +1 -1
@@ -82,7 +82,7 @@ obj-$(CONFIG_KPROBES) += kprobes.o obj-$(CONFIG_KGDB) += debug/ obj-$(CONFIG_DETECT_HUNG_TASK) += hung_task.o obj-$(CONFIG_LOCKUP_DETECTOR) += watchdog.o -obj-$(CONFIG_HARDLOCKUP_DETECTOR) += watchdog_hld.o +obj-$(CONFIG_HARDLOCKUP_DETECTOR_PERF) += watchdog_hld.o obj-$(CONFIG_SECCOMP) += seccomp.o obj-$(CONFIG_RELAY) += relay.o obj-$(CONFIG_SYSCTL) += utsname_sysctl.o
kernel/sysctl.c +10 -8
@@ -873,13 +873,21 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = proc_nmi_watchdog, .extra1 = &zero, -#if defined(CONFIG_HAVE_NMI_WATCHDOG ) || defined(CONFIG_HARDLOCKUP_DETECTOR ) +#ifdef CONFIG_HARDLOCKUP_DETECTOR .extra2 = &one, #else .extra2 = &zero, #endif }, { + .procname ="watchdog_cpumask" , + .data = &watchdog_cpumask_bits, + .maxlen = NR_CPUS, + .mode = 0644, + .proc_handler = proc_watchdog_cpumask, + }, +#ifdef CONFIG_SOFTLOCKUP_DETECTOR + { .procname ="soft_watchdog" , .data = &soft_watchdog_enabled, .maxlen = sizeof (int),
@@ -889,13 +897,6 @@ static struct ctl_table kern_table[] = { .extra2 = &one, }, { - .procname = "watchdog_cpumask", - .data = &watchdog_cpumask_bits, - .maxlen = NR_CPUS, - .mode = 0644, - .proc_handler = proc_watchdog_cpumask, - }, - { .procname = "softlockup_panic", .data = &softlockup_panic, .maxlen = sizeof(int),
@@ -904,6 +905,7 @@ static struct ctl_table kern_table[] = { .extra1 = &zero, .extra2 = &one, }, +#endif #ifdef CONFIG_HARDLOCKUP_DETECTOR { .procname = "hardlockup_panic",
kernel/watchdog.c +154 -84
314 lines not on this page · raw message
kernel/watchdog_hld.c +0 -32
@@ -22,39 +22,7 @@ static DEFINE_PER_CPU(bool, hard_watchdog_warn); static DEFINE_PER_CPU(bool, watchdog_nmi_touch); static DEFINE_PER_CPU(struct perf_event *, watchdog_ev); -/* boot commands */ -/* -* Should we panic when a soft-lockup or hard-lockup occurs: -*/ -unsigned int __read_mostly hardlockup_panic = -CONFIG_BOOTPARAM_HARDLOCKUP_PANIC_VALUE ;static unsigned long hardlockup_allcpu_dumped; -/* -* We may not want to enable hard lockup detection by default in all cases, -* for example when running the kernel as a guest on a hypervisor. In these -* cases this function can be called to disable hard lockup detection. This -* function should only be executed once by the boot processor before the -* kernel command line parameters are parsed, because otherwise it is not -* possible to override this in hardlockup_panic_setup(). -*/ -void hardlockup_detector_disable (void ) -{ - watchdog_enabled &= ~NMI_WATCHDOG_ENABLED ; -} - -static int __init hardlockup_panic_setup (char *str) -{ -if (!strncmp (str,"panic" ,5 )) - hardlockup_panic =1 ; -else if (!strncmp (str,"nopanic" ,7 )) - hardlockup_panic =0 ; -else if (!strncmp (str,"0" ,1 )) - watchdog_enabled &= ~NMI_WATCHDOG_ENABLED ; -else if (!strncmp (str,"1" ,1 )) - watchdog_enabled |=NMI_WATCHDOG_ENABLED ; -return 1 ; -} -__setup ("nmi_watchdog=" , hardlockup_panic_setup);void arch_touch_nmi_watchdog (void ) {
lib/Kconfig.debug +23 -6
@@ -801,10 +801,27 @@ config LOCKUP_DETECTOR The frequency of hrtimer and NMI events and the soft and hard lockup thresholds can be controlled through the sysctl watchdog_thresh. +config SOFTLOCKUP_DETECTOR + bool "Detect Soft Lockups" + depends on LOCKUP_DETECTOR + +config HARDLOCKUP_DETECTOR_PERF + bool + select SOFTLOCKUP_DETECTOR + +# +# arch/ can define HAVE_NMI_WATCHDOG to provide their own NMI watchdog +# rather than the perf based detector. +# +# The arch may do its own thing, or select HARDLOCKUP_DETECTOR, in which +# case it should conform to HARDLOCKUP_DETECTOR interfaces and settings +# (e.g., sysctl and cmdline). +# config HARDLOCKUP_DETECTOR - def_bool y - depends on LOCKUP_DETECTOR && !HAVE_NMI_WATCHDOG - depends on PERF_EVENTS && HAVE_PERF_EVENTS_NMI + bool "Detect Hard Lockups" + depends on LOCKUP_DETECTOR + depends on !HAVE_NMI_WATCHDOG && (PERF_EVENTS && HAVE_PERF_EVENTS_NMI) + select HARDLOCKUP_DETECTOR_PERF if !HAVE_NMI_WATCHDOG config BOOTPARAM_HARDLOCKUP_PANIC bool "Panic (Reboot) On Hard Lockups"
@@ -826,7 +843,7 @@ config BOOTPARAM_HARDLOCKUP_PANIC_VALUE config BOOTPARAM_SOFTLOCKUP_PANIC bool "Panic (Reboot) On Soft Lockups" - depends on LOCKUP_DETECTOR + depends on SOFTLOCKUP_DETECTOR help Say Y here to enable the kernel to panic on "soft lockups", which are bugs that cause the kernel to loop in kernel
@@ -843,7 +860,7 @@ config BOOTPARAM_SOFTLOCKUP_PANIC config BOOTPARAM_SOFTLOCKUP_PANIC_VALUE int - depends on LOCKUP_DETECTOR + depends on SOFTLOCKUP_DETECTOR range 0 1 default 0 if !BOOTPARAM_SOFTLOCKUP_PANIC default 1 if BOOTPARAM_SOFTLOCKUP_PANIC
@@ -851,7 +868,7 @@ config BOOTPARAM_SOFTLOCKUP_PANIC_VALUE config DETECT_HUNG_TASK bool "Detect Hung Tasks" depends on DEBUG_KERNEL - default LOCKUP_DETECTOR + default SOFTLOCKUP_DETECTOR help Say Y here to enable the kernel to detect "hung tasks", which are bugs that cause the task to be stuck in
Signature · 1 line
2.11.0
Re: [PATCH 3/4] watchdog: Split up config options
Quoted 9 lines · Nicholas Piggin
Split
SOFTLOCKUP_DETECTORfromLOCKUP_DETECTOR, and splitHARDLOCKUP_DETECTOR_PERFfromHARDLOCKUP_DETECTOR.
LOCKUP_DETECTORprovides the boot, sysctl, and programming interfaces for lockup detectors. An architecture that definesHAVE_NMI_WATCHDOGneed not use this this if it has a very basic watchdog or uses its own options and interfaces (e.g., sparc).touch_nmi_watchdog()will continue to call theirarch_touch_nmi_watchdog().
Quoted 4 lines
HARDLOCKUP_DETECTOR_PERFis the perf-based lockup detector.
HARDLOCKUP_DETECTORis the framework for archNMI_WATCHDOGhard lockup detectors that conform to theLOCKUP_DETECTORinterfaces.
Hi Nick,
Sorry for the late response. I did some sanity testing on your patches on x86_64 and it seems to work fine. I don't think I have any real issues with the patches (without making time-consuming cleanup changes).
My last concern is wrapping my head around the config options.
HAVE_NMI_WATCHDOG seems to have a dual meaning, I think.
In the sparc case, it uses the HARDLOCKUP_DETECTOR framework (hence the original split out of watchdog_hld.c). Actually more like the SOFTLOCKUP_DETECTOR framework for which HARDLOCKUP_DETECTOR is a part of.
In your ppc64 case, it means do _not_ use the HARDLOCKUP_DETECTOR or SOFTLOCKUP_DETECTOR framework. Instead just the bare bones LOCKUP_DETECTOR.
If so, the following is a little confusing to me..
<snip>
Quoted 5 lines
lib/Kconfig.debug +0
-0
lib/Kconfig.debug config LOCKUP_DETECTOR · line 810
Quoted 10 lines
lib/Kconfig.debug +7
-0@@ -801,10 +801,27 @@ config LOCKUP_DETECTOR The frequency of hrtimer and NMI events and the soft and hard lockup thresholds can be controlled through the sysctl watchdog_thresh. +config SOFTLOCKUP_DETECTOR + bool "Detect Soft Lockups" + depends on LOCKUP_DETECTOR + +config HARDLOCKUP_DETECTOR_PERF + bool + select SOFTLOCKUP_DETECTOR
Perhaps add a 'depends on (PERF_EVENTS && HAVE_PERF_EVENTS_NMI)'
Quoted 7 lines
lib/Kconfig.debug +7
-0+ +# +# arch/ can define HAVE_NMI_WATCHDOG to provide their own NMI watchdog +# rather than the perf based detector. +# +# The arch may do its own thing, or select HARDLOCKUP_DETECTOR, in which +# case it should conform to HARDLOCKUP_DETECTOR interfaces and settings
lib/Kconfig.debug config LOCKUP_DETECTOR · line 824
Quoted 10 lines
lib/Kconfig.debug +6
-3+# (e.g., sysctl and cmdline). +# config HARDLOCKUP_DETECTOR - def_bool y - depends on LOCKUP_DETECTOR && !HAVE_NMI_WATCHDOG - depends on PERF_EVENTS && HAVE_PERF_EVENTS_NMI + bool "Detect Hard Lockups" + depends on LOCKUP_DETECTOR + depends on !HAVE_NMI_WATCHDOG && (PERF_EVENTS && HAVE_PERF_EVENTS_NMI) + select HARDLOCKUP_DETECTOR_PERF if !HAVE_NMI_WATCHDOG
Here is my confusion with HAVE_NMI_WATCHDOG
It seems like you can only select HARDLOCKUP_DETECTOR if !HAVE_NMI_DETECTOR which would break sparc, I think.
And then it always selects HARDLOCKUP_DETECTOR_PERF because of the dependency on !HAVE_NMI_WATCHDOG???
Yeah, the config options are confusing.
If the above is right then we might need something like
depends on HAVE_NMI_WATCHDOG || HAVE_PERF_EVENTS_NMI
(to replace the depends on !HAVE_NMI_WATCHDOG.. line)
Cheers,
Don
Quoted 33 lines
lib/Kconfig.debug +3
-3config BOOTPARAM_HARDLOCKUP_PANIC bool "Panic (Reboot) On Hard Lockups"@@ -826,7 +843,7 @@ config BOOTPARAM_HARDLOCKUP_PANIC_VALUE config BOOTPARAM_SOFTLOCKUP_PANIC bool "Panic (Reboot) On Soft Lockups" - depends on LOCKUP_DETECTOR + depends on SOFTLOCKUP_DETECTOR help Say Y here to enable the kernel to panic on "soft lockups", which are bugs that cause the kernel to loop in kernel@@ -843,7 +860,7 @@ config BOOTPARAM_SOFTLOCKUP_PANIC config BOOTPARAM_SOFTLOCKUP_PANIC_VALUE int - depends on LOCKUP_DETECTOR + depends on SOFTLOCKUP_DETECTOR range 0 1 default 0 if !BOOTPARAM_SOFTLOCKUP_PANIC default 1 if BOOTPARAM_SOFTLOCKUP_PANIC@@ -851,7 +868,7 @@ config BOOTPARAM_SOFTLOCKUP_PANIC_VALUE config DETECT_HUNG_TASK bool "Detect Hung Tasks" depends on DEBUG_KERNEL - default LOCKUP_DETECTOR + default SOFTLOCKUP_DETECTOR help Say Y here to enable the kernel to detect "hung tasks", which are bugs that cause the task to be stuck inSignature · 1 line
2.11.0
Nicholas Piggin
reviewerRe: [PATCH 3/4] watchdog: Split up config options
Quoted 17 lines · On Fri, 2 Jun 2017 16:15:00 -0400 Don Zickus <[email protected]> wrote:
Quoted 9 lines · Nicholas Piggin
Split
SOFTLOCKUP_DETECTORfromLOCKUP_DETECTOR, and splitHARDLOCKUP_DETECTOR_PERFfromHARDLOCKUP_DETECTOR.
LOCKUP_DETECTORprovides the boot, sysctl, and programming interfaces for lockup detectors. An architecture that definesHAVE_NMI_WATCHDOGneed not use this this if it has a very basic watchdog or uses its own options and interfaces (e.g., sparc).touch_nmi_watchdog()will continue to call theirarch_touch_nmi_watchdog().Quoted 4 lines
HARDLOCKUP_DETECTOR_PERFis the perf-based lockup detector.
HARDLOCKUP_DETECTORis the framework for archNMI_WATCHDOGhard lockup detectors that conform to theLOCKUP_DETECTORinterfaces.Hi Nick,
Quoted 7 lines
Sorry for the late response. I did some sanity testing on your patches on
x86_64and it seems to work fine. I don't think I have any real issues with the patches (without making time-consuming cleanup changes).My last concern is wrapping my head around the config options.
HAVE_NMI_WATCHDOGseems to have a dual meaning, I think.
Yeah it's not the clearest. I think we need another pass over config options to start straightening them out.
It means the arch has a hardlockup detector, so it has the arch_touch_nmi_watchdog() and you can't also select the perf HLD.
Quoted 3 lines
In the sparc case, it uses the
HARDLOCKUP_DETECTORframework (hence the original split out ofwatchdog_hld.c). Actually more like theSOFTLOCKUP_DETECTORframework for whichHARDLOCKUP_DETECTORis a part of.
Well yes it uses some of the start/stop framework for the SLD, but doesn't use much beyond that of the lockup detector stuff (most of the boot options and sysctl parameters etc it does not use). So sparc is a little odd.
I would hope to convert it over to more like powerpc patch and make it a first class HLD, but it seems not all options are 100% compatible so it would need some careful testing.
Quoted 3 lines
In your ppc64 case, it means do _not_ use the
HARDLOCKUP_DETECTORorSOFTLOCKUP_DETECTORframework. Instead just the bare bonesLOCKUP_DETECTOR.
It does use the HLD framework. The subsequent patch for powerpc adds a PPC64 case in the dependencies.
Quoted 15 lines
If so, the following is a little confusing to me..
<snip>
Quoted 8 lines
lib/Kconfig.debug +0
-0@@ -801,10 +801,27 @@ config LOCKUP_DETECTOR The frequency of hrtimer and NMI events and the soft and hard lockup thresholds can be controlled through the sysctl watchdog_thresh.
Quoted 9 lines
lib/Kconfig.debug config LOCKUP_DETECTOR · line 810
Quoted 7 lines
lib/Kconfig.debug +7
-0+config SOFTLOCKUP_DETECTOR + bool "Detect Soft Lockups" + depends on LOCKUP_DETECTOR + +config HARDLOCKUP_DETECTOR_PERF + bool + select SOFTLOCKUP_DETECTORPerhaps add a 'depends on (
PERF_EVENTS&&HAVE_PERF_EVENTS_NMI)'
Kconfig is pretty clunky, I was struggling to make it do the right thing... I could try.
Quoted 21 lines
Quoted 8 lines
lib/Kconfig.debug +7
-0+ +# +# arch/ can define HAVE_NMI_WATCHDOG to provide their own NMI watchdog +# rather than the perf based detector. +# +# The arch may do its own thing, or select HARDLOCKUP_DETECTOR, in which +# case it should conform to HARDLOCKUP_DETECTOR interfaces and settingslib/Kconfig.debug config LOCKUP_DETECTOR · line 824
Quoted 10 lines
lib/Kconfig.debug +6
-3+# (e.g., sysctl and cmdline). +# config HARDLOCKUP_DETECTOR - def_bool y - depends on LOCKUP_DETECTOR && !HAVE_NMI_WATCHDOG - depends on PERF_EVENTS && HAVE_PERF_EVENTS_NMI + bool "Detect Hard Lockups" + depends on LOCKUP_DETECTOR + depends on !HAVE_NMI_WATCHDOG && (PERF_EVENTS && HAVE_PERF_EVENTS_NMI) + select HARDLOCKUP_DETECTOR_PERF if !HAVE_NMI_WATCHDOGHere is my confusion with
HAVE_NMI_WATCHDOG
Quoted 5 lines
It seems like you can only select
HARDLOCKUP_DETECTORif !HAVE_NMI_DETECTOR which would break sparc, I think.And then it always selects
HARDLOCKUP_DETECTOR_PERFbecause of the dependency on !HAVE_NMI_WATCHDOG???
I don't think so -- sparc today does not select HARDLOCKUP_DETECTOR.
After this patch, it always selects the _PERF detector because that's the only one available. See the powerpc patch which adds the PPC64 exception here.
Yes it's a bit clunky. I think we can subsequently remove HAVE_NMI_DETECTOR and replace it with something a bit saner and clean up some of these convoluted cases.
Thanks,
Nick
Re: [PATCH 3/4] watchdog: Split up config options
Quoted 9 lines · Nicholas Piggin
Quoted 3 lines
My last concern is wrapping my head around the config options.
HAVE_NMI_WATCHDOGseems to have a dual meaning, I think.Yeah it's not the clearest. I think we need another pass over config options to start straightening them out.
It means the arch has a hardlockup detector, so it has the
arch_touch_nmi_watchdog()and you can't also select the perf HLD.
Ok, agreed.
Quoted 5 lines
Quoted 4 lines
In the sparc case, it uses the
HARDLOCKUP_DETECTORframework (hence the original split out ofwatchdog_hld.c). Actually more like theSOFTLOCKUP_DETECTORframework for whichHARDLOCKUP_DETECTORis a part of.
Quoted 9 lines
Well yes it uses some of the start/stop framework for the SLD, but doesn't use much beyond that of the lockup detector stuff (most of the boot options and sysctl parameters etc it does not use). So sparc is a little odd.
I would hope to convert it over to more like powerpc patch and make it a first class HLD, but it seems not all options are 100% compatible so it would need some careful testing.
Ok. More comments on sparc below..
Quoted 6 lines
Quoted 3 lines
In your ppc64 case, it means do _not_ use the
HARDLOCKUP_DETECTORorSOFTLOCKUP_DETECTORframework. Instead just the bare bonesLOCKUP_DETECTOR.It does use the HLD framework. The subsequent patch for powerpc adds a PPC64 case in the dependencies.
Ah, ok.
Quoted 50 lines
Quoted 16 lines
If so, the following is a little confusing to me..
<snip>
Quoted 8 lines
lib/Kconfig.debug +0
-0@@ -801,10 +801,27 @@ config LOCKUP_DETECTOR The frequency of hrtimer and NMI events and the soft and hard lockup thresholds can be controlled through the sysctl watchdog_thresh.Quoted 9 lines
lib/Kconfig.debug config LOCKUP_DETECTOR · line 810
Quoted 7 lines
lib/Kconfig.debug +7
-0+config SOFTLOCKUP_DETECTOR + bool "Detect Soft Lockups" + depends on LOCKUP_DETECTOR + +config HARDLOCKUP_DETECTOR_PERF + bool + select SOFTLOCKUP_DETECTORPerhaps add a 'depends on (
PERF_EVENTS&&HAVE_PERF_EVENTS_NMI)'
Kconfigis pretty clunky, I was struggling to make it do the right thing... I could try.Quoted 21 lines
Quoted 8 lines
lib/Kconfig.debug +7
-0+ +# +# arch/ can define HAVE_NMI_WATCHDOG to provide their own NMI watchdog +# rather than the perf based detector. +# +# The arch may do its own thing, or select HARDLOCKUP_DETECTOR, in which +# case it should conform to HARDLOCKUP_DETECTOR interfaces and settingslib/Kconfig.debug config LOCKUP_DETECTOR · line 824
Quoted 10 lines
lib/Kconfig.debug +6
-3+# (e.g., sysctl and cmdline). +# config HARDLOCKUP_DETECTOR - def_bool y - depends on LOCKUP_DETECTOR && !HAVE_NMI_WATCHDOG - depends on PERF_EVENTS && HAVE_PERF_EVENTS_NMI + bool "Detect Hard Lockups" + depends on LOCKUP_DETECTOR + depends on !HAVE_NMI_WATCHDOG && (PERF_EVENTS && HAVE_PERF_EVENTS_NMI) + select HARDLOCKUP_DETECTOR_PERF if !HAVE_NMI_WATCHDOGHere is my confusion with
HAVE_NMI_WATCHDOG
Quoted 7 lines
Quoted 5 lines
It seems like you can only select
HARDLOCKUP_DETECTORif !HAVE_NMI_DETECTOR which would break sparc, I think.And then it always selects
HARDLOCKUP_DETECTOR_PERFbecause of the dependency on !HAVE_NMI_WATCHDOG???I don't think so -- sparc today does not select
HARDLOCKUP_DETECTOR.
Well yes, but your patch changes the definition of HARDLOCKUP_DETECTOR to HARDLOCKUP_DETECTOR_PERF and then recreates HARDLOCKUP_DETECTOR.
For example look at kernel/watchdog.c::watchdog_enabled (line 38)
sparc has HAVE_NMI_WATCHDOG set, but that will disable HARDLOCKUP_DETECTOR which I believes means sparc's nmi_watchdog is disabled on boot and has to be manually enabled?
I _think_ having
depends on LOCKUP_DETECTOR
depends on HAVE_NMI_WATCHDOG || HAVE_PERF_EVENTS_NMI select HARDLOCKUP_DETECTOR_PERF if !HAVE_NMI_WATCHDOG
will work because your new definition of HARDLOCKUP_DETECTOR is a combination of HAVE_NMI_WATCHDOG && HARDLOCKUP_DETECTOR_PERF ??
Did I get that right?
I almost wonder if arches should set either HAVE_NMI_WATCHDOG or HAVE_PERF_NMI_WATCHDOG and then use those two to determine HARDLOCKUP_DETECTOR. Would that make the config options slightly less confusing?
Thoughts?
Cheers,
Don
Quoted 11 lines
After this patch, it always selects the
_PERFdetector because that's the only one available. See the powerpc patch which adds the PPC64 exception here.Yes it's a bit clunky. I think we can subsequently remove
HAVE_NMI_DETECTORand replace it with something a bit saner and clean up some of these convoluted cases.Thanks,
Nick
Nicholas Piggin
reviewerRe: [PATCH 3/4] watchdog: Split up config options
Quoted 21 lines · On Tue, 6 Jun 2017 12:49:58 -0400 Don Zickus <[email protected]> wrote:
Quoted 11 lines · Nicholas Piggin
Quoted 11 lines
lib/Kconfig.debug config LOCKUP_DETECTOR · line 824
Quoted 8 lines
config
HARDLOCKUP_DETECTORlib/Kconfig.debug +4
-3- def_bool y - depends on LOCKUP_DETECTOR && !HAVE_NMI_WATCHDOG - depends on PERF_EVENTS && HAVE_PERF_EVENTS_NMI + bool "Detect Hard Lockups" + depends on LOCKUP_DETECTOR + depends on !HAVE_NMI_WATCHDOG && (PERF_EVENTS && HAVE_PERF_EVENTS_NMI) + select HARDLOCKUP_DETECTOR_PERF if !HAVE_NMI_WATCHDOGHere is my confusion with
HAVE_NMI_WATCHDOGQuoted 7 lines
Quoted 5 lines
It seems like you can only select
HARDLOCKUP_DETECTORif !HAVE_NMI_DETECTOR which would break sparc, I think.And then it always selects
HARDLOCKUP_DETECTOR_PERFbecause of the dependency on !HAVE_NMI_WATCHDOG???I don't think so -- sparc today does not select
HARDLOCKUP_DETECTOR.
Quoted 8 lines
Well yes, but your patch changes the definition of
HARDLOCKUP_DETECTORtoHARDLOCKUP_DETECTOR_PERFand then recreatesHARDLOCKUP_DETECTOR.For example look at kernel/watchdog.c::watchdog_enabled (line 38)
sparc has
HAVE_NMI_WATCHDOGset, but that will disableHARDLOCKUP_DETECTORwhich I believes means sparc'snmi_watchdogis disabled on boot and has to be manually enabled?
Ahh okay because sparc is using watchdog_nmi_enable/disable from the softlockup watchdog, which checks watchdog_enabled.
Quoted 4 lines
I _think_ having
Quoted 8 lines
depends on
LOCKUP_DETECTOR
depends onHAVE_NMI_WATCHDOG||HAVE_PERF_EVENTS_NMIselectHARDLOCKUP_DETECTOR_PERFif !HAVE_NMI_WATCHDOGwill work because your new definition of
HARDLOCKUP_DETECTORis a combination ofHAVE_NMI_WATCHDOG&&HARDLOCKUP_DETECTOR_PERF??Did I get that right?
Well in some ways, except that most of the NMI watchdogs do not seem to heed the HARDLOCKUP_DETECTOR configuration sysctls and commands.
NMI_WATCHDOG by itself was supposed to be for an arch that wnats to do completely it own thing.
sparc is somewhere in the middle. It uses some of the HLD stuff, but not all. That makes it a bit tricky.
Quoted 4 lines
I almost wonder if arches should set either
HAVE_NMI_WATCHDOGorHAVE_PERF_NMI_WATCHDOGand then use those two to determineHARDLOCKUP_DETECTOR. Would that make the config options slightly less confusing?
This would probably be the right direction to go in, but it will take slightly more I think. We first need to remove HAVE_NMI_WATCHDOG from meaning that an arch has its own watchdog and does not want any HLD stuff. I think with arch_touch_nmi_watchdog(), we can probably get there.
While transitioning, we could add a new option instead,
HAVE_ARCH_HARDLOCKUP_DETECTOR
I think HAVE_PERF_EVENTS_NMI is sufficient to imply it will use the PERF HLD. Possibly you could just change the name to be a bit more regular, HAVE_PERF_NMI_HARDLOCKUP_DETECTOR
Thanks,
Nick
Re: [PATCH 3/4] watchdog: Split up config options
Quoted 12 lines · Nicholas Piggin
Quoted 11 lines
I _think_ having
depends on
LOCKUP_DETECTOR
depends onHAVE_NMI_WATCHDOG||HAVE_PERF_EVENTS_NMIselectHARDLOCKUP_DETECTOR_PERFif !HAVE_NMI_WATCHDOGwill work because your new definition of
HARDLOCKUP_DETECTORis a combination ofHAVE_NMI_WATCHDOG&&HARDLOCKUP_DETECTOR_PERF??Did I get that right?
Quoted 8 lines
Well in some ways, except that most of the NMI watchdogs do not seem to heed the
HARDLOCKUP_DETECTORconfiguration sysctls and commands.
NMI_WATCHDOGby itself was supposed to be for an arch that wnats to do completely it own thing.sparc is somewhere in the middle. It uses some of the HLD stuff, but not all. That makes it a bit tricky.
Hmm, I can see sparc relying on SOFTLOCKUP, but the HARDLOCKUP code with your patches seems really small. The only sysctl is nmi_watchdog and hardlockup_panic. The former is needed but the later is only implemented in the HARDLOCKUP_DETECTOR_PERF case.
So by having HAVE_NMI_WATCHDOG, you sorta need a sysctl knob which the HARDLOCKUP_DETECTOR seems to provide on top of the default knobs.
With sparc being special and needing SOFTLOCKUP to call its nmi enable/disable hooks.
Is there a particular chunk of code you had in mind that did not make sense with HARDLOCKUP_DETECTOR enabled?
Quoted 12 lines
Quoted 6 lines
I almost wonder if arches should set either
HAVE_NMI_WATCHDOGorHAVE_PERF_NMI_WATCHDOGand then use those two to determineHARDLOCKUP_DETECTOR. Would that make the config options slightly less confusing?This would probably be the right direction to go in, but it will take slightly more I think. We first need to remove
HAVE_NMI_WATCHDOGfrom meaning that an arch has its own watchdog and does not want any HLD stuff. I think witharch_touch_nmi_watchdog(), we can probably get there.
Quoted 7 lines
While transitioning, we could add a new option instead,
HAVE_ARCH_HARDLOCKUP_DETECTORI think
HAVE_PERF_EVENTS_NMIis sufficient to imply it will use the PERF HLD. Possibly you could just change the name to be a bit more regular,HAVE_PERF_NMI_HARDLOCKUP_DETECTOR
Actually, I don't think I can just rename it as it has a specific use to let OPROFILE know the perf events are being NMI triggered as opposed to IRQ triggered.
Though I like the direction you are going. Then arches either have one or the other. Or in the ppc case it is dependent on what ppc platform is being used.
Then the HARDLOCKUP_DETECTOR needs one or the other to work correctly with the arch/<arch>/Kconfig explicitly stating which one to use?
Cheers,
Don
Quoted 3 lines
Thanks,
Nick
Nicholas Piggin
reviewerRe: [PATCH 3/4] watchdog: Split up config options
Quoted 22 lines · On Thu, 8 Jun 2017 12:05:02 -0400 Don Zickus <[email protected]> wrote:
Quoted 12 lines · Nicholas Piggin
Quoted 11 lines
I _think_ having
depends on
LOCKUP_DETECTOR
depends onHAVE_NMI_WATCHDOG||HAVE_PERF_EVENTS_NMIselectHARDLOCKUP_DETECTOR_PERFif !HAVE_NMI_WATCHDOGwill work because your new definition of
HARDLOCKUP_DETECTORis a combination ofHAVE_NMI_WATCHDOG&&HARDLOCKUP_DETECTOR_PERF??Did I get that right?
Quoted 8 lines
Well in some ways, except that most of the NMI watchdogs do not seem to heed the
HARDLOCKUP_DETECTORconfiguration sysctls and commands.
NMI_WATCHDOGby itself was supposed to be for an arch that wnats to do completely it own thing.sparc is somewhere in the middle. It uses some of the HLD stuff, but not all. That makes it a bit tricky.
Quoted 7 lines
Hmm, I can see sparc relying on SOFTLOCKUP, but the HARDLOCKUP code with your patches seems really small. The only sysctl is
nmi_watchdogandhardlockup_panic. The former is needed but the later is only implemented in theHARDLOCKUP_DETECTOR_PERFcase.So by having
HAVE_NMI_WATCHDOG, you sorta need a sysctl knob which theHARDLOCKUP_DETECTORseems to provide on top of the default knobs.
I would say there's a few others like the cpumask, threshold, panic, backtrace, etc.
Quoted 2 lines
With sparc being special and needing SOFTLOCKUP to call its nmi enable/disable hooks.
Yes, although we could just remove that dependency (it's minimal code to start them up with hotplug).
That said, I would hope to actually go the other way in general and move architectures to using the generic parameters as much as possible.
Quoted 2 lines
Is there a particular chunk of code you had in mind that did not make sense with
HARDLOCKUP_DETECTORenabled?
Perhaps the couple of other archs that have their own NMI watchdogs.
Quoted 21 lines
Quoted 13 lines
Quoted 7 lines
I almost wonder if arches should set either
HAVE_NMI_WATCHDOGorHAVE_PERF_NMI_WATCHDOGand then use those two to determineHARDLOCKUP_DETECTOR. Would that make the config options slightly less confusing?This would probably be the right direction to go in, but it will take slightly more I think. We first need to remove
HAVE_NMI_WATCHDOGfrom meaning that an arch has its own watchdog and does not want any HLD stuff. I think witharch_touch_nmi_watchdog(), we can probably get there.Quoted 7 lines
While transitioning, we could add a new option instead,
HAVE_ARCH_HARDLOCKUP_DETECTORI think
HAVE_PERF_EVENTS_NMIis sufficient to imply it will use the PERF HLD. Possibly you could just change the name to be a bit more regular,HAVE_PERF_NMI_HARDLOCKUP_DETECTOR
Quoted 7 lines
Actually, I don't think I can just rename it as it has a specific use to let OPROFILE know the perf events are being NMI triggered as opposed to IRQ triggered.
Though I like the direction you are going. Then arches either have one or the other. Or in the ppc case it is dependent on what ppc platform is being used.
Okay, glad we're on the same page conceptually :)
Quoted 3 lines
Then the
HARDLOCKUP_DETECTORneeds one or the other to work correctly with the arch/<arch>/Kconfig explicitly stating which one to use?
Yeah I guess the arch would advertise it has the PERF_HLD or ARCH_HLD if it provides its own. HARDLOCKUP_DETECTOR option would then depend on one of the two being defined.
I could try redoing the series with those changes to Kconfig and see how it looks?
Thanks,
Nick
Re: [PATCH 3/4] watchdog: Split up config options
Quoted 27 lines · Nicholas Piggin
Quoted 13 lines
Quoted 5 lines
This would probably be the right direction to go in, but it will take slightly more I think. We first need to remove
HAVE_NMI_WATCHDOGfrom meaning that an arch has its own watchdog and does not want any HLD stuff. I think witharch_touch_nmi_watchdog(), we can probably get there.Quoted 7 lines
While transitioning, we could add a new option instead,
HAVE_ARCH_HARDLOCKUP_DETECTORI think
HAVE_PERF_EVENTS_NMIis sufficient to imply it will use the PERF HLD. Possibly you could just change the name to be a bit more regular,HAVE_PERF_NMI_HARDLOCKUP_DETECTORQuoted 7 lines
Actually, I don't think I can just rename it as it has a specific use to let OPROFILE know the perf events are being NMI triggered as opposed to IRQ triggered.
Though I like the direction you are going. Then arches either have one or the other. Or in the ppc case it is dependent on what ppc platform is being used.
Okay, glad we're on the same page conceptually :)
Quoted 3 lines
Then the
HARDLOCKUP_DETECTORneeds one or the other to work correctly with the arch/<arch>/Kconfig explicitly stating which one to use?
Quoted 6 lines
Yeah I guess the arch would advertise it has the
PERF_HLDorARCH_HLDif it provides its own.HARDLOCKUP_DETECTORoption would then depend on one of the two being defined.I could try redoing the series with those changes to
Kconfigand see how it looks?
Yeah, if you wouldn't mind. Sorry for dragging this out, but I feel like we are getting close to have this defined properly which would allow us to split the code up correctly in the future.
Cheers,
Don
Nicholas Piggin
reviewerRe: [PATCH 3/4] watchdog: Split up config options
Quoted 32 lines · On Mon, 12 Jun 2017 16:41:56 -0400 Don Zickus <[email protected]> wrote:
Quoted 31 lines · Nicholas Piggin
Quoted 13 lines
Quoted 5 lines
This would probably be the right direction to go in, but it will take slightly more I think. We first need to remove
HAVE_NMI_WATCHDOGfrom meaning that an arch has its own watchdog and does not want any HLD stuff. I think witharch_touch_nmi_watchdog(), we can probably get there.Quoted 7 lines
While transitioning, we could add a new option instead,
HAVE_ARCH_HARDLOCKUP_DETECTORI think
HAVE_PERF_EVENTS_NMIis sufficient to imply it will use the PERF HLD. Possibly you could just change the name to be a bit more regular,HAVE_PERF_NMI_HARDLOCKUP_DETECTORQuoted 7 lines
Actually, I don't think I can just rename it as it has a specific use to let OPROFILE know the perf events are being NMI triggered as opposed to IRQ triggered.
Though I like the direction you are going. Then arches either have one or the other. Or in the ppc case it is dependent on what ppc platform is being used.
Okay, glad we're on the same page conceptually :)
Quoted 3 lines
Then the
HARDLOCKUP_DETECTORneeds one or the other to work correctly with the arch/<arch>/Kconfig explicitly stating which one to use?Yeah I guess the arch would advertise it has the
PERF_HLDorARCH_HLDif it provides its own.HARDLOCKUP_DETECTORoption would then depend on one of the two being defined.
Quoted 6 lines
Quoted 2 lines
I could try redoing the series with those changes to
Kconfigand see how it looks?Yeah, if you wouldn't mind. Sorry for dragging this out, but I feel like we are getting close to have this defined properly which would allow us to split the code up correctly in the future.
How's this for a replacement patch 3? I think the Kconfig works out much better now.
--
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.
--- arch/Kconfig | 23 ++++ arch/powerpc/Kconfig | 1 + arch/powerpc/kernel/setup_64.c | 2 +- arch/x86/Kconfig | 1 + arch/x86/kernel/apic/hw_nmi.c | 2 +- include/linux/nmi.h | 29 +++-- kernel/Makefile | 2 +- kernel/sysctl.c | 16 +-- kernel/watchdog.c | 238 ++++++++++++++++++++++++++--------------- kernel/watchdog_hld.c | 32 ------ lib/Kconfig.debug | 26 +++-- 11 files changed, 231 insertions(+), 141 deletions(-)
arch/Kconfig +23 -0
@@ -288,6 +288,29 @@ config HAVE_PERF_EVENTS_NMI subsystem. Also has support for calculating CPU cycle events to determine how many clock cycles in a given period. + +config HAVE_HARDLOCKUP_DETECTOR_PERF + bool + depends on HAVE_PERF_EVENTS_NMI + help + The arch chooses to use the generic perf-NMI-based hardlockup + detector. Must define HAVE_PERF_EVENTS_NMI. + +config HAVE_NMI_WATCHDOG + bool + help + The arch provides a low level NMI watchdog. It provides + asm/nmi.h, and defines its own arch_touch_nmi_watchdog(). + +config HAVE_HARDLOCKUP_DETECTOR_ARCH + bool + select HAVE_NMI_WATCHDOG + help + The arch chooses to provide its own hardlockup detector, which is + a superset of the HAVE_NMI_WATCHDOG. It also conforms to config + interfaces and parameters provided by hardlockup detector subsystem. + + config HAVE_PERF_REGS bool help
arch/powerpc/Kconfig +1 -0
@@ -202,6 +202,7 @@ config PPC select HAVE_OPTPROBES if PPC64 select HAVE_PERF_EVENTS select HAVE_PERF_EVENTS_NMI if PPC64 + select HAVE_HARDLOCKUP_DETECTOR_PERF if HAVE_PERF_EVENTS_NMI select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP select HAVE_RCU_TABLE_FREE if SMP
arch/powerpc/kernel/setup_64.c +1 -1
@@ -727,7 +727,7 @@ struct ppc_pci_io ppc_pci_io;EXPORT_SYMBOL (ppc_pci_io);#endif -#ifdef CONFIG_HARDLOCKUP_DETECTOR +#ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF u64 hw_nmi_get_sample_period (int watchdog_thresh) {return ppc_proc_freq * watchdog_thresh;
arch/x86/Kconfig +1 -0
@@ -157,6 +157,7 @@ config X86 select HAVE_PCSPKR_PLATFORM select HAVE_PERF_EVENTS select HAVE_PERF_EVENTS_NMI + select HAVE_HARDLOCKUP_DETECTOR_PERF if HAVE_PERF_EVENTS_NMI select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP select HAVE_REGS_AND_STACK_ACCESS_API
arch/x86/kernel/apic/hw_nmi.c +1 -1
@@ -19,7 +19,7 @@#include <linux/init.h> #include <linux/delay.h> -#ifdef CONFIG_HARDLOCKUP_DETECTOR +#ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF u64 hw_nmi_get_sample_period (int watchdog_thresh) {return (u64)(cpu_khz) *1000 * watchdog_thresh;
include/linux/nmi.h +20 -9
@@ -11,13 +11,21 @@#endif #ifdef CONFIG_LOCKUP_DETECTOR +void lockup_detector_init (void ); +#else +static inline void lockup_detector_init (void ) +{ +} +#endif + +#ifdef CONFIG_SOFTLOCKUP_DETECTOR extern void touch_softlockup_watchdog_sched (void );extern void touch_softlockup_watchdog (void );extern void touch_softlockup_watchdog_sync (void );extern void touch_all_softlockup_watchdogs (void );extern unsigned int softlockup_panic; -extern unsigned int hardlockup_panic; -void lockup_detector_init (void ); +extern int soft_watchdog_enabled; +extern atomic_t watchdog_park_in_progress;#else static inline void touch_softlockup_watchdog_sched (void ) {
@@ -31,9 +39,6 @@ static inline void touch_softlockup_watchdog_sync(void)static inline void touch_all_softlockup_watchdogs (void ) { } -static inline void lockup_detector_init (void ) -{ -}#endif #ifdef CONFIG_DETECT_HUNG_TASK
@@ -63,15 +68,18 @@ static inline void reset_hung_task_detector(void)#if defined(CONFIG_HARDLOCKUP_DETECTOR )extern void hardlockup_detector_disable (void ); +extern unsigned int hardlockup_panic;#else static inline void hardlockup_detector_disable (void ) {}#endif -#if defined(CONFIG_HARDLOCKUP_DETECTOR ) || defined(CONFIG_HAVE_NMI_WATCHDOG ) +#if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF )extern void arch_touch_nmi_watchdog (void );#else +#if !defined(CONFIG_HAVE_NMI_WATCHDOG )static inline void arch_touch_nmi_watchdog (void ) {}#endif +#endif /** * touch_nmi_watchdog - restart NMI watchdog timeout.
@@ -141,15 +149,18 @@ static inline bool trigger_single_cpu_backtrace(int cpu) }#endif -#ifdef CONFIG_LOCKUP_DETECTOR +#ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF u64 hw_nmi_get_sample_period (int watchdog_thresh); +#endif + +#ifdef CONFIG_LOCKUP_DETECTOR extern int nmi_watchdog_enabled; -extern int soft_watchdog_enabled;extern int watchdog_user_enabled;extern int watchdog_thresh;extern unsigned long watchdog_enabled; +extern struct cpumask watchdog_cpumask;extern unsigned long *watchdog_cpumask_bits; -extern atomic_t watchdog_park_in_progress; +extern int __read_mostly watchdog_suspended;#ifdef CONFIG_SMP extern int sysctl_softlockup_all_cpu_backtrace;extern int sysctl_hardlockup_all_cpu_backtrace;
kernel/Makefile +1 -1
@@ -82,7 +82,7 @@ obj-$(CONFIG_KPROBES) += kprobes.o obj-$(CONFIG_KGDB) += debug/ obj-$(CONFIG_DETECT_HUNG_TASK) += hung_task.o obj-$(CONFIG_LOCKUP_DETECTOR) += watchdog.o -obj-$(CONFIG_HARDLOCKUP_DETECTOR) += watchdog_hld.o +obj-$(CONFIG_HARDLOCKUP_DETECTOR_PERF) += watchdog_hld.o obj-$(CONFIG_SECCOMP) += seccomp.o obj-$(CONFIG_RELAY) += relay.o obj-$(CONFIG_SYSCTL) += utsname_sysctl.o
kernel/sysctl.c +9 -7
@@ -880,6 +880,14 @@ static struct ctl_table kern_table[] = {#endif }, { + .procname = "watchdog_cpumask", + .data = &watchdog_cpumask_bits, + .maxlen = NR_CPUS, + .mode = 0644, + .proc_handler = proc_watchdog_cpumask, + }, +#ifdef CONFIG_SOFTLOCKUP_DETECTOR + { .procname = "soft_watchdog", .data = &soft_watchdog_enabled, .maxlen = sizeof (int),
@@ -889,13 +897,6 @@ static struct ctl_table kern_table[] = { .extra2 = &one, }, { - .procname = "watchdog_cpumask", - .data = &watchdog_cpumask_bits, - .maxlen = NR_CPUS, - .mode = 0644, - .proc_handler = proc_watchdog_cpumask, - }, - { .procname = "softlockup_panic", .data = &softlockup_panic, .maxlen = sizeof(int),
@@ -904,6 +905,7 @@ static struct ctl_table kern_table[] = { .extra1 = &zero, .extra2 = &one, }, +#endif #ifdef CONFIG_HARDLOCKUP_DETECTOR { .procname = "hardlockup_panic",
kernel/watchdog.c +154 -84
314 lines not on this page · raw message
kernel/watchdog_hld.c +0 -32
@@ -22,39 +22,7 @@ static DEFINE_PER_CPU(bool, hard_watchdog_warn); static DEFINE_PER_CPU(bool, watchdog_nmi_touch); static DEFINE_PER_CPU(struct perf_event *, watchdog_ev); -/* boot commands */ -/* -* Should we panic when a soft-lockup or hard-lockup occurs: -*/ -unsigned int __read_mostly hardlockup_panic = -CONFIG_BOOTPARAM_HARDLOCKUP_PANIC_VALUE ;static unsigned long hardlockup_allcpu_dumped; -/* -* We may not want to enable hard lockup detection by default in all cases, -* for example when running the kernel as a guest on a hypervisor. In these -* cases this function can be called to disable hard lockup detection. This -* function should only be executed once by the boot processor before the -* kernel command line parameters are parsed, because otherwise it is not -* possible to override this in hardlockup_panic_setup(). -*/ -void hardlockup_detector_disable (void ) -{ - watchdog_enabled &= ~NMI_WATCHDOG_ENABLED ; -} - -static int __init hardlockup_panic_setup (char *str) -{ -if (!strncmp (str,"panic" ,5 )) - hardlockup_panic =1 ; -else if (!strncmp (str,"nopanic" ,7 )) - hardlockup_panic =0 ; -else if (!strncmp (str,"0" ,1 )) - watchdog_enabled &= ~NMI_WATCHDOG_ENABLED ; -else if (!strncmp (str,"1" ,1 )) - watchdog_enabled |=NMI_WATCHDOG_ENABLED ; -return 1 ; -} -__setup ("nmi_watchdog=" , hardlockup_panic_setup);void arch_touch_nmi_watchdog (void ) {
lib/Kconfig.debug +20 -6
@@ -801,10 +801,24 @@ config LOCKUP_DETECTOR The frequency of hrtimer and NMI events and the soft and hard lockup thresholds can be controlled through the sysctl watchdog_thresh. +config SOFTLOCKUP_DETECTOR + bool "Detect Soft Lockups" + depends on LOCKUP_DETECTOR + +config HARDLOCKUP_DETECTOR_PERF + bool + select SOFTLOCKUP_DETECTOR + +# +# arch/ can define HAVE_HARDLOCKUP_DETECTOR_ARCH to provide their own hard +# lockup detector rather than the perf based detector. +# config HARDLOCKUP_DETECTOR - def_bool y - depends on LOCKUP_DETECTOR && !HAVE_NMI_WATCHDOG - depends on PERF_EVENTS && HAVE_PERF_EVENTS_NMI + bool "Detect Hard Lockups" + depends on LOCKUP_DETECTOR + depends on HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_ARCH + select HARDLOCKUP_DETECTOR_PERF if HAVE_HARDLOCKUP_DETECTOR_PERF + select HARDLOCKUP_DETECTOR_ARCH if HAVE_HARDLOCKUP_DETECTOR_ARCH config BOOTPARAM_HARDLOCKUP_PANIC bool "Panic (Reboot) On Hard Lockups"
@@ -826,7 +840,7 @@ config BOOTPARAM_HARDLOCKUP_PANIC_VALUE config BOOTPARAM_SOFTLOCKUP_PANIC bool "Panic (Reboot) On Soft Lockups" - depends on LOCKUP_DETECTOR + depends on SOFTLOCKUP_DETECTOR help Say Y here to enable the kernel to panic on "soft lockups", which are bugs that cause the kernel to loop in kernel
@@ -843,7 +857,7 @@ config BOOTPARAM_SOFTLOCKUP_PANIC config BOOTPARAM_SOFTLOCKUP_PANIC_VALUE int - depends on LOCKUP_DETECTOR + depends on SOFTLOCKUP_DETECTOR range 0 1 default 0 if !BOOTPARAM_SOFTLOCKUP_PANIC default 1 if BOOTPARAM_SOFTLOCKUP_PANIC
@@ -851,7 +865,7 @@ config BOOTPARAM_SOFTLOCKUP_PANIC_VALUE config DETECT_HUNG_TASK bool "Detect Hung Tasks" depends on DEBUG_KERNEL - default LOCKUP_DETECTOR + default SOFTLOCKUP_DETECTOR help Say Y here to enable the kernel to detect "hung tasks", which are bugs that cause the task to be stuck in
Signature · 1 line
2.11.0
Re: [PATCH 3/4] watchdog: Split up config options
Quoted 6 lines · Nicholas Piggin
Quoted 3 lines
Yeah, if you wouldn't mind. Sorry for dragging this out, but I feel like we are getting close to have this defined properly which would allow us to split the code up correctly in the future.
How's this for a replacement patch 3? I think the
Kconfigworks out much better now.
Hi Nick,
I think you made this much clearer, thank you! I am good with this.
Hi Babu,
Can you give this patchset (and particularly this version of patch 3) a try on sparc to make sure we didn't break anything? I believe this should resolve the start nmi watchdog on boot issue you noticed. Thanks!
Cheers,
Don
Quoted 686 lines
--
Split
SOFTLOCKUP_DETECTORfromLOCKUP_DETECTOR, and splitHARDLOCKUP_DETECTOR_PERFfromHARDLOCKUP_DETECTOR.
LOCKUP_DETECTORimplies 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_PERForHAVE_HARDLOCKUP_DETECTOR_ARCH.Alternatively an arch can define
HAVE_NMI_WATCHDOG, which provides the minimumarch_touch_nmi_watchdog, and it otherwise does its own thing and does not implement theLOCKUP_DETECTORinterfaces.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.Signed-off-by Nicholas Piggin <[email protected]>--- arch/Kconfig | 23 ++++ arch/powerpc/Kconfig | 1 + arch/powerpc/kernel/setup_64.c | 2 +- arch/x86/Kconfig | 1 + arch/x86/kernel/apic/hw_nmi.c | 2 +- include/linux/nmi.h | 29 +++-- kernel/Makefile | 2 +- kernel/sysctl.c | 16 +-- kernel/watchdog.c | 238 ++++++++++++++++++++++++++--------------- kernel/watchdog_hld.c | 32 ------ lib/Kconfig.debug | 26 +++-- 11 files changed, 231 insertions(+), 141 deletions(-)arch/Kconfig +23
-0@@ -288,6 +288,29 @@ config HAVE_PERF_EVENTS_NMI subsystem. Also has support for calculating CPU cycle events to determine how many clock cycles in a given period. + +config HAVE_HARDLOCKUP_DETECTOR_PERF + bool + depends on HAVE_PERF_EVENTS_NMI + help + The arch chooses to use the generic perf-NMI-based hardlockup + detector. Must define HAVE_PERF_EVENTS_NMI. + +config HAVE_NMI_WATCHDOG + bool + help + The arch provides a low level NMI watchdog. It provides + asm/nmi.h, and defines its own arch_touch_nmi_watchdog(). + +config HAVE_HARDLOCKUP_DETECTOR_ARCH + bool + select HAVE_NMI_WATCHDOG + help + The arch chooses to provide its own hardlockup detector, which is + a superset of the HAVE_NMI_WATCHDOG. It also conforms to config + interfaces and parameters provided by hardlockup detector subsystem. + + config HAVE_PERF_REGS bool helparch/powerpc/Kconfig +1
-0@@ -202,6 +202,7 @@ config PPC select HAVE_OPTPROBES if PPC64 select HAVE_PERF_EVENTS select HAVE_PERF_EVENTS_NMI if PPC64 + select HAVE_HARDLOCKUP_DETECTOR_PERF if HAVE_PERF_EVENTS_NMI select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP select HAVE_RCU_TABLE_FREE if SMParch/powerpc/kernel/setup_64.c +1
-1@@ -727,7 +727,7 @@ struct ppc_pci_io ppc_pci_io;EXPORT_SYMBOL (ppc_pci_io);#endif -#ifdef CONFIG_HARDLOCKUP_DETECTOR +#ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF u64 hw_nmi_get_sample_period (int watchdog_thresh) {return ppc_proc_freq * watchdog_thresh;arch/x86/Kconfig +1
-0@@ -157,6 +157,7 @@ config X86 select HAVE_PCSPKR_PLATFORM select HAVE_PERF_EVENTS select HAVE_PERF_EVENTS_NMI + select HAVE_HARDLOCKUP_DETECTOR_PERF if HAVE_PERF_EVENTS_NMI select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP select HAVE_REGS_AND_STACK_ACCESS_APIarch/x86/kernel/apic/hw_nmi.c +1
-1@@ -19,7 +19,7 @@#include <linux/init.h> #include <linux/delay.h> -#ifdef CONFIG_HARDLOCKUP_DETECTOR +#ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF u64 hw_nmi_get_sample_period (int watchdog_thresh) {return (u64)(cpu_khz) *1000 * watchdog_thresh;include/linux/nmi.h +20
-9@@ -11,13 +11,21 @@#endif #ifdef CONFIG_LOCKUP_DETECTOR +void lockup_detector_init (void ); +#else +static inline void lockup_detector_init (void ) +{ +} +#endif + +#ifdef CONFIG_SOFTLOCKUP_DETECTOR extern void touch_softlockup_watchdog_sched (void );extern void touch_softlockup_watchdog (void );extern void touch_softlockup_watchdog_sync (void );extern void touch_all_softlockup_watchdogs (void );extern unsigned int softlockup_panic; -extern unsigned int hardlockup_panic; -void lockup_detector_init (void ); +extern int soft_watchdog_enabled; +extern atomic_t watchdog_park_in_progress;#else static inline void touch_softlockup_watchdog_sched (void ) {@@ -31,9 +39,6 @@ static inline void touch_softlockup_watchdog_sync(void)static inline void touch_all_softlockup_watchdogs (void ) { } -static inline void lockup_detector_init (void ) -{ -}#endif #ifdef CONFIG_DETECT_HUNG_TASK @@ -63,15 +68,18 @@ static inline void reset_hung_task_detector(void)#if defined(CONFIG_HARDLOCKUP_DETECTOR )extern void hardlockup_detector_disable (void ); +extern unsigned int hardlockup_panic;#else static inline void hardlockup_detector_disable (void ) {}#endif -#if defined(CONFIG_HARDLOCKUP_DETECTOR ) || defined(CONFIG_HAVE_NMI_WATCHDOG ) +#if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF )extern void arch_touch_nmi_watchdog (void );#else +#if !defined(CONFIG_HAVE_NMI_WATCHDOG )static inline void arch_touch_nmi_watchdog (void ) {}#endif +#endif /** * touch_nmi_watchdog - restart NMI watchdog timeout. @@ -141,15 +149,18 @@ static inline bool trigger_single_cpu_backtrace(int cpu) }#endif -#ifdef CONFIG_LOCKUP_DETECTOR +#ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF u64 hw_nmi_get_sample_period (int watchdog_thresh); +#endif + +#ifdef CONFIG_LOCKUP_DETECTOR extern int nmi_watchdog_enabled; -extern int soft_watchdog_enabled;extern int watchdog_user_enabled;extern int watchdog_thresh;extern unsigned long watchdog_enabled; +extern struct cpumask watchdog_cpumask;extern unsigned long *watchdog_cpumask_bits; -extern atomic_t watchdog_park_in_progress; +extern int __read_mostly watchdog_suspended;#ifdef CONFIG_SMP extern int sysctl_softlockup_all_cpu_backtrace;extern int sysctl_hardlockup_all_cpu_backtrace;kernel/Makefile +1
-1@@ -82,7 +82,7 @@ obj-$(CONFIG_KPROBES) += kprobes.o obj-$(CONFIG_KGDB) += debug/ obj-$(CONFIG_DETECT_HUNG_TASK) += hung_task.o obj-$(CONFIG_LOCKUP_DETECTOR) += watchdog.o -obj-$(CONFIG_HARDLOCKUP_DETECTOR) += watchdog_hld.o +obj-$(CONFIG_HARDLOCKUP_DETECTOR_PERF) += watchdog_hld.o obj-$(CONFIG_SECCOMP) += seccomp.o obj-$(CONFIG_RELAY) += relay.o obj-$(CONFIG_SYSCTL) += utsname_sysctl.okernel/sysctl.c +9
-7@@ -880,6 +880,14 @@ static struct ctl_table kern_table[] = {#endif }, { + .procname = "watchdog_cpumask", + .data = &watchdog_cpumask_bits, + .maxlen = NR_CPUS, + .mode = 0644, + .proc_handler = proc_watchdog_cpumask, + }, +#ifdef CONFIG_SOFTLOCKUP_DETECTOR + { .procname = "soft_watchdog", .data = &soft_watchdog_enabled, .maxlen = sizeof (int),@@ -889,13 +897,6 @@ static struct ctl_table kern_table[] = { .extra2 = &one, }, { - .procname = "watchdog_cpumask", - .data = &watchdog_cpumask_bits, - .maxlen = NR_CPUS, - .mode = 0644, - .proc_handler = proc_watchdog_cpumask, - }, - { .procname = "softlockup_panic", .data = &softlockup_panic, .maxlen = sizeof(int),@@ -904,6 +905,7 @@ static struct ctl_table kern_table[] = { .extra1 = &zero, .extra2 = &one, }, +#endif #ifdef CONFIG_HARDLOCKUP_DETECTOR { .procname = "hardlockup_panic",kernel/watchdog.c +154
-84@@ -29,15 +29,55 @@#include <linux/kvm_para.h> #include <linux/kthread.h> +/* Watchdog configuration */ static DEFINE_MUTEX (watchdog_proc_mutex); -#if defined(CONFIG_HAVE_NMI_WATCHDOG ) || defined(CONFIG_HARDLOCKUP_DETECTOR ) +int __read_mostly nmi_watchdog_enabled; + +#ifdef CONFIG_HARDLOCKUP_DETECTOR unsigned long __read_mostly watchdog_enabled =SOFT_WATCHDOG_ENABLED |NMI_WATCHDOG_ENABLED ; + +/* boot commands */ +/* +* Should we panic when a soft-lockup or hard-lockup occurs: +*/ +unsigned int __read_mostly hardlockup_panic = +CONFIG_BOOTPARAM_HARDLOCKUP_PANIC_VALUE ; +/* +* We may not want to enable hard lockup detection by default in all cases, +* for example when running the kernel as a guest on a hypervisor. In these +* cases this function can be called to disable hard lockup detection. This +* function should only be executed once by the boot processor before the +* kernel command line parameters are parsed, because otherwise it is not +* possible to override this in hardlockup_panic_setup(). +*/ +void hardlockup_detector_disable (void ) +{ + watchdog_enabled &= ~NMI_WATCHDOG_ENABLED ; +} + +static int __init hardlockup_panic_setup (char *str) +{ +if (!strncmp (str,"panic" ,5 )) + hardlockup_panic =1 ; +else if (!strncmp (str,"nopanic" ,7 )) + hardlockup_panic =0 ; +else if (!strncmp (str,"0" ,1 )) + watchdog_enabled &= ~NMI_WATCHDOG_ENABLED ; +else if (!strncmp (str,"1" ,1 )) + watchdog_enabled |=NMI_WATCHDOG_ENABLED ; +return 1 ; +} +__setup ("nmi_watchdog=" , hardlockup_panic_setup); +#else unsigned long __read_mostly watchdog_enabled =SOFT_WATCHDOG_ENABLED ;#endif -int __read_mostly nmi_watchdog_enabled; + +#ifdef CONFIG_SOFTLOCKUP_DETECTOR int __read_mostly soft_watchdog_enabled; +#endif +int __read_mostly watchdog_user_enabled;int __read_mostly watchdog_thresh =10 ;@@ -45,15 +85,9 @@ int __read_mostly watchdog_thresh = 10;int __read_mostly sysctl_softlockup_all_cpu_backtrace;int __read_mostly sysctl_hardlockup_all_cpu_backtrace;#endif -static struct cpumask watchdog_cpumask__read_mostly ; +struct cpumask watchdog_cpumask__read_mostly ;unsigned long *watchdog_cpumask_bits =cpumask_bits (&watchdog_cpumask); -/* Helper for online, unparked cpus. */ -#define for_each_watchdog_cpu (cpu) \ - for_each_cpu_and((cpu), cpu_online_mask, &watchdog_cpumask) - -atomic_t watchdog_park_in_progress =ATOMIC_INIT (0 ); -/* * The 'watchdog_running' variable is set to 1 when the watchdog threads * are registered/started and is set to 0 when the watchdog threads are @@ -72,7 +106,27 @@ static int __read_mostly watchdog_running;* of 'watchdog_running' cannot change while the watchdog is deactivated * temporarily (see related code in 'proc' handlers). */ -static int __read_mostly watchdog_suspended; +int __read_mostly watchdog_suspended; + +/* +* These functions can be overridden if an architecture implements its +* own hardlockup detector. +*/ +int __weak watchdog_nmi_enable (unsigned int cpu) +{ +return 0 ; +} +void __weak watchdog_nmi_disable (unsigned int cpu) +{ +} + +#ifdef CONFIG_SOFTLOCKUP_DETECTOR + +/* Helper for online, unparked cpus. */ +#define for_each_watchdog_cpu (cpu) \ + for_each_cpu_and((cpu), cpu_online_mask, &watchdog_cpumask) + +atomic_t watchdog_park_in_progress =ATOMIC_INIT (0 );static u64 __read_mostly sample_period;@@ -120,6 +174,7 @@ static int __init softlockup_all_cpu_backtrace_setup(char *str)return 1 ; }__setup ("softlockup_all_cpu_backtrace=" , softlockup_all_cpu_backtrace_setup); +#ifdef CONFIG_HARDLOCKUP_DETECTOR static int __init hardlockup_all_cpu_backtrace_setup (char *str) { sysctl_hardlockup_all_cpu_backtrace =@@ -128,6 +183,7 @@ static int __init hardlockup_all_cpu_backtrace_setup(char *str) }__setup ("hardlockup_all_cpu_backtrace=" , hardlockup_all_cpu_backtrace_setup);#endif +#endif /* * Hard-lockup warnings should be triggered after just a few seconds. Soft- @@ -213,18 +269,6 @@ void touch_softlockup_watchdog_sync(void)__this_cpu_write (watchdog_touch_ts,0 ); } -/* watchdog detector functions */ -bool is_hardlockup (void ) -{ -unsigned long hrint =__this_cpu_read (hrtimer_interrupts); - -if (__this_cpu_read (hrtimer_interrupts_saved) == hrint) -return true; - -__this_cpu_write (hrtimer_interrupts_saved, hrint); -return false; -} -static int is_softlockup (unsigned long touch_ts) {unsigned long now =get_timestamp ();@@ -237,21 +281,21 @@ static int is_softlockup(unsigned long touch_ts)return 0 ; } -static void watchdog_interrupt_count (void ) +/* watchdog detector functions */ +bool is_hardlockup (void ) { -__this_cpu_inc (hrtimer_interrupts); -} +unsigned long hrint =__this_cpu_read (hrtimer_interrupts); -/* -* These two functions are mostly architecture specific -* defining them as weak here. -*/ -int __weak watchdog_nmi_enable (unsigned int cpu) -{ -return 0 ; +if (__this_cpu_read (hrtimer_interrupts_saved) == hrint) +return true; + +__this_cpu_write (hrtimer_interrupts_saved, hrint); +return false; } -void __weak watchdog_nmi_disable (unsigned int cpu) + +static void watchdog_interrupt_count (void ) { +__this_cpu_inc (hrtimer_interrupts); }static int watchdog_enable_all_cpus (void );@@ -502,57 +546,6 @@ static void watchdog_unpark_threads(void)kthread_unpark (per_cpu (softlockup_watchdog, cpu)); } -/* -* Suspend the hard and soft lockup detector by parking the watchdog threads. -*/ -int lockup_detector_suspend (void ) -{ -int ret =0 ; - -get_online_cpus (); -mutex_lock (&watchdog_proc_mutex); -/* -* Multiple suspend requests can be active in parallel (counted by -* the 'watchdog_suspended' variable). If the watchdog threads are -* running, the first caller takes care that they will be parked. -* The state of 'watchdog_running' cannot change while a suspend -* request is active (see related code in 'proc' handlers). -*/ -if (watchdog_running && !watchdog_suspended) - ret =watchdog_park_threads (); - -if (ret ==0 ) - watchdog_suspended++; -else { -watchdog_disable_all_cpus (); -pr_err ("Failed to suspend lockup detectors, disabled\n" ); - watchdog_enabled =0 ; - } - -mutex_unlock (&watchdog_proc_mutex); - -return ret; -} - -/* -* Resume the hard and soft lockup detector by unparking the watchdog threads. -*/ -void lockup_detector_resume (void ) -{ -mutex_lock (&watchdog_proc_mutex); - - watchdog_suspended--; -/* -* The watchdog threads are unparked if they were previously running -* and if there is no more active suspend request. -*/ -if (watchdog_running && !watchdog_suspended) -watchdog_unpark_threads (); - -mutex_unlock (&watchdog_proc_mutex); -put_online_cpus (); -} -static int update_watchdog_all_cpus (void ) {int ret;@@ -604,6 +597,81 @@ static void watchdog_disable_all_cpus(void) } } +#else /* SOFTLOCKUP */ +static int watchdog_park_threads (void ) +{ +return 0 ; +} + +static void watchdog_unpark_threads (void ) +{ +} + +static int watchdog_enable_all_cpus (void ) +{ +return 0 ; +} + +static void watchdog_disable_all_cpus (void ) +{ +} + +static void set_sample_period (void ) +{ +} +#endif /* SOFTLOCKUP */ + +/* +* Suspend the hard and soft lockup detector by parking the watchdog threads. +*/ +int lockup_detector_suspend (void ) +{ +int ret =0 ; + +get_online_cpus (); +mutex_lock (&watchdog_proc_mutex); +/* +* Multiple suspend requests can be active in parallel (counted by +* the 'watchdog_suspended' variable). If the watchdog threads are +* running, the first caller takes care that they will be parked. +* The state of 'watchdog_running' cannot change while a suspend +* request is active (see related code in 'proc' handlers). +*/ +if (watchdog_running && !watchdog_suspended) + ret =watchdog_park_threads (); + +if (ret ==0 ) + watchdog_suspended++; +else { +watchdog_disable_all_cpus (); +pr_err ("Failed to suspend lockup detectors, disabled\n" ); + watchdog_enabled =0 ; + } + +mutex_unlock (&watchdog_proc_mutex); + +return ret; +} + +/* +* Resume the hard and soft lockup detector by unparking the watchdog threads. +*/ +void lockup_detector_resume (void ) +{ +mutex_lock (&watchdog_proc_mutex); + + watchdog_suspended--; +/* +* The watchdog threads are unparked if they were previously running +* and if there is no more active suspend request. +*/ +if (watchdog_running && !watchdog_suspended) +watchdog_unpark_threads (); + +mutex_unlock (&watchdog_proc_mutex); +put_online_cpus (); +} +#ifdef CONFIG_SYSCTL /* @@ -810,9 +878,11 @@ int proc_watchdog_cpumask(struct ctl_table *table, int write,* a temporary cpumask, so we are likely not in a * position to do much else to make things better. */ +#ifdef CONFIG_SOFTLOCKUP_DETECTOR if (smpboot_update_cpumask_percpu_thread ( &watchdog_threads, &watchdog_cpumask) !=0 )pr_err ("cpumask update failed\n" ); +#endif } } out:kernel/watchdog_hld.c +0
-32@@ -22,39 +22,7 @@ static DEFINE_PER_CPU(bool, hard_watchdog_warn); static DEFINE_PER_CPU(bool, watchdog_nmi_touch); static DEFINE_PER_CPU(struct perf_event *, watchdog_ev); -/* boot commands */ -/* -* Should we panic when a soft-lockup or hard-lockup occurs: -*/ -unsigned int __read_mostly hardlockup_panic = -CONFIG_BOOTPARAM_HARDLOCKUP_PANIC_VALUE ;static unsigned long hardlockup_allcpu_dumped; -/* -* We may not want to enable hard lockup detection by default in all cases, -* for example when running the kernel as a guest on a hypervisor. In these -* cases this function can be called to disable hard lockup detection. This -* function should only be executed once by the boot processor before the -* kernel command line parameters are parsed, because otherwise it is not -* possible to override this in hardlockup_panic_setup(). -*/ -void hardlockup_detector_disable (void ) -{ - watchdog_enabled &= ~NMI_WATCHDOG_ENABLED ; -} - -static int __init hardlockup_panic_setup (char *str) -{ -if (!strncmp (str,"panic" ,5 )) - hardlockup_panic =1 ; -else if (!strncmp (str,"nopanic" ,7 )) - hardlockup_panic =0 ; -else if (!strncmp (str,"0" ,1 )) - watchdog_enabled &= ~NMI_WATCHDOG_ENABLED ; -else if (!strncmp (str,"1" ,1 )) - watchdog_enabled |=NMI_WATCHDOG_ENABLED ; -return 1 ; -} -__setup ("nmi_watchdog=" , hardlockup_panic_setup);void arch_touch_nmi_watchdog (void ) {lib/Kconfig.debug +20
-6@@ -801,10 +801,24 @@ config LOCKUP_DETECTOR The frequency of hrtimer and NMI events and the soft and hard lockup thresholds can be controlled through the sysctl watchdog_thresh. +config SOFTLOCKUP_DETECTOR + bool "Detect Soft Lockups" + depends on LOCKUP_DETECTOR + +config HARDLOCKUP_DETECTOR_PERF + bool + select SOFTLOCKUP_DETECTOR + +# +# arch/ can define HAVE_HARDLOCKUP_DETECTOR_ARCH to provide their own hard +# lockup detector rather than the perf based detector. +# config HARDLOCKUP_DETECTOR - def_bool y - depends on LOCKUP_DETECTOR && !HAVE_NMI_WATCHDOG - depends on PERF_EVENTS && HAVE_PERF_EVENTS_NMI + bool "Detect Hard Lockups" + depends on LOCKUP_DETECTOR + depends on HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_ARCH + select HARDLOCKUP_DETECTOR_PERF if HAVE_HARDLOCKUP_DETECTOR_PERF + select HARDLOCKUP_DETECTOR_ARCH if HAVE_HARDLOCKUP_DETECTOR_ARCH config BOOTPARAM_HARDLOCKUP_PANIC bool "Panic (Reboot) On Hard Lockups"@@ -826,7 +840,7 @@ config BOOTPARAM_HARDLOCKUP_PANIC_VALUE config BOOTPARAM_SOFTLOCKUP_PANIC bool "Panic (Reboot) On Soft Lockups" - depends on LOCKUP_DETECTOR + depends on SOFTLOCKUP_DETECTOR help Say Y here to enable the kernel to panic on "soft lockups", which are bugs that cause the kernel to loop in kernel@@ -843,7 +857,7 @@ config BOOTPARAM_SOFTLOCKUP_PANIC config BOOTPARAM_SOFTLOCKUP_PANIC_VALUE int - depends on LOCKUP_DETECTOR + depends on SOFTLOCKUP_DETECTOR range 0 1 default 0 if !BOOTPARAM_SOFTLOCKUP_PANIC default 1 if BOOTPARAM_SOFTLOCKUP_PANIC@@ -851,7 +865,7 @@ config BOOTPARAM_SOFTLOCKUP_PANIC_VALUE config DETECT_HUNG_TASK bool "Detect Hung Tasks" depends on DEBUG_KERNEL - default LOCKUP_DETECTOR + default SOFTLOCKUP_DETECTOR help Say Y here to enable the kernel to detect "hung tasks", which are bugs that cause the task to be stuck inSignature · 1 line
2.11.0
Re: [PATCH 3/4] watchdog: Split up config options
Hi Don,
Quoted 8 lines · Don Zickus
Quoted 5 lines · Nicholas Piggin
Quoted 3 lines
Yeah, if you wouldn't mind. Sorry for dragging this out, but I feel like we are getting close to have this defined properly which would allow us to split the code up correctly in the future.
How's this for a replacement patch 3? I think the
Kconfigworks out much better now.Hi Nick,
Quoted 8 lines
I think you made this much clearer, thank you! I am good with this.
Hi Babu,
Can you give this patchset (and particularly this version of patch 3) a try on sparc to make sure we didn't break anything? I believe this should resolve the start nmi watchdog on boot issue you noticed. Thanks!
There is still one problem with the patch.
# cat /proc/sys/kernel/watchdog 1 # cat /proc/sys/kernel/nmi_watchdog 0
Problem is setting the initial value for "nmi_watchdog"
We need something(or similar) patch on top to address this.
============================================
kernel/watchdog.c +1 -1
@@ -34,9 +34,13 @@int __read_mostly nmi_watchdog_enabled; -#ifdef CONFIG_HARDLOCKUP_DETECTOR +#if defined(CONFIG_HARDLOCKUP_DETECTOR ) || defined(CONFIG_HAVE_NMI_WATCHDOG ) unsigned long __read_mostly watchdog_enabled =
SOFT_WATCHDOG_ENABLED|NMI_WATCHDOG_ENABLED;
+#else
+unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED; +#endif
+#ifdef CONFIG_HARDLOCKUP_DETECTOR
/* boot commands */
/*
* Should we panic when a soft-lockup or hard-lockup occurs:
@@ -69,9 +73,6 @@ static int __init hardlockup_panic_setup(char *str)
return 1;
}
__setup("nmi_watchdog=", hardlockup_panic_setup);
-
-#else
-unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED;
#endif
#ifdef CONFIG_SOFTLOCKUP_DETECTOR
Quoted 690 lines
Cheers,
DonQuoted 686 lines
--
Split
SOFTLOCKUP_DETECTORfromLOCKUP_DETECTOR, and splitHARDLOCKUP_DETECTOR_PERFfromHARDLOCKUP_DETECTOR.
LOCKUP_DETECTORimplies 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_PERForHAVE_HARDLOCKUP_DETECTOR_ARCH.Alternatively an arch can define
HAVE_NMI_WATCHDOG, which provides the minimumarch_touch_nmi_watchdog, and it otherwise does its own thing and does not implement theLOCKUP_DETECTORinterfaces.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.Signed-off-by Nicholas Piggin <[email protected]>--- arch/Kconfig | 23 ++++ arch/powerpc/Kconfig | 1 + arch/powerpc/kernel/setup_64.c | 2 +- arch/x86/Kconfig | 1 + arch/x86/kernel/apic/hw_nmi.c | 2 +- include/linux/nmi.h | 29 +++-- kernel/Makefile | 2 +- kernel/sysctl.c | 16 +-- kernel/watchdog.c | 238 ++++++++++++++++++++++++++--------------- kernel/watchdog_hld.c | 32 ------ lib/Kconfig.debug | 26 +++-- 11 files changed, 231 insertions(+), 141 deletions(-)arch/Kconfig +23
-0@@ -288,6 +288,29 @@ config HAVE_PERF_EVENTS_NMI subsystem. Also has support for calculating CPU cycle events to determine how many clock cycles in a given period. + +config HAVE_HARDLOCKUP_DETECTOR_PERF + bool + depends on HAVE_PERF_EVENTS_NMI + help + The arch chooses to use the generic perf-NMI-based hardlockup + detector. Must define HAVE_PERF_EVENTS_NMI. + +config HAVE_NMI_WATCHDOG + bool + help + The arch provides a low level NMI watchdog. It provides + asm/nmi.h, and defines its own arch_touch_nmi_watchdog(). + +config HAVE_HARDLOCKUP_DETECTOR_ARCH + bool + select HAVE_NMI_WATCHDOG + help + The arch chooses to provide its own hardlockup detector, which is + a superset of the HAVE_NMI_WATCHDOG. It also conforms to config + interfaces and parameters provided by hardlockup detector subsystem. + + config HAVE_PERF_REGS bool helparch/powerpc/Kconfig +1
-0@@ -202,6 +202,7 @@ config PPC select HAVE_OPTPROBES if PPC64 select HAVE_PERF_EVENTS select HAVE_PERF_EVENTS_NMI if PPC64 + select HAVE_HARDLOCKUP_DETECTOR_PERF if HAVE_PERF_EVENTS_NMI select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP select HAVE_RCU_TABLE_FREE if SMParch/powerpc/kernel/setup_64.c +1
-1@@ -727,7 +727,7 @@ struct ppc_pci_io ppc_pci_io;EXPORT_SYMBOL (ppc_pci_io);#endif -#ifdef CONFIG_HARDLOCKUP_DETECTOR +#ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF u64 hw_nmi_get_sample_period (int watchdog_thresh) {return ppc_proc_freq * watchdog_thresh;arch/x86/Kconfig +1
-0@@ -157,6 +157,7 @@ config X86 select HAVE_PCSPKR_PLATFORM select HAVE_PERF_EVENTS select HAVE_PERF_EVENTS_NMI + select HAVE_HARDLOCKUP_DETECTOR_PERF if HAVE_PERF_EVENTS_NMI select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP select HAVE_REGS_AND_STACK_ACCESS_APIarch/x86/kernel/apic/hw_nmi.c +1
-1@@ -19,7 +19,7 @@#include <linux/init.h> #include <linux/delay.h> -#ifdef CONFIG_HARDLOCKUP_DETECTOR +#ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF u64 hw_nmi_get_sample_period (int watchdog_thresh) {return (u64)(cpu_khz) *1000 * watchdog_thresh;include/linux/nmi.h +20
-9@@ -11,13 +11,21 @@#endif #ifdef CONFIG_LOCKUP_DETECTOR +void lockup_detector_init (void ); +#else +static inline void lockup_detector_init (void ) +{ +} +#endif + +#ifdef CONFIG_SOFTLOCKUP_DETECTOR extern void touch_softlockup_watchdog_sched (void );extern void touch_softlockup_watchdog (void );extern void touch_softlockup_watchdog_sync (void );extern void touch_all_softlockup_watchdogs (void );extern unsigned int softlockup_panic; -extern unsigned int hardlockup_panic; -void lockup_detector_init (void ); +extern int soft_watchdog_enabled; +extern atomic_t watchdog_park_in_progress;#else static inline void touch_softlockup_watchdog_sched (void ) {@@ -31,9 +39,6 @@ static inline void touch_softlockup_watchdog_sync(void)static inline void touch_all_softlockup_watchdogs (void ) { } -static inline void lockup_detector_init (void ) -{ -}#endif #ifdef CONFIG_DETECT_HUNG_TASK @@ -63,15 +68,18 @@ static inline void reset_hung_task_detector(void)#if defined(CONFIG_HARDLOCKUP_DETECTOR )extern void hardlockup_detector_disable (void ); +extern unsigned int hardlockup_panic;#else static inline void hardlockup_detector_disable (void ) {}#endif -#if defined(CONFIG_HARDLOCKUP_DETECTOR ) || defined(CONFIG_HAVE_NMI_WATCHDOG ) +#if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF )extern void arch_touch_nmi_watchdog (void );#else +#if !defined(CONFIG_HAVE_NMI_WATCHDOG )static inline void arch_touch_nmi_watchdog (void ) {}#endif +#endif /** * touch_nmi_watchdog - restart NMI watchdog timeout. @@ -141,15 +149,18 @@ static inline bool trigger_single_cpu_backtrace(int cpu) }#endif -#ifdef CONFIG_LOCKUP_DETECTOR +#ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF u64 hw_nmi_get_sample_period (int watchdog_thresh); +#endif + +#ifdef CONFIG_LOCKUP_DETECTOR extern int nmi_watchdog_enabled; -extern int soft_watchdog_enabled;extern int watchdog_user_enabled;extern int watchdog_thresh;extern unsigned long watchdog_enabled; +extern struct cpumask watchdog_cpumask;extern unsigned long *watchdog_cpumask_bits; -extern atomic_t watchdog_park_in_progress; +extern int __read_mostly watchdog_suspended;#ifdef CONFIG_SMP extern int sysctl_softlockup_all_cpu_backtrace;extern int sysctl_hardlockup_all_cpu_backtrace;kernel/Makefile +1
-1@@ -82,7 +82,7 @@ obj-$(CONFIG_KPROBES) += kprobes.o obj-$(CONFIG_KGDB) += debug/ obj-$(CONFIG_DETECT_HUNG_TASK) += hung_task.o obj-$(CONFIG_LOCKUP_DETECTOR) += watchdog.o -obj-$(CONFIG_HARDLOCKUP_DETECTOR) += watchdog_hld.o +obj-$(CONFIG_HARDLOCKUP_DETECTOR_PERF) += watchdog_hld.o obj-$(CONFIG_SECCOMP) += seccomp.o obj-$(CONFIG_RELAY) += relay.o obj-$(CONFIG_SYSCTL) += utsname_sysctl.okernel/sysctl.c +9
-7@@ -880,6 +880,14 @@ static struct ctl_table kern_table[] = {#endif }, { + .procname = "watchdog_cpumask", + .data = &watchdog_cpumask_bits, + .maxlen = NR_CPUS, + .mode = 0644, + .proc_handler = proc_watchdog_cpumask, + }, +#ifdef CONFIG_SOFTLOCKUP_DETECTOR + { .procname = "soft_watchdog", .data = &soft_watchdog_enabled, .maxlen = sizeof (int),@@ -889,13 +897,6 @@ static struct ctl_table kern_table[] = { .extra2 = &one, }, { - .procname = "watchdog_cpumask", - .data = &watchdog_cpumask_bits, - .maxlen = NR_CPUS, - .mode = 0644, - .proc_handler = proc_watchdog_cpumask, - }, - { .procname = "softlockup_panic", .data = &softlockup_panic, .maxlen = sizeof(int),@@ -904,6 +905,7 @@ static struct ctl_table kern_table[] = { .extra1 = &zero, .extra2 = &one, }, +#endif #ifdef CONFIG_HARDLOCKUP_DETECTOR { .procname = "hardlockup_panic",kernel/watchdog.c +154
-84@@ -29,15 +29,55 @@#include <linux/kvm_para.h> #include <linux/kthread.h> +/* Watchdog configuration */ static DEFINE_MUTEX (watchdog_proc_mutex); -#if defined(CONFIG_HAVE_NMI_WATCHDOG ) || defined(CONFIG_HARDLOCKUP_DETECTOR ) +int __read_mostly nmi_watchdog_enabled; + +#ifdef CONFIG_HARDLOCKUP_DETECTOR unsigned long __read_mostly watchdog_enabled =SOFT_WATCHDOG_ENABLED |NMI_WATCHDOG_ENABLED ; + +/* boot commands */ +/* +* Should we panic when a soft-lockup or hard-lockup occurs: +*/ +unsigned int __read_mostly hardlockup_panic = +CONFIG_BOOTPARAM_HARDLOCKUP_PANIC_VALUE ; +/* +* We may not want to enable hard lockup detection by default in all cases, +* for example when running the kernel as a guest on a hypervisor. In these +* cases this function can be called to disable hard lockup detection. This +* function should only be executed once by the boot processor before the +* kernel command line parameters are parsed, because otherwise it is not +* possible to override this in hardlockup_panic_setup(). +*/ +void hardlockup_detector_disable (void ) +{ + watchdog_enabled &= ~NMI_WATCHDOG_ENABLED ; +} + +static int __init hardlockup_panic_setup (char *str) +{ +if (!strncmp (str,"panic" ,5 )) + hardlockup_panic =1 ; +else if (!strncmp (str,"nopanic" ,7 )) + hardlockup_panic =0 ; +else if (!strncmp (str,"0" ,1 )) + watchdog_enabled &= ~NMI_WATCHDOG_ENABLED ; +else if (!strncmp (str,"1" ,1 )) + watchdog_enabled |=NMI_WATCHDOG_ENABLED ; +return 1 ; +} +__setup ("nmi_watchdog=" , hardlockup_panic_setup); +#else unsigned long __read_mostly watchdog_enabled =SOFT_WATCHDOG_ENABLED ;#endif -int __read_mostly nmi_watchdog_enabled; + +#ifdef CONFIG_SOFTLOCKUP_DETECTOR int __read_mostly soft_watchdog_enabled; +#endif +int __read_mostly watchdog_user_enabled;int __read_mostly watchdog_thresh =10 ;@@ -45,15 +85,9 @@ int __read_mostly watchdog_thresh = 10;int __read_mostly sysctl_softlockup_all_cpu_backtrace;int __read_mostly sysctl_hardlockup_all_cpu_backtrace;#endif -static struct cpumask watchdog_cpumask__read_mostly ; +struct cpumask watchdog_cpumask__read_mostly ;unsigned long *watchdog_cpumask_bits =cpumask_bits (&watchdog_cpumask); -/* Helper for online, unparked cpus. */ -#define for_each_watchdog_cpu (cpu) \ - for_each_cpu_and((cpu), cpu_online_mask, &watchdog_cpumask) - -atomic_t watchdog_park_in_progress =ATOMIC_INIT (0 ); -/* * The 'watchdog_running' variable is set to 1 when the watchdog threads * are registered/started and is set to 0 when the watchdog threads are @@ -72,7 +106,27 @@ static int __read_mostly watchdog_running;* of 'watchdog_running' cannot change while the watchdog is deactivated * temporarily (see related code in 'proc' handlers). */ -static int __read_mostly watchdog_suspended; +int __read_mostly watchdog_suspended; + +/* +* These functions can be overridden if an architecture implements its +* own hardlockup detector. +*/ +int __weak watchdog_nmi_enable (unsigned int cpu) +{ +return 0 ; +} +void __weak watchdog_nmi_disable (unsigned int cpu) +{ +} + +#ifdef CONFIG_SOFTLOCKUP_DETECTOR + +/* Helper for online, unparked cpus. */ +#define for_each_watchdog_cpu (cpu) \ + for_each_cpu_and((cpu), cpu_online_mask, &watchdog_cpumask) + +atomic_t watchdog_park_in_progress =ATOMIC_INIT (0 );static u64 __read_mostly sample_period;@@ -120,6 +174,7 @@ static int __init softlockup_all_cpu_backtrace_setup(char *str)return 1 ; }__setup ("softlockup_all_cpu_backtrace=" , softlockup_all_cpu_backtrace_setup); +#ifdef CONFIG_HARDLOCKUP_DETECTOR static int __init hardlockup_all_cpu_backtrace_setup (char *str) { sysctl_hardlockup_all_cpu_backtrace =@@ -128,6 +183,7 @@ static int __init hardlockup_all_cpu_backtrace_setup(char *str) }__setup ("hardlockup_all_cpu_backtrace=" , hardlockup_all_cpu_backtrace_setup);#endif +#endif /* * Hard-lockup warnings should be triggered after just a few seconds. Soft- @@ -213,18 +269,6 @@ void touch_softlockup_watchdog_sync(void)__this_cpu_write (watchdog_touch_ts,0 ); } -/* watchdog detector functions */ -bool is_hardlockup (void ) -{ -unsigned long hrint =__this_cpu_read (hrtimer_interrupts); - -if (__this_cpu_read (hrtimer_interrupts_saved) == hrint) -return true; - -__this_cpu_write (hrtimer_interrupts_saved, hrint); -return false; -} -static int is_softlockup (unsigned long touch_ts) {unsigned long now =get_timestamp ();@@ -237,21 +281,21 @@ static int is_softlockup(unsigned long touch_ts)return 0 ; } -static void watchdog_interrupt_count (void ) +/* watchdog detector functions */ +bool is_hardlockup (void ) { -__this_cpu_inc (hrtimer_interrupts); -} +unsigned long hrint =__this_cpu_read (hrtimer_interrupts); -/* -* These two functions are mostly architecture specific -* defining them as weak here. -*/ -int __weak watchdog_nmi_enable (unsigned int cpu) -{ -return 0 ; +if (__this_cpu_read (hrtimer_interrupts_saved) == hrint) +return true; + +__this_cpu_write (hrtimer_interrupts_saved, hrint); +return false; } -void __weak watchdog_nmi_disable (unsigned int cpu) + +static void watchdog_interrupt_count (void ) { +__this_cpu_inc (hrtimer_interrupts); }static int watchdog_enable_all_cpus (void );@@ -502,57 +546,6 @@ static void watchdog_unpark_threads(void)kthread_unpark (per_cpu (softlockup_watchdog, cpu)); } -/* -* Suspend the hard and soft lockup detector by parking the watchdog threads. -*/ -int lockup_detector_suspend (void ) -{ -int ret =0 ; - -get_online_cpus (); -mutex_lock (&watchdog_proc_mutex); -/* -* Multiple suspend requests can be active in parallel (counted by -* the 'watchdog_suspended' variable). If the watchdog threads are -* running, the first caller takes care that they will be parked. -* The state of 'watchdog_running' cannot change while a suspend -* request is active (see related code in 'proc' handlers). -*/ -if (watchdog_running && !watchdog_suspended) - ret =watchdog_park_threads (); - -if (ret ==0 ) - watchdog_suspended++; -else { -watchdog_disable_all_cpus (); -pr_err ("Failed to suspend lockup detectors, disabled\n" ); - watchdog_enabled =0 ; - } - -mutex_unlock (&watchdog_proc_mutex); - -return ret; -} - -/* -* Resume the hard and soft lockup detector by unparking the watchdog threads. -*/ -void lockup_detector_resume (void ) -{ -mutex_lock (&watchdog_proc_mutex); - - watchdog_suspended--; -/* -* The watchdog threads are unparked if they were previously running -* and if there is no more active suspend request. -*/ -if (watchdog_running && !watchdog_suspended) -watchdog_unpark_threads (); - -mutex_unlock (&watchdog_proc_mutex); -put_online_cpus (); -} -static int update_watchdog_all_cpus (void ) {int ret;@@ -604,6 +597,81 @@ static void watchdog_disable_all_cpus(void) } } +#else /* SOFTLOCKUP */ +static int watchdog_park_threads (void ) +{ +return 0 ; +} + +static void watchdog_unpark_threads (void ) +{ +} + +static int watchdog_enable_all_cpus (void ) +{ +return 0 ; +} + +static void watchdog_disable_all_cpus (void ) +{ +} + +static void set_sample_period (void ) +{ +} +#endif /* SOFTLOCKUP */ + +/* +* Suspend the hard and soft lockup detector by parking the watchdog threads. +*/ +int lockup_detector_suspend (void ) +{ +int ret =0 ; + +get_online_cpus (); +mutex_lock (&watchdog_proc_mutex); +/* +* Multiple suspend requests can be active in parallel (counted by +* the 'watchdog_suspended' variable). If the watchdog threads are +* running, the first caller takes care that they will be parked. +* The state of 'watchdog_running' cannot change while a suspend +* request is active (see related code in 'proc' handlers). +*/ +if (watchdog_running && !watchdog_suspended) + ret =watchdog_park_threads (); + +if (ret ==0 ) + watchdog_suspended++; +else { +watchdog_disable_all_cpus (); +pr_err ("Failed to suspend lockup detectors, disabled\n" ); + watchdog_enabled =0 ; + } + +mutex_unlock (&watchdog_proc_mutex); + +return ret; +} + +/* +* Resume the hard and soft lockup detector by unparking the watchdog threads. +*/ +void lockup_detector_resume (void ) +{ +mutex_lock (&watchdog_proc_mutex); + + watchdog_suspended--; +/* +* The watchdog threads are unparked if they were previously running +* and if there is no more active suspend request. +*/ +if (watchdog_running && !watchdog_suspended) +watchdog_unpark_threads (); + +mutex_unlock (&watchdog_proc_mutex); +put_online_cpus (); +} +#ifdef CONFIG_SYSCTL /* @@ -810,9 +878,11 @@ int proc_watchdog_cpumask(struct ctl_table *table, int write,* a temporary cpumask, so we are likely not in a * position to do much else to make things better. */ +#ifdef CONFIG_SOFTLOCKUP_DETECTOR if (smpboot_update_cpumask_percpu_thread ( &watchdog_threads, &watchdog_cpumask) !=0 )pr_err ("cpumask update failed\n" ); +#endif } } out:kernel/watchdog_hld.c +0
-32@@ -22,39 +22,7 @@ static DEFINE_PER_CPU(bool, hard_watchdog_warn); static DEFINE_PER_CPU(bool, watchdog_nmi_touch); static DEFINE_PER_CPU(struct perf_event *, watchdog_ev); -/* boot commands */ -/* -* Should we panic when a soft-lockup or hard-lockup occurs: -*/ -unsigned int __read_mostly hardlockup_panic = -CONFIG_BOOTPARAM_HARDLOCKUP_PANIC_VALUE ;static unsigned long hardlockup_allcpu_dumped; -/* -* We may not want to enable hard lockup detection by default in all cases, -* for example when running the kernel as a guest on a hypervisor. In these -* cases this function can be called to disable hard lockup detection. This -* function should only be executed once by the boot processor before the -* kernel command line parameters are parsed, because otherwise it is not -* possible to override this in hardlockup_panic_setup(). -*/ -void hardlockup_detector_disable (void ) -{ - watchdog_enabled &= ~NMI_WATCHDOG_ENABLED ; -} - -static int __init hardlockup_panic_setup (char *str) -{ -if (!strncmp (str,"panic" ,5 )) - hardlockup_panic =1 ; -else if (!strncmp (str,"nopanic" ,7 )) - hardlockup_panic =0 ; -else if (!strncmp (str,"0" ,1 )) - watchdog_enabled &= ~NMI_WATCHDOG_ENABLED ; -else if (!strncmp (str,"1" ,1 )) - watchdog_enabled |=NMI_WATCHDOG_ENABLED ; -return 1 ; -} -__setup ("nmi_watchdog=" , hardlockup_panic_setup);void arch_touch_nmi_watchdog (void ) {lib/Kconfig.debug +20
-6@@ -801,10 +801,24 @@ config LOCKUP_DETECTOR The frequency of hrtimer and NMI events and the soft and hard lockup thresholds can be controlled through the sysctl watchdog_thresh. +config SOFTLOCKUP_DETECTOR + bool "Detect Soft Lockups" + depends on LOCKUP_DETECTOR + +config HARDLOCKUP_DETECTOR_PERF + bool + select SOFTLOCKUP_DETECTOR + +# +# arch/ can define HAVE_HARDLOCKUP_DETECTOR_ARCH to provide their own hard +# lockup detector rather than the perf based detector. +# config HARDLOCKUP_DETECTOR - def_bool y - depends on LOCKUP_DETECTOR && !HAVE_NMI_WATCHDOG - depends on PERF_EVENTS && HAVE_PERF_EVENTS_NMI + bool "Detect Hard Lockups" + depends on LOCKUP_DETECTOR + depends on HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_ARCH + select HARDLOCKUP_DETECTOR_PERF if HAVE_HARDLOCKUP_DETECTOR_PERF + select HARDLOCKUP_DETECTOR_ARCH if HAVE_HARDLOCKUP_DETECTOR_ARCH config BOOTPARAM_HARDLOCKUP_PANIC bool "Panic (Reboot) On Hard Lockups"@@ -826,7 +840,7 @@ config BOOTPARAM_HARDLOCKUP_PANIC_VALUE config BOOTPARAM_SOFTLOCKUP_PANIC bool "Panic (Reboot) On Soft Lockups" - depends on LOCKUP_DETECTOR + depends on SOFTLOCKUP_DETECTOR help Say Y here to enable the kernel to panic on "soft lockups", which are bugs that cause the kernel to loop in kernel@@ -843,7 +857,7 @@ config BOOTPARAM_SOFTLOCKUP_PANIC config BOOTPARAM_SOFTLOCKUP_PANIC_VALUE int - depends on LOCKUP_DETECTOR + depends on SOFTLOCKUP_DETECTOR range 0 1 default 0 if !BOOTPARAM_SOFTLOCKUP_PANIC default 1 if BOOTPARAM_SOFTLOCKUP_PANIC@@ -851,7 +865,7 @@ config BOOTPARAM_SOFTLOCKUP_PANIC_VALUE config DETECT_HUNG_TASK bool "Detect Hung Tasks" depends on DEBUG_KERNEL - default LOCKUP_DETECTOR + default SOFTLOCKUP_DETECTOR help Say Y here to enable the kernel to detect "hung tasks", which are bugs that cause the task to be stuck inSignature · 1 line
2.11.0
Nicholas Piggin
reviewerRe: [PATCH 3/4] watchdog: Split up config options
Quoted 53 lines · On Wed, 14 Jun 2017 21:16:04 -0500 Babu Moger <[email protected]> wrote:
Hi Don,
Quoted 8 lines · Don Zickus
Quoted 5 lines · Nicholas Piggin
Quoted 3 lines
Yeah, if you wouldn't mind. Sorry for dragging this out, but I feel like we are getting close to have this defined properly which would allow us to split the code up correctly in the future.
How's this for a replacement patch 3? I think the
Kconfigworks out much better now.Hi Nick,
Quoted 8 lines
I think you made this much clearer, thank you! I am good with this.
Hi Babu,
Can you give this patchset (and particularly this version of patch 3) a try on sparc to make sure we didn't break anything? I believe this should resolve the start nmi watchdog on boot issue you noticed. Thanks!
There is still one problem with the patch.
# cat /proc/sys/kernel/watchdog 1 # cat /proc/sys/kernel/nmi_watchdog 0Problem is setting the initial value for "
nmi_watchdog"We need something(or similar) patch on top to address this.
============================================kernel/watchdog.c +5
-1@@ -34,9 +34,13 @@int __read_mostly nmi_watchdog_enabled; -#ifdef CONFIG_HARDLOCKUP_DETECTOR +#if defined(CONFIG_HARDLOCKUP_DETECTOR ) || defined(CONFIG_HAVE_NMI_WATCHDOG )unsigned long __read_mostly watchdog_enabled =SOFT_WATCHDOG_ENABLED |NMI_WATCHDOG_ENABLED ; +#else +unsigned long __read_mostly watchdog_enabled =SOFT_WATCHDOG_ENABLED ; +#endif +#ifdef CONFIG_HARDLOCKUP_DETECTOR /* boot commands */ /*
* Should we panic when a soft-lockup or hard-lockup occurs:
kernel/watchdog.c static int __init hardlockup_panic_setup(char *str) · line 78
Quoted 9 lines
kernel/watchdog.c +0
-3@@ -69,9 +73,6 @@ static int __init hardlockup_panic_setup(char *str) return 1; }__setup ("nmi_watchdog=" , hardlockup_panic_setup); - -#else -unsigned long __read_mostly watchdog_enabled =SOFT_WATCHDOG_ENABLED ;#endif #ifdef CONFIG_SOFTLOCKUP_DETECTOR
Hmm, I guess I missed this because sparc parses nmi_watchdog=, but it also relies on the watchdog_enabled value.
I guess I can fold your incremental patch in. I hope we could get sparc quickly to adopt the complate HAVE_HARDLOCKUP_DETECTOR_ARCH soon afterwards though, so we only have 2 cases -- complete hardlockup detector, or the very bare minimum NMI_WATCHDOG.
Thanks,
Nick
Re: [PATCH 3/4] watchdog: Split up config options
Nick,
Quoted 63 lines · Nicholas Piggin
Quoted 60 lines · On Wed, 14 Jun 2017 21:16:04 -0500 Babu Moger <[email protected]> wrote:
Hi Don,
Quoted 8 lines · Don Zickus
Quoted 5 lines · Nicholas Piggin
Quoted 3 lines
Yeah, if you wouldn't mind. Sorry for dragging this out, but I feel like we are getting close to have this defined properly which would allow us to split the code up correctly in the future.
How's this for a replacement patch 3? I think the
Kconfigworks out much better now.Hi Nick,
Quoted 8 lines
I think you made this much clearer, thank you! I am good with this.
Hi Babu,
Can you give this patchset (and particularly this version of patch 3) a try on sparc to make sure we didn't break anything? I believe this should resolve the start nmi watchdog on boot issue you noticed. Thanks!
There is still one problem with the patch.
# cat /proc/sys/kernel/watchdog 1 # cat /proc/sys/kernel/nmi_watchdog 0Problem is setting the initial value for "
nmi_watchdog"We need something(or similar) patch on top to address this.
============================================kernel/watchdog.c +5
-1@@ -34,9 +34,13 @@int __read_mostly nmi_watchdog_enabled; -#ifdef CONFIG_HARDLOCKUP_DETECTOR +#if defined(CONFIG_HARDLOCKUP_DETECTOR ) || defined(CONFIG_HAVE_NMI_WATCHDOG )unsigned long __read_mostly watchdog_enabled =SOFT_WATCHDOG_ENABLED |NMI_WATCHDOG_ENABLED ; +#else +unsigned long __read_mostly watchdog_enabled =SOFT_WATCHDOG_ENABLED ; +#endif +#ifdef CONFIG_HARDLOCKUP_DETECTOR /* boot commands */ /*
* Should we panic when a soft-lockup or hard-lockup occurs:kernel/watchdog.c +0
-3@@ -69,9 +73,6 @@ static int __init hardlockup_panic_setup(char *str) return 1; }__setup ("nmi_watchdog=" , hardlockup_panic_setup); - -#else -unsigned long __read_mostly watchdog_enabled =SOFT_WATCHDOG_ENABLED ;#endif
Quoted 5 lines
kernel/watchdog.c static int __init hardlockup_panic_setup(char *str) · line 78
Quoted 1 line
kernel/watchdog.c +0
-0#ifdef CONFIG_SOFTLOCKUP_DETECTOR Hmm, I guess I missed this because sparc parses nmi_watchdog=, but it also relies on the
watchdog_enabledvalue.I guess I can fold your incremental patch in. I hope we could get
Sure. Please go ahead.
Quoted 2 lines
sparc quickly to adopt the complate
HAVE_HARDLOCKUP_DETECTOR_ARCHsoon afterwards though, so we only have 2 cases -- complete hardlockup
Sure. Sounds good. Will look at it later.
Quoted 4 lines
detector, or the very bare minimum
NMI_WATCHDOG.Thanks,
Nick
Re: [PATCH 3/4] watchdog: Split up config options
In reply to Nicholas PigginQuoted 18 lines · Nicholas Piggin
Quoted 5 lines
(quoted diff) +1
-0+#ifdef CONFIG_HARDLOCKUP_DETECTOR /* boot commands */ /* * Should we panic when a soft-lockup or hard-lockup occurs:Review static int __init hardlockup_panic_setup(char *str) · line 78
Quoted 9 lines
(quoted diff) +0
-3@@ -69,9 +73,6 @@ static int __init hardlockup_panic_setup(char *str) return 1; } __setup("nmi_watchdog=", hardlockup_panic_setup); - -#else -unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED; #endif #ifdef CONFIG_SOFTLOCKUP_DETECTORHmm, I guess I missed this because sparc parses nmi_watchdog=, but it also relies on the
watchdog_enabledvalue.
Quoted 4 lines
I guess I can fold your incremental patch in. I hope we could get sparc quickly to adopt the complate
HAVE_HARDLOCKUP_DETECTOR_ARCHsoon afterwards though, so we only have 2 cases -- complete hardlockup detector, or the very bare minimumNMI_WATCHDOG.
Hi Nick,
I agree. Let's move forward with this temp fix just to get things in the kernel for initial testing. Then follow up with a cleanup patch. The idea is we can always revert the cleanup patch if things still don't quite work.
Thoughts?
Cheers,
Don
Nicholas Piggin
reviewerRe: [PATCH 3/4] watchdog: Split up config options
Quoted 24 lines · On Thu, 15 Jun 2017 11:51:22 -0400 Don Zickus <[email protected]> wrote:
Quoted 18 lines · Nicholas Piggin
Quoted 5 lines
(quoted diff) +1
-0+#ifdef CONFIG_HARDLOCKUP_DETECTOR /* boot commands */ /* * Should we panic when a soft-lockup or hard-lockup occurs:Review static int __init hardlockup_panic_setup(char *str) · line 78
Quoted 9 lines
(quoted diff) +0
-3@@ -69,9 +73,6 @@ static int __init hardlockup_panic_setup(char *str) return 1; } __setup("nmi_watchdog=", hardlockup_panic_setup); - -#else -unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED; #endif #ifdef CONFIG_SOFTLOCKUP_DETECTORHmm, I guess I missed this because sparc parses nmi_watchdog=, but it also relies on the
watchdog_enabledvalue.Quoted 4 lines
I guess I can fold your incremental patch in. I hope we could get sparc quickly to adopt the complate
HAVE_HARDLOCKUP_DETECTOR_ARCHsoon afterwards though, so we only have 2 cases -- complete hardlockup detector, or the very bare minimumNMI_WATCHDOG.
Quoted 7 lines
Hi Nick,
I agree. Let's move forward with this temp fix just to get things in the kernel for initial testing. Then follow up with a cleanup patch. The idea is we can always revert the cleanup patch if things still don't quite work.
Thoughts?
Hi Don,
Yeah that sounds good to me. Would you like me to re-test things and resend the series?
Thanks,
Nick
Re: [PATCH 3/4] watchdog: Split up config options
Quoted 33 lines · Nicholas Piggin
Quoted 30 lines · On Thu, 15 Jun 2017 11:51:22 -0400 Don Zickus <[email protected]> wrote:
Quoted 18 lines · Nicholas Piggin
Quoted 5 lines
(quoted diff) +1
-0+#ifdef CONFIG_HARDLOCKUP_DETECTOR /* boot commands */ /* * Should we panic when a soft-lockup or hard-lockup occurs:Review static int __init hardlockup_panic_setup(char *str) · line 78
Quoted 9 lines
(quoted diff) +0
-3@@ -69,9 +73,6 @@ static int __init hardlockup_panic_setup(char *str) return 1; } __setup("nmi_watchdog=", hardlockup_panic_setup); - -#else -unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED; #endif #ifdef CONFIG_SOFTLOCKUP_DETECTORHmm, I guess I missed this because sparc parses nmi_watchdog=, but it also relies on the
watchdog_enabledvalue.Quoted 4 lines
I guess I can fold your incremental patch in. I hope we could get sparc quickly to adopt the complate
HAVE_HARDLOCKUP_DETECTOR_ARCHsoon afterwards though, so we only have 2 cases -- complete hardlockup detector, or the very bare minimumNMI_WATCHDOG.Hi Nick,
I agree. Let's move forward with this temp fix just to get things in the kernel for initial testing. Then follow up with a cleanup patch. The idea is we can always revert the cleanup patch if things still don't quite work.
Quoted 6 lines
Quoted 1 line
Thoughts?
Hi Don,
Yeah that sounds good to me. Would you like me to re-test things and resend the series?
Yes, please. Thanks!
Cheers,
Don
Nicholas Piggin
reviewerPATCH v3 4/4 watchdog: Provide watchdog_reconfigure() for arch watchdogs
In reply to Nicholas PigginAfter reconfiguring watchdog sysctls etc., architecture specific watchdogs may not get all their parameters updated.
watchdog_reconfigure() can be implemented to pull the new values in and set the arch NMI watchdog.
--- kernel/watchdog.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-)
kernel/watchdog.c +25 -4
@@ -120,6 +120,11 @@ void __weak watchdog_nmi_disable(unsigned int cpu) { } +void __weak watchdog_nmi_reconfigure (void ) +{ +} + +#ifdef CONFIG_SOFTLOCKUP_DETECTOR /* Helper for online, unparked cpus. */
@@ -597,6 +602,12 @@ static void watchdog_disable_all_cpus(void) } } +static int watchdog_update_cpus (void ) +{ +return smpboot_update_cpumask_percpu_thread ( + &watchdog_threads, &watchdog_cpumask); +} +#else /* SOFTLOCKUP */ static int watchdog_park_threads (void ) {
@@ -616,6 +627,11 @@ static void watchdog_disable_all_cpus(void) { } +static int watchdog_update_cpus (void ) +{ +return 0 ; +} +static void set_sample_period (void ) { }
@@ -648,6 +664,8 @@ int lockup_detector_suspend(void) watchdog_enabled =0 ; } +watchdog_nmi_reconfigure (); +mutex_unlock (&watchdog_proc_mutex);return ret;
@@ -668,6 +686,8 @@ void lockup_detector_resume(void)if (watchdog_running && !watchdog_suspended)watchdog_unpark_threads (); +watchdog_nmi_reconfigure (); +mutex_unlock (&watchdog_proc_mutex);put_online_cpus (); }
@@ -693,6 +713,8 @@ static int proc_watchdog_update(void)else watchdog_disable_all_cpus (); +watchdog_nmi_reconfigure (); +return err; }
@@ -878,12 +900,11 @@ int proc_watchdog_cpumask(struct ctl_table *table, int write,* a temporary cpumask, so we are likely not in a * position to do much else to make things better. */ -#ifdef CONFIG_SOFTLOCKUP_DETECTOR -if (smpboot_update_cpumask_percpu_thread ( - &watchdog_threads, &watchdog_cpumask) !=0 ) +if (watchdog_update_cpus () !=0 )pr_err ("cpumask update failed\n" ); -#endif } + +watchdog_nmi_reconfigure (); } out:mutex_unlock (&watchdog_proc_mutex);
Signature · 1 line
2.11.0
(adding Babu)
Quoted 8 lines · Nicholas Piggin
Since last time:
- Have the perf based hardlockup detector use
arch_touch_nmi_watchdog()rather thanhld_touch_nmi_watchdog(). This changes direction slightly to make the perf-based hard lockup detector an alternative that an arch may select, rather than standalone. This better reflects how the code works in practice).
Quoted 5 lines
- Hopefully fixed the
Kconfigoptions. There's still a bit of ugliness that will require another pass or two over interfaces and config scheme, but the idea is to make a minimal change to get the powerpc HLD in, which gives a reasonable starting point to improve things further.
Hi Babu,
Does this patchset break sparc? Specifically patch3 with all the config option changes?
Cheers,
Don
Quoted 27 lines
Nicholas Piggin (4):
watchdog: remove unused declaration
watchdog: Introducearch_touch_nmi_watchdog()
watchdog: Split up config options
watchdog: Providewatchdog_reconfigure()for arch watchdogsarch/blackfin/include/asm/nmi.h | 2 + arch/blackfin/kernel/nmi.c | 2 +- arch/mn10300/include/asm/nmi.h | 2 + arch/mn10300/kernel/mn10300-watchdog-low.S | 8 +- arch/mn10300/kernel/mn10300-watchdog.c | 2 +- arch/powerpc/kernel/setup_64.c | 2 +- arch/sparc/include/asm/nmi.h | 1 + arch/sparc/kernel/nmi.c | 6 +- arch/x86/kernel/apic/hw_nmi.c | 2 +- include/linux/nmi.h | 57 ++++--- kernel/Makefile | 2 +- kernel/sysctl.c | 18 +- kernel/watchdog.c | 263 +++++++++++++++++++---------- kernel/watchdog_hld.c | 37 +--- lib/Kconfig.debug | 29 +++- 15 files changed, 263 insertions(+), 170 deletions(-)Signature · 1 line
2.11.0
Hi Don, Nicholas,
Quoted 11 lines · Don Zickus
(adding Babu)
Quoted 8 lines · Nicholas Piggin
Since last time:
- Have the perf based hardlockup detector use
arch_touch_nmi_watchdog()rather thanhld_touch_nmi_watchdog(). This changes direction slightly to make the perf-based hard lockup detector an alternative that an arch may select, rather than standalone. This better reflects how the code works in practice).
Quoted 8 lines
Quoted 5 lines
- Hopefully fixed the
Kconfigoptions. There's still a bit of ugliness that will require another pass or two over interfaces and config scheme, but the idea is to make a minimal change to get the powerpc HLD in, which gives a reasonable starting point to improve things further.Hi Babu,
Does this patchset break sparc? Specifically patch3 with all the config
Patches applies, compiles fine and also works fine for most part. However, there are few issues.
We need to enter 'N' or 'Y' for SOFTLOCKUP_DETECTOR.
*
* Restart config...
*
*
* Debug Lockups and Hangs
*
Detect Hard and Soft Lockups (LOCKUP_DETECTOR) [Y/n/?] y
Detect Soft Lockups (SOFTLOCKUP_DETECTOR) [N/y] (NEW)
For SPARC, softlockup is enabled by default earlier. May be we need to submit another patch to enable this in
arch/sparc/configs/sparc64_defconfig. Not a big issue.
Another issue.
before that patch
# cat /proc/sys/kernel/watchdog 1 # cat /proc/sys/kernel/nmi_watchdog 1
After the patch
# cat /proc/sys/kernel/watchdog 1 # cat /proc/sys/kernel/nmi_watchdog 0
I think this is mostly due to change in this code below.
#ifdef CONFIG_HARDLOCKUP_DETECTOR
unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED|NMI_WATCHDOG_ENABLED;
Old code was like this
#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR) unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED|NMI_WATCHDOG_ENABLED; #else
unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED; #endif
SPARC defines CONFIG_HAVE_NMI_WATCHDOG.
Thanks
Babu
Quoted 31 lines
option changes?
Cheers,
DonQuoted 26 lines
Nicholas Piggin (4):
watchdog: remove unused declaration
watchdog: Introducearch_touch_nmi_watchdog()
watchdog: Split up config options
watchdog: Providewatchdog_reconfigure()for arch watchdogsarch/blackfin/include/asm/nmi.h | 2 + arch/blackfin/kernel/nmi.c | 2 +- arch/mn10300/include/asm/nmi.h | 2 + arch/mn10300/kernel/mn10300-watchdog-low.S | 8 +- arch/mn10300/kernel/mn10300-watchdog.c | 2 +- arch/powerpc/kernel/setup_64.c | 2 +- arch/sparc/include/asm/nmi.h | 1 + arch/sparc/kernel/nmi.c | 6 +- arch/x86/kernel/apic/hw_nmi.c | 2 +- include/linux/nmi.h | 57 ++++--- kernel/Makefile | 2 +- kernel/sysctl.c | 18 +- kernel/watchdog.c | 263 +++++++++++++++++++---------- kernel/watchdog_hld.c | 37 +--- lib/Kconfig.debug | 29 +++- 15 files changed, 263 insertions(+), 170 deletions(-)Signature · 1 line
2.11.0
Quoted 20 lines · Babu Moger
Hi Don, Nicholas,
Quoted 16 lines · Don Zickus
(adding Babu)
Quoted 13 lines · Nicholas Piggin
Since last time:
- Have the perf based hardlockup detector use
arch_touch_nmi_watchdog()rather thanhld_touch_nmi_watchdog(). This changes direction slightly to make the perf-based hard lockup detector an alternative that an arch may select, rather than standalone. This better reflects how the code works in practice).- Hopefully fixed the
Kconfigoptions. There's still a bit of ugliness that will require another pass or two over interfaces and config scheme, but the idea is to make a minimal change to get the powerpc HLD in, which gives a reasonable starting point to improve things further.
Quoted 5 lines
Quoted 3 lines
Hi Babu,
Does this patchset break sparc? Specifically patch3 with all the config
Patches applies, compiles fine and also works fine for most part. However, there are few issues.
Thanks for the quick turnaround!
Quoted 12 lines
We need to enter 'N' or 'Y' for
SOFTLOCKUP_DETECTOR.*
* Restart config...
*
*
* Debug Lockups and Hangs
*
Detect Hard and Soft Lockups (LOCKUP_DETECTOR) [Y/n/?] y
Detect Soft Lockups (SOFTLOCKUP_DETECTOR) [N/y] (NEW)
Quoted 4 lines
For SPARC, softlockup is enabled by default earlier. May be we need to
submit another patch to enable this in
arch/sparc/configs/sparc64_defconfig. Not a big issue.
Hmm, I think the nmi_enable/disable stuff is wrapped into the SOFTLOCKUP_DETECTOR code, so you might need it. Though Nick did create a separate interface outside of SOFTLOCKUP to something similar. I believe patch4 introduces nmi_reconfigure().
Not sure if the spirit of the sparc nmi_watchdog code wants SOFTLOCKUP or not.
Quoted 10 lines
Another issue.
before that patch# cat /proc/sys/kernel/watchdog 1 # cat /proc/sys/kernel/nmi_watchdog 1
Quoted 6 lines
After the patch
# cat /proc/sys/kernel/watchdog 1 # cat /proc/sys/kernel/nmi_watchdog 0
Yes, that is what I thought. Thanks for confirming!
Quoted 9 lines
I think this is mostly due to change in this code below.
#ifdef
CONFIG_HARDLOCKUP_DETECTOR
unsigned long__read_mostlywatchdog_enabled=
SOFT_WATCHDOG_ENABLED|NMI_WATCHDOG_ENABLED;Old code was like this
Quoted 8 lines
#if
defined(CONFIG_HAVE_NMI_WATCHDOG)||defined(CONFIG_HARDLOCKUP_DETECTOR)unsigned long__read_mostlywatchdog_enabled= SOFT_WATCHDOG_ENABLED|NMI_WATCHDOG_ENABLED;
#else
unsigned long__read_mostlywatchdog_enabled=SOFT_WATCHDOG_ENABLED; #endifSPARC defines
CONFIG_HAVE_NMI_WATCHDOG.
I am still working with Nick to deal with these config issues. But I am going to keep this one in mind while we work through it.
Cheers,
Don