* [RFC PATCH v2 07/14] watchdog/hardlockup: Define a generic function to detect hardlockups
[not found] <1551283518-18922-1-git-send-email-ricardo.neri-calderon@linux.intel.com>
@ 2019-02-27 16:05 ` Ricardo Neri
2019-02-27 16:05 ` [RFC PATCH v2 08/14] watchdog/hardlockup: Decouple the hardlockup detector from perf Ricardo Neri
` (2 subsequent siblings)
3 siblings, 0 replies; 14+ messages in thread
From: Ricardo Neri @ 2019-02-27 16:05 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov
Cc: Peter Zijlstra, Ricardo Neri, Paul Mackerras, H. Peter Anvin,
sparclinux, Ashok Raj, x86, Andi Kleen, Don Zickus,
Ravi V. Shankar, Ricardo Neri, Frederic Weisbecker,
Nicholas Piggin, Mathieu Desnoyers, Tony Luck, Babu Moger,
linux-kernel, Luis R. Rodriguez, Masami Hiramatsu,
Philippe Ombredanne, Colin Ian King, Andrew Morton, linuxppc-dev,
David S. Miller
The procedure to detect hardlockups is independent of the underlying
mechanism that generated the non-maskable interrupt used to drive the
detector. Thus, it can be put in a separate, generic function. In this
manner, it can be invoked by various implementations of the NMI watchdog.
For this purpose, move the bulk of watchdog_overflow_callback() to the
new function inspect_for_hardlockups(). This function can then be called
from the applicable NMI handlers.
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ashok Raj <ashok.raj@intel.com>
Cc: Andi Kleen <andi.kleen@intel.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Frederic Weisbecker <frederic@kernel.org>
Cc: Babu Moger <babu.moger@oracle.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Cc: Colin Ian King <colin.king@canonical.com>
Cc: "Luis R. Rodriguez" <mcgrof@kernel.org>
Cc: "Ravi V. Shankar" <ravi.v.shankar@intel.com>
Cc: x86@kernel.org
Cc: sparclinux@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
---
include/linux/nmi.h | 1 +
kernel/watchdog_hld.c | 18 +++++++++++-------
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/include/linux/nmi.h b/include/linux/nmi.h
index 9003e29cde46..5a8b19749769 100644
--- a/include/linux/nmi.h
+++ b/include/linux/nmi.h
@@ -212,6 +212,7 @@ extern int proc_watchdog_thresh(struct ctl_table *, int ,
void __user *, size_t *, loff_t *);
extern int proc_watchdog_cpumask(struct ctl_table *, int,
void __user *, size_t *, loff_t *);
+void inspect_for_hardlockups(struct pt_regs *regs);
#ifdef CONFIG_HAVE_ACPI_APEI_NMI
#include <asm/nmi.h>
diff --git a/kernel/watchdog_hld.c b/kernel/watchdog_hld.c
index 71381168dede..9724cd57307b 100644
--- a/kernel/watchdog_hld.c
+++ b/kernel/watchdog_hld.c
@@ -106,14 +106,8 @@ static struct perf_event_attr wd_hw_attr = {
.disabled = 1,
};
-/* Callback function for perf event subsystem */
-static void watchdog_overflow_callback(struct perf_event *event,
- struct perf_sample_data *data,
- struct pt_regs *regs)
+void inspect_for_hardlockups(struct pt_regs *regs)
{
- /* Ensure the watchdog never gets throttled */
- event->hw.interrupts = 0;
-
if (__this_cpu_read(watchdog_nmi_touch) == true) {
__this_cpu_write(watchdog_nmi_touch, false);
return;
@@ -162,6 +156,16 @@ static void watchdog_overflow_callback(struct perf_event *event,
return;
}
+/* Callback function for perf event subsystem */
+static void watchdog_overflow_callback(struct perf_event *event,
+ struct perf_sample_data *data,
+ struct pt_regs *regs)
+{
+ /* Ensure the watchdog never gets throttled */
+ event->hw.interrupts = 0;
+ inspect_for_hardlockups(regs);
+}
+
static int hardlockup_detector_event_create(void)
{
unsigned int cpu = smp_processor_id();
--
2.17.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [RFC PATCH v2 08/14] watchdog/hardlockup: Decouple the hardlockup detector from perf
[not found] <1551283518-18922-1-git-send-email-ricardo.neri-calderon@linux.intel.com>
2019-02-27 16:05 ` [RFC PATCH v2 07/14] watchdog/hardlockup: Define a generic function to detect hardlockups Ricardo Neri
@ 2019-02-27 16:05 ` Ricardo Neri
2019-03-26 21:18 ` Thomas Gleixner
2019-02-27 16:05 ` [RFC PATCH v2 09/14] watchdog/hardlockup: Make arch_touch_nmi_watchdog() to hpet-based implementation Ricardo Neri
2019-02-27 16:05 ` [RFC PATCH v2 10/14] kernel/watchdog: Add a function to obtain the watchdog_allowed_mask Ricardo Neri
3 siblings, 1 reply; 14+ messages in thread
From: Ricardo Neri @ 2019-02-27 16:05 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov
Cc: Peter Zijlstra, Ricardo Neri, Paul Mackerras, H. Peter Anvin,
sparclinux, Ashok Raj, x86, Andi Kleen, Don Zickus,
Ravi V. Shankar, Ricardo Neri, Frederic Weisbecker,
Nicholas Piggin, Mathieu Desnoyers, Tony Luck, Babu Moger,
linux-kernel, Luis R. Rodriguez, Masami Hiramatsu,
Philippe Ombredanne, Colin Ian King, Andrew Morton, linuxppc-dev,
David S. Miller
The current default implementation of the hardlockup detector assumes that
it is implemented using perf events. However, the hardlockup detector can
be driven by other sources of non-maskable interrupts (e.g., a properly
configured timer).
Put in a separate file all the code that is specific to perf: create and
manage events, stop and start the detector. This perf-specific code is put
in the new file watchdog_hld_perf.c
The code generic code used to monitor the timers' thresholds, check
timestamps and detect hardlockups remains in watchdog_hld.c
Functions and variables are simply relocated to a new file. No functional
changes were made.
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ashok Raj <ashok.raj@intel.com>
Cc: Andi Kleen <andi.kleen@intel.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Frederic Weisbecker <frederic@kernel.org>
Cc: Babu Moger <babu.moger@oracle.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Cc: Colin Ian King <colin.king@canonical.com>
Cc: "Luis R. Rodriguez" <mcgrof@kernel.org>
Cc: "Ravi V. Shankar" <ravi.v.shankar@intel.com>
Cc: x86@kernel.org
Cc: sparclinux@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
---
kernel/Makefile | 3 +-
kernel/watchdog_hld.c | 153 --------------------------------
kernel/watchdog_hld_perf.c | 175 +++++++++++++++++++++++++++++++++++++
3 files changed, 177 insertions(+), 154 deletions(-)
create mode 100644 kernel/watchdog_hld_perf.c
diff --git a/kernel/Makefile b/kernel/Makefile
index 6aa7543bcdb2..5b75e6003458 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -81,7 +81,8 @@ obj-$(CONFIG_FAIL_FUNCTION) += fail_function.o
obj-$(CONFIG_KGDB) += debug/
obj-$(CONFIG_DETECT_HUNG_TASK) += hung_task.o
obj-$(CONFIG_LOCKUP_DETECTOR) += watchdog.o
-obj-$(CONFIG_HARDLOCKUP_DETECTOR_PERF) += watchdog_hld.o
+obj-$(CONFIG_HARDLOCKUP_DETECTOR) += watchdog_hld.o
+obj-$(CONFIG_HARDLOCKUP_DETECTOR_PERF) += watchdog_hld_perf.o
obj-$(CONFIG_SECCOMP) += seccomp.o
obj-$(CONFIG_RELAY) += relay.o
obj-$(CONFIG_SYSCTL) += utsname_sysctl.o
diff --git a/kernel/watchdog_hld.c b/kernel/watchdog_hld.c
index 9724cd57307b..372db565b1b9 100644
--- a/kernel/watchdog_hld.c
+++ b/kernel/watchdog_hld.c
@@ -22,12 +22,8 @@
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);
-static DEFINE_PER_CPU(struct perf_event *, dead_event);
-static struct cpumask dead_events_mask;
static unsigned long hardlockup_allcpu_dumped;
-static atomic_t watchdog_cpus = ATOMIC_INIT(0);
notrace void arch_touch_nmi_watchdog(void)
{
@@ -98,14 +94,6 @@ static inline bool watchdog_check_timestamp(void)
}
#endif
-static struct perf_event_attr wd_hw_attr = {
- .type = PERF_TYPE_HARDWARE,
- .config = PERF_COUNT_HW_CPU_CYCLES,
- .size = sizeof(struct perf_event_attr),
- .pinned = 1,
- .disabled = 1,
-};
-
void inspect_for_hardlockups(struct pt_regs *regs)
{
if (__this_cpu_read(watchdog_nmi_touch) == true) {
@@ -156,144 +144,3 @@ void inspect_for_hardlockups(struct pt_regs *regs)
return;
}
-/* Callback function for perf event subsystem */
-static void watchdog_overflow_callback(struct perf_event *event,
- struct perf_sample_data *data,
- struct pt_regs *regs)
-{
- /* Ensure the watchdog never gets throttled */
- event->hw.interrupts = 0;
- inspect_for_hardlockups(regs);
-}
-
-static int hardlockup_detector_event_create(void)
-{
- unsigned int cpu = smp_processor_id();
- struct perf_event_attr *wd_attr;
- struct perf_event *evt;
-
- wd_attr = &wd_hw_attr;
- wd_attr->sample_period = hw_nmi_get_sample_period(watchdog_thresh);
-
- /* Try to register using hardware perf events */
- evt = perf_event_create_kernel_counter(wd_attr, cpu, NULL,
- watchdog_overflow_callback, NULL);
- if (IS_ERR(evt)) {
- pr_debug("Perf event create on CPU %d failed with %ld\n", cpu,
- PTR_ERR(evt));
- return PTR_ERR(evt);
- }
- this_cpu_write(watchdog_ev, evt);
- return 0;
-}
-
-/**
- * hardlockup_detector_perf_enable - Enable the local event
- */
-void hardlockup_detector_perf_enable(void)
-{
- if (hardlockup_detector_event_create())
- return;
-
- /* use original value for check */
- if (!atomic_fetch_inc(&watchdog_cpus))
- pr_info("Enabled. Permanently consumes one hw-PMU counter.\n");
-
- perf_event_enable(this_cpu_read(watchdog_ev));
-}
-
-/**
- * hardlockup_detector_perf_disable - Disable the local event
- */
-void hardlockup_detector_perf_disable(void)
-{
- struct perf_event *event = this_cpu_read(watchdog_ev);
-
- if (event) {
- perf_event_disable(event);
- this_cpu_write(watchdog_ev, NULL);
- this_cpu_write(dead_event, event);
- cpumask_set_cpu(smp_processor_id(), &dead_events_mask);
- atomic_dec(&watchdog_cpus);
- }
-}
-
-/**
- * hardlockup_detector_perf_cleanup - Cleanup disabled events and destroy them
- *
- * Called from lockup_detector_cleanup(). Serialized by the caller.
- */
-void hardlockup_detector_perf_cleanup(void)
-{
- int cpu;
-
- for_each_cpu(cpu, &dead_events_mask) {
- struct perf_event *event = per_cpu(dead_event, cpu);
-
- /*
- * Required because for_each_cpu() reports unconditionally
- * CPU0 as set on UP kernels. Sigh.
- */
- if (event)
- perf_event_release_kernel(event);
- per_cpu(dead_event, cpu) = NULL;
- }
- cpumask_clear(&dead_events_mask);
-}
-
-/**
- * hardlockup_detector_perf_stop - Globally stop watchdog events
- *
- * Special interface for x86 to handle the perf HT bug.
- */
-void __init hardlockup_detector_perf_stop(void)
-{
- int cpu;
-
- lockdep_assert_cpus_held();
-
- for_each_online_cpu(cpu) {
- struct perf_event *event = per_cpu(watchdog_ev, cpu);
-
- if (event)
- perf_event_disable(event);
- }
-}
-
-/**
- * hardlockup_detector_perf_restart - Globally restart watchdog events
- *
- * Special interface for x86 to handle the perf HT bug.
- */
-void __init hardlockup_detector_perf_restart(void)
-{
- int cpu;
-
- lockdep_assert_cpus_held();
-
- if (!(watchdog_enabled & NMI_WATCHDOG_ENABLED))
- return;
-
- for_each_online_cpu(cpu) {
- struct perf_event *event = per_cpu(watchdog_ev, cpu);
-
- if (event)
- perf_event_enable(event);
- }
-}
-
-/**
- * hardlockup_detector_perf_init - Probe whether NMI event is available at all
- */
-int __init hardlockup_detector_perf_init(void)
-{
- int ret = hardlockup_detector_event_create();
-
- if (ret) {
- pr_info("Perf NMI watchdog permanently disabled\n");
- } else {
- perf_event_release_kernel(this_cpu_read(watchdog_ev));
- this_cpu_write(watchdog_ev, NULL);
- }
- return ret;
-}
diff --git a/kernel/watchdog_hld_perf.c b/kernel/watchdog_hld_perf.c
new file mode 100644
index 000000000000..1d06ec5a8e42
--- /dev/null
+++ b/kernel/watchdog_hld_perf.c
@@ -0,0 +1,175 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Detect hard lockups on a system
+ *
+ * Copyright (C) Intel Corporation 2019
+ *
+ * Note: All of this code comes from the original perf-specific hardlockup
+ * detector.
+ */
+
+#define pr_fmt(fmt) "NMI perf watchdog: " fmt
+
+#include <linux/nmi.h>
+#include <linux/atomic.h>
+#include <linux/module.h>
+#include <linux/sched/debug.h>
+#include <linux/perf_event.h>
+#include <asm/irq_regs.h>
+
+static DEFINE_PER_CPU(struct perf_event *, watchdog_ev);
+static DEFINE_PER_CPU(struct perf_event *, dead_event);
+static struct cpumask dead_events_mask;
+
+static atomic_t watchdog_cpus = ATOMIC_INIT(0);
+
+static struct perf_event_attr wd_hw_attr = {
+ .type = PERF_TYPE_HARDWARE,
+ .config = PERF_COUNT_HW_CPU_CYCLES,
+ .size = sizeof(struct perf_event_attr),
+ .pinned = 1,
+ .disabled = 1,
+};
+
+/* Callback function for perf event subsystem */
+static void watchdog_overflow_callback(struct perf_event *event,
+ struct perf_sample_data *data,
+ struct pt_regs *regs)
+{
+ /* Ensure the watchdog never gets throttled */
+ event->hw.interrupts = 0;
+ inspect_for_hardlockups(regs);
+}
+
+static int hardlockup_detector_event_create(void)
+{
+ unsigned int cpu = smp_processor_id();
+ struct perf_event_attr *wd_attr;
+ struct perf_event *evt;
+
+ wd_attr = &wd_hw_attr;
+ wd_attr->sample_period = hw_nmi_get_sample_period(watchdog_thresh);
+
+ /* Try to register using hardware perf events */
+ evt = perf_event_create_kernel_counter(wd_attr, cpu, NULL,
+ watchdog_overflow_callback, NULL);
+ if (IS_ERR(evt)) {
+ pr_debug("Perf event create on CPU %d failed with %ld\n", cpu,
+ PTR_ERR(evt));
+ return PTR_ERR(evt);
+ }
+ this_cpu_write(watchdog_ev, evt);
+ return 0;
+}
+
+/**
+ * hardlockup_detector_perf_enable - Enable the local event
+ */
+void hardlockup_detector_perf_enable(void)
+{
+ if (hardlockup_detector_event_create())
+ return;
+
+ /* use original value for check */
+ if (!atomic_fetch_inc(&watchdog_cpus))
+ pr_info("Enabled. Permanently consumes one hw-PMU counter.\n");
+
+ perf_event_enable(this_cpu_read(watchdog_ev));
+}
+
+/**
+ * hardlockup_detector_perf_disable - Disable the local event
+ */
+void hardlockup_detector_perf_disable(void)
+{
+ struct perf_event *event = this_cpu_read(watchdog_ev);
+
+ if (event) {
+ perf_event_disable(event);
+ this_cpu_write(watchdog_ev, NULL);
+ this_cpu_write(dead_event, event);
+ cpumask_set_cpu(smp_processor_id(), &dead_events_mask);
+ atomic_dec(&watchdog_cpus);
+ }
+}
+
+/**
+ * hardlockup_detector_perf_cleanup - Cleanup disabled events and destroy them
+ *
+ * Called from lockup_detector_cleanup(). Serialized by the caller.
+ */
+void hardlockup_detector_perf_cleanup(void)
+{
+ int cpu;
+
+ for_each_cpu(cpu, &dead_events_mask) {
+ struct perf_event *event = per_cpu(dead_event, cpu);
+
+ /*
+ * Required because for_each_cpu() reports unconditionally
+ * CPU0 as set on UP kernels. Sigh.
+ */
+ if (event)
+ perf_event_release_kernel(event);
+ per_cpu(dead_event, cpu) = NULL;
+ }
+ cpumask_clear(&dead_events_mask);
+}
+
+/**
+ * hardlockup_detector_perf_stop - Globally stop watchdog events
+ *
+ * Special interface for x86 to handle the perf HT bug.
+ */
+void __init hardlockup_detector_perf_stop(void)
+{
+ int cpu;
+
+ lockdep_assert_cpus_held();
+
+ for_each_online_cpu(cpu) {
+ struct perf_event *event = per_cpu(watchdog_ev, cpu);
+
+ if (event)
+ perf_event_disable(event);
+ }
+}
+
+/**
+ * hardlockup_detector_perf_restart - Globally restart watchdog events
+ *
+ * Special interface for x86 to handle the perf HT bug.
+ */
+void __init hardlockup_detector_perf_restart(void)
+{
+ int cpu;
+
+ lockdep_assert_cpus_held();
+
+ if (!(watchdog_enabled & NMI_WATCHDOG_ENABLED))
+ return;
+
+ for_each_online_cpu(cpu) {
+ struct perf_event *event = per_cpu(watchdog_ev, cpu);
+
+ if (event)
+ perf_event_enable(event);
+ }
+}
+
+/**
+ * hardlockup_detector_perf_init - Probe whether NMI event is available at all
+ */
+int __init hardlockup_detector_perf_init(void)
+{
+ int ret = hardlockup_detector_event_create();
+
+ if (ret) {
+ pr_info("Perf NMI watchdog permanently disabled\n");
+ } else {
+ perf_event_release_kernel(this_cpu_read(watchdog_ev));
+ this_cpu_write(watchdog_ev, NULL);
+ }
+ return ret;
+}
+
--
2.17.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [RFC PATCH v2 08/14] watchdog/hardlockup: Decouple the hardlockup detector from perf
2019-02-27 16:05 ` [RFC PATCH v2 08/14] watchdog/hardlockup: Decouple the hardlockup detector from perf Ricardo Neri
@ 2019-03-26 21:18 ` Thomas Gleixner
2019-04-09 2:05 ` Ricardo Neri
0 siblings, 1 reply; 14+ messages in thread
From: Thomas Gleixner @ 2019-03-26 21:18 UTC (permalink / raw)
To: Ricardo Neri
Cc: Peter Zijlstra, Ricardo Neri, Paul Mackerras, H. Peter Anvin,
sparclinux, Ingo Molnar, Ashok Raj, x86, Andi Kleen,
Borislav Petkov, Don Zickus, Ravi V. Shankar, Frederic Weisbecker,
Nicholas Piggin, Mathieu Desnoyers, Tony Luck, Babu Moger,
linux-kernel, Luis R. Rodriguez, Masami Hiramatsu,
Philippe Ombredanne, Colin Ian King, Andrew Morton, linuxppc-dev,
David S. Miller
On Wed, 27 Feb 2019, Ricardo Neri wrote:
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Detect hard lockups on a system
> + *
> + * Copyright (C) Intel Corporation 2019
> + *
> + * Note: All of this code comes from the original perf-specific hardlockup
> + * detector.
And because you copied it from there without modification this becomes
automatically Copyrighted by Intel?
May I recommend that you talk to your legal departement about this.
Aside of that there is really no value in creating yet another file. The
code in question can simply wrapped into a large #ifdef PERF in the old
file.
Thanks,
tglx
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC PATCH v2 08/14] watchdog/hardlockup: Decouple the hardlockup detector from perf
2019-03-26 21:18 ` Thomas Gleixner
@ 2019-04-09 2:05 ` Ricardo Neri
0 siblings, 0 replies; 14+ messages in thread
From: Ricardo Neri @ 2019-04-09 2:05 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Peter Zijlstra, Ricardo Neri, Paul Mackerras, H. Peter Anvin,
sparclinux, Ingo Molnar, Ashok Raj, x86, Andi Kleen,
Borislav Petkov, Don Zickus, Ravi V. Shankar, Frederic Weisbecker,
Nicholas Piggin, Mathieu Desnoyers, Tony Luck, Babu Moger,
linux-kernel, Luis R. Rodriguez, Masami Hiramatsu,
Philippe Ombredanne, Colin Ian King, Andrew Morton, linuxppc-dev,
David S. Miller
On Tue, Mar 26, 2019 at 10:18:32PM +0100, Thomas Gleixner wrote:
> On Wed, 27 Feb 2019, Ricardo Neri wrote:
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Detect hard lockups on a system
> > + *
> > + * Copyright (C) Intel Corporation 2019
> > + *
> > + * Note: All of this code comes from the original perf-specific hardlockup
> > + * detector.
>
> And because you copied it from there without modification this becomes
> automatically Copyrighted by Intel?
Yes, it does not look correct.
>
> May I recommend that you talk to your legal departement about this.
>
> Aside of that there is really no value in creating yet another file. The
> code in question can simply wrapped into a large #ifdef PERF in the old
> file.
Sure, I'll implement the change in this manner.
Thanks and BR,
Ricardo
^ permalink raw reply [flat|nested] 14+ messages in thread
* [RFC PATCH v2 09/14] watchdog/hardlockup: Make arch_touch_nmi_watchdog() to hpet-based implementation
[not found] <1551283518-18922-1-git-send-email-ricardo.neri-calderon@linux.intel.com>
2019-02-27 16:05 ` [RFC PATCH v2 07/14] watchdog/hardlockup: Define a generic function to detect hardlockups Ricardo Neri
2019-02-27 16:05 ` [RFC PATCH v2 08/14] watchdog/hardlockup: Decouple the hardlockup detector from perf Ricardo Neri
@ 2019-02-27 16:05 ` Ricardo Neri
2019-02-27 16:17 ` Paul E. McKenney
2019-02-27 16:05 ` [RFC PATCH v2 10/14] kernel/watchdog: Add a function to obtain the watchdog_allowed_mask Ricardo Neri
3 siblings, 1 reply; 14+ messages in thread
From: Ricardo Neri @ 2019-02-27 16:05 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov
Cc: Rafael J. Wysocki, Peter Zijlstra, Alexei Starovoitov,
Kai-Heng Feng, Paul Mackerras, H. Peter Anvin, sparclinux,
Christoffer Dall, Davidlohr Bueso, Ashok Raj, x86, David Rientjes,
Andi Kleen, Waiman Long, Paul E. McKenney, Don Zickus,
Ravi V. Shankar, Konrad Rzeszutek Wilk, Marc Zyngier,
Ricardo Neri, Frederic Weisbecker, Nicholas Piggin, Ricardo Neri,
Byungchul Park, Mathieu Desnoyers, Josh Poimboeuf, Tony Luck,
Babu Moger, Randy Dunlap, linux-kernel, Luis R. Rodriguez,
Masami Hiramatsu, Philippe Ombredanne, Colin Ian King,
Andrew Morton, linuxppc-dev, David S. Miller
CPU architectures that have an NMI watchdog use arch_touch_nmi_watchdog()
to briefly ignore the hardlockup detector. If the architecture does not
have an NMI watchdog, one can be constructed using a source of non-
maskable interrupts. In this case, arch_touch_nmi_watchdog() is common
to any underlying hardware resource used to drive the detector and needs
to be available to other kernel subsystems if hardware different from perf
drives the detector.
There exists perf-based and HPET-based implementations. Make it available
to the latter.
For clarity, wrap this function in a separate preprocessor conditional
from functions which are truly specific to the perf-based implementation.
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ashok Raj <ashok.raj@intel.com>
Cc: Andi Kleen <andi.kleen@intel.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Frederic Weisbecker <frederic@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Babu Moger <babu.moger@oracle.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Cc: Colin Ian King <colin.king@canonical.com>
Cc: Byungchul Park <byungchul.park@lge.com>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: "Luis R. Rodriguez" <mcgrof@kernel.org>
Cc: Waiman Long <longman@redhat.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Christoffer Dall <cdall@linaro.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: David Rientjes <rientjes@google.com>
Cc: "Ravi V. Shankar" <ravi.v.shankar@intel.com>
Cc: x86@kernel.org
Cc: sparclinux@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
---
include/linux/nmi.h | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/include/linux/nmi.h b/include/linux/nmi.h
index 5a8b19749769..bf5ebcfdd590 100644
--- a/include/linux/nmi.h
+++ b/include/linux/nmi.h
@@ -94,8 +94,16 @@ static inline void hardlockup_detector_disable(void) {}
# define NMI_WATCHDOG_SYSCTL_PERM 0444
#endif
-#if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF)
+#if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF) || \
+ defined(CONFIG_X86_HARDLOCKUP_DETECTOR_HPET)
extern void arch_touch_nmi_watchdog(void);
+#else
+# if !defined(CONFIG_HAVE_NMI_WATCHDOG)
+static inline void arch_touch_nmi_watchdog(void) {}
+# endif
+#endif
+
+#if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF)
extern void hardlockup_detector_perf_stop(void);
extern void hardlockup_detector_perf_restart(void);
extern void hardlockup_detector_perf_disable(void);
--
2.17.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [RFC PATCH v2 09/14] watchdog/hardlockup: Make arch_touch_nmi_watchdog() to hpet-based implementation
2019-02-27 16:05 ` [RFC PATCH v2 09/14] watchdog/hardlockup: Make arch_touch_nmi_watchdog() to hpet-based implementation Ricardo Neri
@ 2019-02-27 16:17 ` Paul E. McKenney
2019-03-01 1:17 ` Ricardo Neri
0 siblings, 1 reply; 14+ messages in thread
From: Paul E. McKenney @ 2019-02-27 16:17 UTC (permalink / raw)
To: Ricardo Neri
Cc: Rafael J. Wysocki, Peter Zijlstra, Alexei Starovoitov,
Kai-Heng Feng, Paul Mackerras, H. Peter Anvin, sparclinux,
Ingo Molnar, Christoffer Dall, Davidlohr Bueso, Ashok Raj, x86,
David Rientjes, Andi Kleen, Waiman Long, Borislav Petkov,
Don Zickus, Ravi V. Shankar, Konrad Rzeszutek Wilk, Marc Zyngier,
Frederic Weisbecker, Nicholas Piggin, Ricardo Neri,
Byungchul Park, Mathieu Desnoyers, Josh Poimboeuf,
Thomas Gleixner, Tony Luck, Babu Moger, Randy Dunlap,
linux-kernel, Luis R. Rodriguez, Masami Hiramatsu,
Philippe Ombredanne, Colin Ian King, Andrew Morton, linuxppc-dev,
David S. Miller
On Wed, Feb 27, 2019 at 08:05:13AM -0800, Ricardo Neri wrote:
> CPU architectures that have an NMI watchdog use arch_touch_nmi_watchdog()
> to briefly ignore the hardlockup detector. If the architecture does not
> have an NMI watchdog, one can be constructed using a source of non-
> maskable interrupts. In this case, arch_touch_nmi_watchdog() is common
> to any underlying hardware resource used to drive the detector and needs
> to be available to other kernel subsystems if hardware different from perf
> drives the detector.
>
> There exists perf-based and HPET-based implementations. Make it available
> to the latter.
>
> For clarity, wrap this function in a separate preprocessor conditional
> from functions which are truly specific to the perf-based implementation.
>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: Ashok Raj <ashok.raj@intel.com>
> Cc: Andi Kleen <andi.kleen@intel.com>
> Cc: Tony Luck <tony.luck@intel.com>
> Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
> Cc: Don Zickus <dzickus@redhat.com>
> Cc: Nicholas Piggin <npiggin@gmail.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Frederic Weisbecker <frederic@kernel.org>
> Cc: Alexei Starovoitov <ast@kernel.org>
> Cc: Babu Moger <babu.moger@oracle.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> Cc: Masami Hiramatsu <mhiramat@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Philippe Ombredanne <pombredanne@nexb.com>
> Cc: Colin Ian King <colin.king@canonical.com>
> Cc: Byungchul Park <byungchul.park@lge.com>
> Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
> Cc: "Luis R. Rodriguez" <mcgrof@kernel.org>
> Cc: Waiman Long <longman@redhat.com>
> Cc: Josh Poimboeuf <jpoimboe@redhat.com>
> Cc: Randy Dunlap <rdunlap@infradead.org>
> Cc: Davidlohr Bueso <dave@stgolabs.net>
> Cc: Christoffer Dall <cdall@linaro.org>
> Cc: Marc Zyngier <marc.zyngier@arm.com>
> Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: David Rientjes <rientjes@google.com>
> Cc: "Ravi V. Shankar" <ravi.v.shankar@intel.com>
> Cc: x86@kernel.org
> Cc: sparclinux@vger.kernel.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
> ---
> include/linux/nmi.h | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/nmi.h b/include/linux/nmi.h
> index 5a8b19749769..bf5ebcfdd590 100644
> --- a/include/linux/nmi.h
> +++ b/include/linux/nmi.h
> @@ -94,8 +94,16 @@ static inline void hardlockup_detector_disable(void) {}
> # define NMI_WATCHDOG_SYSCTL_PERM 0444
> #endif
>
> -#if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF)
> +#if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF) || \
> + defined(CONFIG_X86_HARDLOCKUP_DETECTOR_HPET)
Why not instead make CONFIG_X86_HARDLOCKUP_DETECTOR_HPET select
CONFIG_HARDLOCKUP_DETECTOR_PERF? Keep the arch-specific details
in the arch-specific files and all that.
Thanx, Paul
> extern void arch_touch_nmi_watchdog(void);
> +#else
> +# if !defined(CONFIG_HAVE_NMI_WATCHDOG)
> +static inline void arch_touch_nmi_watchdog(void) {}
> +# endif
> +#endif
> +
> +#if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF)
> extern void hardlockup_detector_perf_stop(void);
> extern void hardlockup_detector_perf_restart(void);
> extern void hardlockup_detector_perf_disable(void);
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC PATCH v2 09/14] watchdog/hardlockup: Make arch_touch_nmi_watchdog() to hpet-based implementation
2019-02-27 16:17 ` Paul E. McKenney
@ 2019-03-01 1:17 ` Ricardo Neri
2019-03-26 21:20 ` Thomas Gleixner
0 siblings, 1 reply; 14+ messages in thread
From: Ricardo Neri @ 2019-03-01 1:17 UTC (permalink / raw)
To: Paul E. McKenney
Cc: Rafael J. Wysocki, Peter Zijlstra, Alexei Starovoitov,
Kai-Heng Feng, Paul Mackerras, H. Peter Anvin, sparclinux,
Ingo Molnar, Christoffer Dall, Davidlohr Bueso, Ashok Raj, x86,
David Rientjes, Andi Kleen, Waiman Long, Borislav Petkov,
Don Zickus, Ravi V. Shankar, Konrad Rzeszutek Wilk, Marc Zyngier,
Frederic Weisbecker, Nicholas Piggin, Ricardo Neri,
Byungchul Park, Mathieu Desnoyers, Josh Poimboeuf,
Thomas Gleixner, Tony Luck, Babu Moger, Randy Dunlap,
linux-kernel, Luis R. Rodriguez, Masami Hiramatsu,
Philippe Ombredanne, Colin Ian King, Andrew Morton, linuxppc-dev,
David S. Miller
On Wed, Feb 27, 2019 at 08:17:58AM -0800, Paul E. McKenney wrote:
> On Wed, Feb 27, 2019 at 08:05:13AM -0800, Ricardo Neri wrote:
> > CPU architectures that have an NMI watchdog use arch_touch_nmi_watchdog()
> > to briefly ignore the hardlockup detector. If the architecture does not
> > have an NMI watchdog, one can be constructed using a source of non-
> > maskable interrupts. In this case, arch_touch_nmi_watchdog() is common
> > to any underlying hardware resource used to drive the detector and needs
> > to be available to other kernel subsystems if hardware different from perf
> > drives the detector.
> >
> > There exists perf-based and HPET-based implementations. Make it available
> > to the latter.
> >
> > For clarity, wrap this function in a separate preprocessor conditional
> > from functions which are truly specific to the perf-based implementation.
> >
> > Cc: "H. Peter Anvin" <hpa@zytor.com>
> > Cc: Ashok Raj <ashok.raj@intel.com>
> > Cc: Andi Kleen <andi.kleen@intel.com>
> > Cc: Tony Luck <tony.luck@intel.com>
> > Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
> > Cc: Don Zickus <dzickus@redhat.com>
> > Cc: Nicholas Piggin <npiggin@gmail.com>
> > Cc: Michael Ellerman <mpe@ellerman.id.au>
> > Cc: Frederic Weisbecker <frederic@kernel.org>
> > Cc: Alexei Starovoitov <ast@kernel.org>
> > Cc: Babu Moger <babu.moger@oracle.com>
> > Cc: "David S. Miller" <davem@davemloft.net>
> > Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> > Cc: Paul Mackerras <paulus@samba.org>
> > Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> > Cc: Masami Hiramatsu <mhiramat@kernel.org>
> > Cc: Peter Zijlstra <peterz@infradead.org>
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> > Cc: Philippe Ombredanne <pombredanne@nexb.com>
> > Cc: Colin Ian King <colin.king@canonical.com>
> > Cc: Byungchul Park <byungchul.park@lge.com>
> > Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
> > Cc: "Luis R. Rodriguez" <mcgrof@kernel.org>
> > Cc: Waiman Long <longman@redhat.com>
> > Cc: Josh Poimboeuf <jpoimboe@redhat.com>
> > Cc: Randy Dunlap <rdunlap@infradead.org>
> > Cc: Davidlohr Bueso <dave@stgolabs.net>
> > Cc: Christoffer Dall <cdall@linaro.org>
> > Cc: Marc Zyngier <marc.zyngier@arm.com>
> > Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>
> > Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> > Cc: David Rientjes <rientjes@google.com>
> > Cc: "Ravi V. Shankar" <ravi.v.shankar@intel.com>
> > Cc: x86@kernel.org
> > Cc: sparclinux@vger.kernel.org
> > Cc: linuxppc-dev@lists.ozlabs.org
> > Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
> > ---
> > include/linux/nmi.h | 10 +++++++++-
> > 1 file changed, 9 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/linux/nmi.h b/include/linux/nmi.h
> > index 5a8b19749769..bf5ebcfdd590 100644
> > --- a/include/linux/nmi.h
> > +++ b/include/linux/nmi.h
> > @@ -94,8 +94,16 @@ static inline void hardlockup_detector_disable(void) {}
> > # define NMI_WATCHDOG_SYSCTL_PERM 0444
> > #endif
> >
> > -#if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF)
> > +#if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF) || \
> > + defined(CONFIG_X86_HARDLOCKUP_DETECTOR_HPET)
>
> Why not instead make CONFIG_X86_HARDLOCKUP_DETECTOR_HPET select
> CONFIG_HARDLOCKUP_DETECTOR_PERF? Keep the arch-specific details
> in the arch-specific files and all that.
Thanks for your feedback, Paul! The HPET implementation does not use
perf. Thus, in my opinion is not correct for the HPET HLD to select
the perf implementation. Patch 8 of this series splits the perf-specific
code and the generic hardlockup detector code. Does this make sense?
Thanks and BR,
Ricardo
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC PATCH v2 09/14] watchdog/hardlockup: Make arch_touch_nmi_watchdog() to hpet-based implementation
2019-03-01 1:17 ` Ricardo Neri
@ 2019-03-26 21:20 ` Thomas Gleixner
2019-04-09 2:05 ` Ricardo Neri
0 siblings, 1 reply; 14+ messages in thread
From: Thomas Gleixner @ 2019-03-26 21:20 UTC (permalink / raw)
To: Ricardo Neri
Cc: Rafael J. Wysocki, Peter Zijlstra, Alexei Starovoitov,
Kai-Heng Feng, Paul Mackerras, H. Peter Anvin, sparclinux,
Paul E. McKenney, Ingo Molnar, Christoffer Dall, Davidlohr Bueso,
Ashok Raj, x86, David Rientjes, Andi Kleen, Waiman Long,
Borislav Petkov, Don Zickus, Ravi V. Shankar,
Konrad Rzeszutek Wilk, Marc Zyngier, Frederic Weisbecker,
Nicholas Piggin, Ricardo Neri, Byungchul Park, Mathieu Desnoyers,
Josh Poimboeuf, Tony Luck, Babu Moger, Randy Dunlap, linux-kernel,
Luis R. Rodriguez, Masami Hiramatsu, Philippe Ombredanne,
Colin Ian King, Andrew Morton, linuxppc-dev, David S. Miller
On Thu, 28 Feb 2019, Ricardo Neri wrote:
> > >
> > > -#if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF)
> > > +#if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF) || \
> > > + defined(CONFIG_X86_HARDLOCKUP_DETECTOR_HPET)
> >
> > Why not instead make CONFIG_X86_HARDLOCKUP_DETECTOR_HPET select
> > CONFIG_HARDLOCKUP_DETECTOR_PERF? Keep the arch-specific details
> > in the arch-specific files and all that.
>
> Thanks for your feedback, Paul! The HPET implementation does not use
> perf. Thus, in my opinion is not correct for the HPET HLD to select
> the perf implementation. Patch 8 of this series splits the perf-specific
> code and the generic hardlockup detector code. Does this make sense?
That's what intermediate config symbols are for.
config HARDLOCKUP_DETECTOR_CORE
bool
And make both PERF and HPET select it.
Thanks,
tglx
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC PATCH v2 09/14] watchdog/hardlockup: Make arch_touch_nmi_watchdog() to hpet-based implementation
2019-03-26 21:20 ` Thomas Gleixner
@ 2019-04-09 2:05 ` Ricardo Neri
0 siblings, 0 replies; 14+ messages in thread
From: Ricardo Neri @ 2019-04-09 2:05 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Rafael J. Wysocki, Peter Zijlstra, Alexei Starovoitov,
Kai-Heng Feng, Paul Mackerras, H. Peter Anvin, sparclinux,
Paul E. McKenney, Ingo Molnar, Christoffer Dall, Davidlohr Bueso,
Ashok Raj, x86, David Rientjes, Andi Kleen, Waiman Long,
Borislav Petkov, Don Zickus, Ravi V. Shankar,
Konrad Rzeszutek Wilk, Marc Zyngier, Frederic Weisbecker,
Nicholas Piggin, Ricardo Neri, Byungchul Park, Mathieu Desnoyers,
Josh Poimboeuf, Tony Luck, Babu Moger, Randy Dunlap, linux-kernel,
Luis R. Rodriguez, Masami Hiramatsu, Philippe Ombredanne,
Colin Ian King, Andrew Morton, linuxppc-dev, David S. Miller
On Tue, Mar 26, 2019 at 10:20:41PM +0100, Thomas Gleixner wrote:
> On Thu, 28 Feb 2019, Ricardo Neri wrote:
> > > >
> > > > -#if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF)
> > > > +#if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF) || \
> > > > + defined(CONFIG_X86_HARDLOCKUP_DETECTOR_HPET)
> > >
> > > Why not instead make CONFIG_X86_HARDLOCKUP_DETECTOR_HPET select
> > > CONFIG_HARDLOCKUP_DETECTOR_PERF? Keep the arch-specific details
> > > in the arch-specific files and all that.
> >
> > Thanks for your feedback, Paul! The HPET implementation does not use
> > perf. Thus, in my opinion is not correct for the HPET HLD to select
> > the perf implementation. Patch 8 of this series splits the perf-specific
> > code and the generic hardlockup detector code. Does this make sense?
>
> That's what intermediate config symbols are for.
>
> config HARDLOCKUP_DETECTOR_CORE
> bool
>
> And make both PERF and HPET select it.
I'll implement it in this manner.
Thanks and BR,
Ricardo
^ permalink raw reply [flat|nested] 14+ messages in thread
* [RFC PATCH v2 10/14] kernel/watchdog: Add a function to obtain the watchdog_allowed_mask
[not found] <1551283518-18922-1-git-send-email-ricardo.neri-calderon@linux.intel.com>
` (2 preceding siblings ...)
2019-02-27 16:05 ` [RFC PATCH v2 09/14] watchdog/hardlockup: Make arch_touch_nmi_watchdog() to hpet-based implementation Ricardo Neri
@ 2019-02-27 16:05 ` Ricardo Neri
2019-03-26 21:22 ` Thomas Gleixner
2019-04-09 11:34 ` Peter Zijlstra
3 siblings, 2 replies; 14+ messages in thread
From: Ricardo Neri @ 2019-02-27 16:05 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov
Cc: Rafael J. Wysocki, Peter Zijlstra, Alexei Starovoitov,
Kai-Heng Feng, Paul Mackerras, H. Peter Anvin, sparclinux,
Christoffer Dall, Davidlohr Bueso, Ashok Raj, x86, David Rientjes,
Andi Kleen, Waiman Long, Paul E. McKenney, Don Zickus,
Ravi V. Shankar, Konrad Rzeszutek Wilk, Marc Zyngier,
Ricardo Neri, Frederic Weisbecker, Nicholas Piggin, Ricardo Neri,
Byungchul Park, Mathieu Desnoyers, Josh Poimboeuf, Tony Luck,
Babu Moger, Randy Dunlap, linux-kernel, Luis R. Rodriguez,
Masami Hiramatsu, Philippe Ombredanne, Colin Ian King,
Andrew Morton, linuxppc-dev, David S. Miller
Implementations of NMI watchdogs that use a single piece of hardware to
monitor all the CPUs in the system (as opposed to per-CPU implementations
such as perf) need to know which CPUs the watchdog is allowed to monitor.
In this manner, non-maskable interrupts are directed only to the monitored
CPUs.
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ashok Raj <ashok.raj@intel.com>
Cc: Andi Kleen <andi.kleen@intel.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Frederic Weisbecker <frederic@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Babu Moger <babu.moger@oracle.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Cc: Colin Ian King <colin.king@canonical.com>
Cc: Byungchul Park <byungchul.park@lge.com>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: "Luis R. Rodriguez" <mcgrof@kernel.org>
Cc: Waiman Long <longman@redhat.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Christoffer Dall <cdall@linaro.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: David Rientjes <rientjes@google.com>
Cc: "Ravi V. Shankar" <ravi.v.shankar@intel.com>
Cc: x86@kernel.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: sparclinux@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
---
include/linux/nmi.h | 1 +
kernel/watchdog.c | 7 ++++++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/include/linux/nmi.h b/include/linux/nmi.h
index bf5ebcfdd590..b563fb6ef21d 100644
--- a/include/linux/nmi.h
+++ b/include/linux/nmi.h
@@ -83,6 +83,7 @@ static inline void reset_hung_task_detector(void) { }
#if defined(CONFIG_HARDLOCKUP_DETECTOR)
extern void hardlockup_detector_disable(void);
+extern struct cpumask *watchdog_get_allowed_cpumask(void);
extern unsigned int hardlockup_panic;
#else
static inline void hardlockup_detector_disable(void) {}
diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index 8fbfda94a67b..367aa81294ef 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -44,7 +44,7 @@ int __read_mostly soft_watchdog_user_enabled = 1;
int __read_mostly watchdog_thresh = 10;
int __read_mostly nmi_watchdog_available;
-struct cpumask watchdog_allowed_mask __read_mostly;
+static struct cpumask watchdog_allowed_mask __read_mostly;
struct cpumask watchdog_cpumask __read_mostly;
unsigned long *watchdog_cpumask_bits = cpumask_bits(&watchdog_cpumask);
@@ -92,6 +92,11 @@ static int __init hardlockup_all_cpu_backtrace_setup(char *str)
}
__setup("hardlockup_all_cpu_backtrace=", hardlockup_all_cpu_backtrace_setup);
# endif /* CONFIG_SMP */
+
+struct cpumask *watchdog_get_allowed_cpumask(void)
+{
+ return &watchdog_allowed_mask;
+}
#endif /* CONFIG_HARDLOCKUP_DETECTOR */
/*
--
2.17.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [RFC PATCH v2 10/14] kernel/watchdog: Add a function to obtain the watchdog_allowed_mask
2019-02-27 16:05 ` [RFC PATCH v2 10/14] kernel/watchdog: Add a function to obtain the watchdog_allowed_mask Ricardo Neri
@ 2019-03-26 21:22 ` Thomas Gleixner
2019-04-09 2:05 ` Ricardo Neri
2019-04-09 11:34 ` Peter Zijlstra
1 sibling, 1 reply; 14+ messages in thread
From: Thomas Gleixner @ 2019-03-26 21:22 UTC (permalink / raw)
To: Ricardo Neri
Cc: Rafael J. Wysocki, Peter Zijlstra, Alexei Starovoitov,
Kai-Heng Feng, Paul Mackerras, H. Peter Anvin, sparclinux,
Ingo Molnar, Christoffer Dall, Davidlohr Bueso, Ashok Raj, x86,
David Rientjes, Andi Kleen, Waiman Long, Borislav Petkov,
Don Zickus, Ravi V. Shankar, Konrad Rzeszutek Wilk, Marc Zyngier,
Frederic Weisbecker, Nicholas Piggin, Ricardo Neri,
Byungchul Park, Mathieu Desnoyers, Josh Poimboeuf,
Paul E. McKenney, Tony Luck, Babu Moger, Randy Dunlap,
linux-kernel, Luis R. Rodriguez, Masami Hiramatsu,
Philippe Ombredanne, Colin Ian King, Andrew Morton, linuxppc-dev,
David S. Miller
On Wed, 27 Feb 2019, Ricardo Neri wrote:
>
> -struct cpumask watchdog_allowed_mask __read_mostly;
> +static struct cpumask watchdog_allowed_mask __read_mostly;
That hunk is correct.
> struct cpumask watchdog_cpumask __read_mostly;
> unsigned long *watchdog_cpumask_bits = cpumask_bits(&watchdog_cpumask);
> @@ -92,6 +92,11 @@ static int __init hardlockup_all_cpu_backtrace_setup(char *str)
> }
> __setup("hardlockup_all_cpu_backtrace=", hardlockup_all_cpu_backtrace_setup);
> # endif /* CONFIG_SMP */
> +
> +struct cpumask *watchdog_get_allowed_cpumask(void)
> +{
> + return &watchdog_allowed_mask;
> +}
That part is pointless as I showed you in the other reply. You don't need
that mask in your code at all.
Thanks,
tglx
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC PATCH v2 10/14] kernel/watchdog: Add a function to obtain the watchdog_allowed_mask
2019-03-26 21:22 ` Thomas Gleixner
@ 2019-04-09 2:05 ` Ricardo Neri
0 siblings, 0 replies; 14+ messages in thread
From: Ricardo Neri @ 2019-04-09 2:05 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Rafael J. Wysocki, Peter Zijlstra, Alexei Starovoitov,
Kai-Heng Feng, Paul Mackerras, H. Peter Anvin, sparclinux,
Ingo Molnar, Christoffer Dall, Davidlohr Bueso, Ashok Raj, x86,
David Rientjes, Andi Kleen, Waiman Long, Borislav Petkov,
Don Zickus, Ravi V. Shankar, Konrad Rzeszutek Wilk, Marc Zyngier,
Frederic Weisbecker, Nicholas Piggin, Ricardo Neri,
Byungchul Park, Mathieu Desnoyers, Josh Poimboeuf,
Paul E. McKenney, Tony Luck, Babu Moger, Randy Dunlap,
linux-kernel, Luis R. Rodriguez, Masami Hiramatsu,
Philippe Ombredanne, Colin Ian King, Andrew Morton, linuxppc-dev,
David S. Miller
On Tue, Mar 26, 2019 at 10:22:40PM +0100, Thomas Gleixner wrote:
> On Wed, 27 Feb 2019, Ricardo Neri wrote:
> >
> > -struct cpumask watchdog_allowed_mask __read_mostly;
> > +static struct cpumask watchdog_allowed_mask __read_mostly;
>
> That hunk is correct.
I'll send a separate patch with this hunk only.
>
> > struct cpumask watchdog_cpumask __read_mostly;
> > unsigned long *watchdog_cpumask_bits = cpumask_bits(&watchdog_cpumask);
> > @@ -92,6 +92,11 @@ static int __init hardlockup_all_cpu_backtrace_setup(char *str)
> > }
> > __setup("hardlockup_all_cpu_backtrace=", hardlockup_all_cpu_backtrace_setup);
> > # endif /* CONFIG_SMP */
> > +
> > +struct cpumask *watchdog_get_allowed_cpumask(void)
> > +{
> > + return &watchdog_allowed_mask;
> > +}
>
> That part is pointless as I showed you in the other reply. You don't need
> that mask in your code at all.
Yes. I'll remove this hunk and follow the approach you suggested in your
reply to patch 11.
Thanks and BR,
Ricardo
>
> Thanks,
>
> tglx
>
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC PATCH v2 10/14] kernel/watchdog: Add a function to obtain the watchdog_allowed_mask
2019-02-27 16:05 ` [RFC PATCH v2 10/14] kernel/watchdog: Add a function to obtain the watchdog_allowed_mask Ricardo Neri
2019-03-26 21:22 ` Thomas Gleixner
@ 2019-04-09 11:34 ` Peter Zijlstra
2019-04-11 1:15 ` Ricardo Neri
1 sibling, 1 reply; 14+ messages in thread
From: Peter Zijlstra @ 2019-04-09 11:34 UTC (permalink / raw)
To: Ricardo Neri
Cc: Rafael J. Wysocki, Alexei Starovoitov, Kai-Heng Feng,
Paul Mackerras, H. Peter Anvin, sparclinux, Ingo Molnar,
Christoffer Dall, Davidlohr Bueso, Ashok Raj, x86, David Rientjes,
Andi Kleen, Waiman Long, Borislav Petkov, Don Zickus,
Ravi V. Shankar, Konrad Rzeszutek Wilk, Marc Zyngier,
Frederic Weisbecker, Nicholas Piggin, Ricardo Neri,
Byungchul Park, Mathieu Desnoyers, Josh Poimboeuf,
Paul E. McKenney, Thomas Gleixner, Tony Luck, Babu Moger,
Randy Dunlap, linux-kernel, Luis R. Rodriguez, Masami Hiramatsu,
Philippe Ombredanne, Colin Ian King, Andrew Morton, linuxppc-dev,
David S. Miller
On Wed, Feb 27, 2019 at 08:05:14AM -0800, Ricardo Neri wrote:
> diff --git a/kernel/watchdog.c b/kernel/watchdog.c
> index 8fbfda94a67b..367aa81294ef 100644
> --- a/kernel/watchdog.c
> +++ b/kernel/watchdog.c
> @@ -44,7 +44,7 @@ int __read_mostly soft_watchdog_user_enabled = 1;
> int __read_mostly watchdog_thresh = 10;
> int __read_mostly nmi_watchdog_available;
>
> -struct cpumask watchdog_allowed_mask __read_mostly;
> +static struct cpumask watchdog_allowed_mask __read_mostly;
>
> struct cpumask watchdog_cpumask __read_mostly;
> unsigned long *watchdog_cpumask_bits = cpumask_bits(&watchdog_cpumask);
Hurmph, more struct cpumask, ideally this would get converted to
cpumask_var_t, I don't think we need this before the allocators work, do
we?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC PATCH v2 10/14] kernel/watchdog: Add a function to obtain the watchdog_allowed_mask
2019-04-09 11:34 ` Peter Zijlstra
@ 2019-04-11 1:15 ` Ricardo Neri
0 siblings, 0 replies; 14+ messages in thread
From: Ricardo Neri @ 2019-04-11 1:15 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Rafael J. Wysocki, Alexei Starovoitov, Kai-Heng Feng,
Paul Mackerras, H. Peter Anvin, sparclinux, Ingo Molnar,
Christoffer Dall, Davidlohr Bueso, Ashok Raj, x86, David Rientjes,
Andi Kleen, Waiman Long, Borislav Petkov, Don Zickus,
Ravi V. Shankar, Konrad Rzeszutek Wilk, Marc Zyngier,
Frederic Weisbecker, Nicholas Piggin, Ricardo Neri,
Byungchul Park, Mathieu Desnoyers, Josh Poimboeuf,
Paul E. McKenney, Thomas Gleixner, Tony Luck, Babu Moger,
Randy Dunlap, linux-kernel, Luis R. Rodriguez, Masami Hiramatsu,
Philippe Ombredanne, Colin Ian King, Andrew Morton, linuxppc-dev,
David S. Miller
On Tue, Apr 09, 2019 at 01:34:21PM +0200, Peter Zijlstra wrote:
> On Wed, Feb 27, 2019 at 08:05:14AM -0800, Ricardo Neri wrote:
> > diff --git a/kernel/watchdog.c b/kernel/watchdog.c
> > index 8fbfda94a67b..367aa81294ef 100644
> > --- a/kernel/watchdog.c
> > +++ b/kernel/watchdog.c
> > @@ -44,7 +44,7 @@ int __read_mostly soft_watchdog_user_enabled = 1;
> > int __read_mostly watchdog_thresh = 10;
> > int __read_mostly nmi_watchdog_available;
> >
> > -struct cpumask watchdog_allowed_mask __read_mostly;
> > +static struct cpumask watchdog_allowed_mask __read_mostly;
> >
> > struct cpumask watchdog_cpumask __read_mostly;
> > unsigned long *watchdog_cpumask_bits = cpumask_bits(&watchdog_cpumask);
>
> Hurmph, more struct cpumask, ideally this would get converted to
> cpumask_var_t, I don't think we need this before the allocators work, do
> we?
I see mm_init() is called before lockup_detector_init(); both from start_kernel().
Thus, IMHO, kzalloc should work at this point.
Thanks and BR,
Ricardo
^ permalink raw reply [flat|nested] 14+ messages in thread