Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1652756 > unrolled thread
| Started by | Nicholas Piggin <npiggin@gmail.com> |
|---|---|
| First post | 2017-05-30 03:30 +0200 |
| Last post | 2017-06-07 06:00 +0200 |
| Articles | 5 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 3/4] watchdog: Split up config options Nicholas Piggin <npiggin@gmail.com> - 2017-05-30 03:30 +0200
Re: [PATCH 3/4] watchdog: Split up config options Don Zickus <dzickus@redhat.com> - 2017-06-02 22:20 +0200
Re: [PATCH 3/4] watchdog: Split up config options Nicholas Piggin <npiggin@gmail.com> - 2017-06-03 08:20 +0200
Re: [PATCH 3/4] watchdog: Split up config options Don Zickus <dzickus@redhat.com> - 2017-06-06 19:00 +0200
Re: [PATCH 3/4] watchdog: Split up config options Nicholas Piggin <npiggin@gmail.com> - 2017-06-07 06:00 +0200
| From | Nicholas Piggin <npiggin@gmail.com> |
|---|---|
| Date | 2017-05-30 03:30 +0200 |
| Subject | [PATCH 3/4] watchdog: Split up config options |
| Message-ID | <tME8V-8vo-1@gated-at.bofh.it> |
Split 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.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
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(-)
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index f35ff9dea4fb..ab650905f75a 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -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;
diff --git a/arch/x86/kernel/apic/hw_nmi.c b/arch/x86/kernel/apic/hw_nmi.c
index c73c9fb281e1..d6f387780849 100644
--- a/arch/x86/kernel/apic/hw_nmi.c
+++ b/arch/x86/kernel/apic/hw_nmi.c
@@ -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;
diff --git a/include/linux/nmi.h b/include/linux/nmi.h
index bd387ef8bccd..257e6d7a9e6a 100644
--- a/include/linux/nmi.h
+++ b/include/linux/nmi.h
@@ -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;
diff --git a/kernel/Makefile b/kernel/Makefile
index 72aa080f91f0..4cb8e8b23c6e 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -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
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 4dfba1a76cc3..fa37faa89143 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -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",
diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index 03e0b69bb5bf..deb010505646 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -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:
diff --git a/kernel/watchdog_hld.c b/kernel/watchdog_hld.c
index 90d688df6ce1..295a0d84934c 100644
--- a/kernel/watchdog_hld.c
+++ b/kernel/watchdog_hld.c
@@ -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)
{
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index e4587ebe52c7..a3afe3e10278 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -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
--
2.11.0
[toc] | [next] | [standalone]
| From | Don Zickus <dzickus@redhat.com> |
|---|---|
| Date | 2017-06-02 22:20 +0200 |
| Message-ID | <tO1d8-5RY-11@gated-at.bofh.it> |
| In reply to | #1652756 |
On Tue, May 30, 2017 at 11:26:58AM +1000, Nicholas Piggin wrote: > Split 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. 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> > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > index e4587ebe52c7..a3afe3e10278 100644 > --- a/lib/Kconfig.debug > +++ b/lib/Kconfig.debug > @@ -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)' > + > +# > +# 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 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 > > 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 > -- > 2.11.0 >
[toc] | [prev] | [next] | [standalone]
| From | Nicholas Piggin <npiggin@gmail.com> |
|---|---|
| Date | 2017-06-03 08:20 +0200 |
| Message-ID | <tOazL-3pu-3@gated-at.bofh.it> |
| In reply to | #1656520 |
On Fri, 2 Jun 2017 16:15:00 -0400 Don Zickus <dzickus@redhat.com> wrote: > On Tue, May 30, 2017 at 11:26:58AM +1000, Nicholas Piggin wrote: > > Split 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. > > 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. 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. > 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. 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. > > In your ppc64 case, it means do _not_ use the HARDLOCKUP_DETECTOR or > SOFTLOCKUP_DETECTOR framework. Instead just the bare bones LOCKUP_DETECTOR. It does use the HLD framework. The subsequent patch for powerpc adds a PPC64 case in the dependencies. > > > If so, the following is a little confusing to me.. > > > <snip> > > > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > > index e4587ebe52c7..a3afe3e10278 100644 > > --- a/lib/Kconfig.debug > > +++ b/lib/Kconfig.debug > > @@ -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)' Kconfig is pretty clunky, I was struggling to make it do the right thing... I could try. > > > + > > +# > > +# 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 > > 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??? 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
[toc] | [prev] | [next] | [standalone]
| From | Don Zickus <dzickus@redhat.com> |
|---|---|
| Date | 2017-06-06 19:00 +0200 |
| Message-ID | <tPpZL-2W5-3@gated-at.bofh.it> |
| In reply to | #1656725 |
On Sat, Jun 03, 2017 at 04:10:05PM +1000, Nicholas Piggin wrote: > > My last concern is wrapping my head around the config options. > > > > HAVE_NMI_WATCHDOG seems 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. > > > 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. > > 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.. > > > > In your ppc64 case, it means do _not_ use the HARDLOCKUP_DETECTOR or > > SOFTLOCKUP_DETECTOR framework. Instead just the bare bones LOCKUP_DETECTOR. > > It does use the HLD framework. The subsequent patch for powerpc adds > a PPC64 case in the dependencies. Ah, ok. > > > > > > > If so, the following is a little confusing to me.. > > > > > > <snip> > > > > > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > > > index e4587ebe52c7..a3afe3e10278 100644 > > > --- a/lib/Kconfig.debug > > > +++ b/lib/Kconfig.debug > > > @@ -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)' > > Kconfig is pretty clunky, I was struggling to make it do the right > thing... I could try. > > > > > > + > > > +# > > > +# 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 > > > > 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??? > > 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 > > 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
[toc] | [prev] | [next] | [standalone]
| From | Nicholas Piggin <npiggin@gmail.com> |
|---|---|
| Date | 2017-06-07 06:00 +0200 |
| Message-ID | <tPAit-1dp-1@gated-at.bofh.it> |
| In reply to | #1658942 |
On Tue, 6 Jun 2017 12:49:58 -0400 Don Zickus <dzickus@redhat.com> wrote: > On Sat, Jun 03, 2017 at 04:10:05PM +1000, Nicholas Piggin wrote: > > > > 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??? > > > > 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? Ahh okay because sparc is using watchdog_nmi_enable/disable from the softlockup watchdog, which checks watchdog_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? 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. > 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? 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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web