2008-10-27 16:41:32

by Aristeu Rozanski

[permalink] [raw]
Subject: [PATCH 1/2] NMI watchdog: add support to enable and disable IOAPIC NMI

This patch adds support to enable/disable IOAPIC NMI watchdog in runtime via
procfs.

Signed-off-by: Aristeu Rozanski <[email protected]>

---
arch/x86/kernel/nmi.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)

--- linus-2.6.orig/arch/x86/kernel/nmi.c 2008-10-27 11:31:56.000000000 -0400
+++ linus-2.6/arch/x86/kernel/nmi.c 2008-10-27 11:43:49.000000000 -0400
@@ -340,6 +340,8 @@ void stop_apic_nmi_watchdog(void *unused
return;
if (nmi_watchdog == NMI_LOCAL_APIC)
lapic_watchdog_stop();
+ else
+ __acpi_nmi_disable(NULL);
__get_cpu_var(wd_enabled) = 0;
atomic_dec(&nmi_active);
}
@@ -465,6 +467,24 @@ nmi_watchdog_tick(struct pt_regs *regs,

#ifdef CONFIG_SYSCTL

+static void enable_ioapic_nmi_watchdog_single(void *unused)
+{
+ __get_cpu_var(wd_enabled) = 1;
+ atomic_inc(&nmi_active);
+ __acpi_nmi_enable(NULL);
+}
+
+static void enable_ioapic_nmi_watchdog(void)
+{
+ on_each_cpu(enable_ioapic_nmi_watchdog_single, NULL, 1);
+ touch_nmi_watchdog();
+}
+
+static void disable_ioapic_nmi_watchdog(void)
+{
+ on_each_cpu(stop_apic_nmi_watchdog, NULL, 1);
+}
+
static int __init setup_unknown_nmi_panic(char *str)
{
unknown_nmi_panic = 1;
@@ -507,6 +527,11 @@ int proc_nmi_enabled(struct ctl_table *t
enable_lapic_nmi_watchdog();
else
disable_lapic_nmi_watchdog();
+ } else if (nmi_watchdog == NMI_IO_APIC) {
+ if (nmi_watchdog_enabled)
+ enable_ioapic_nmi_watchdog();
+ else
+ disable_ioapic_nmi_watchdog();
} else {
printk(KERN_WARNING
"NMI watchdog doesn't know what hardware to touch\n");

--
Aristeu


2008-10-29 16:06:36

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH 1/2] NMI watchdog: add support to enable and disable IOAPIC NMI

On Mon, 27 Oct 2008 12:42:34 -0400 Aristeu Rozanski wrote:

> This patch adds support to enable/disable IOAPIC NMI watchdog in runtime via
> procfs.

Some info on how to use this, what to write(?) to what file(?) in procfs
would be Very Good to have.


> Signed-off-by: Aristeu Rozanski <[email protected]>
>
> ---
> arch/x86/kernel/nmi.c | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> --- linus-2.6.orig/arch/x86/kernel/nmi.c 2008-10-27 11:31:56.000000000 -0400
> +++ linus-2.6/arch/x86/kernel/nmi.c 2008-10-27 11:43:49.000000000 -0400
> @@ -340,6 +340,8 @@ void stop_apic_nmi_watchdog(void *unused
> return;
> if (nmi_watchdog == NMI_LOCAL_APIC)
> lapic_watchdog_stop();
> + else
> + __acpi_nmi_disable(NULL);
> __get_cpu_var(wd_enabled) = 0;
> atomic_dec(&nmi_active);
> }
> @@ -465,6 +467,24 @@ nmi_watchdog_tick(struct pt_regs *regs,
>
> #ifdef CONFIG_SYSCTL
>
> +static void enable_ioapic_nmi_watchdog_single(void *unused)
> +{
> + __get_cpu_var(wd_enabled) = 1;
> + atomic_inc(&nmi_active);
> + __acpi_nmi_enable(NULL);
> +}
> +
> +static void enable_ioapic_nmi_watchdog(void)
> +{
> + on_each_cpu(enable_ioapic_nmi_watchdog_single, NULL, 1);
> + touch_nmi_watchdog();
> +}
> +
> +static void disable_ioapic_nmi_watchdog(void)
> +{
> + on_each_cpu(stop_apic_nmi_watchdog, NULL, 1);
> +}
> +
> static int __init setup_unknown_nmi_panic(char *str)
> {
> unknown_nmi_panic = 1;
> @@ -507,6 +527,11 @@ int proc_nmi_enabled(struct ctl_table *t
> enable_lapic_nmi_watchdog();
> else
> disable_lapic_nmi_watchdog();
> + } else if (nmi_watchdog == NMI_IO_APIC) {
> + if (nmi_watchdog_enabled)
> + enable_ioapic_nmi_watchdog();
> + else
> + disable_ioapic_nmi_watchdog();
> } else {
> printk(KERN_WARNING
> "NMI watchdog doesn't know what hardware to touch\n");
>
> --

---
~Randy

2008-10-29 20:38:28

by Aristeu Rozanski

[permalink] [raw]
Subject: Re: [PATCH 1/2] NMI watchdog: add support to enable and disable IOAPIC NMI

> > > This patch adds support to enable/disable IOAPIC NMI watchdog in runtime via
> > > procfs.
> >
> > Some info on how to use this, what to write(?) to what file(?) in procfs
> > would be Very Good to have.
>
> I gather this is an extension to the existing interface already covering
> the local APIC NMI watchdog, which surely ;) must have been documented at
> the time it was added. If it wasn't, then we cannot require it now as a
> prerequisite to accept this patch, although such documentation would be
> desirable as a separate submission.
What about (if OK, I'll resubmit in a different thread with proper format):

---
Documentation/nmi_watchdog.txt | 5 +++++
1 file changed, 5 insertions(+)

--- linus-2.6.orig/Documentation/nmi_watchdog.txt 2008-10-24 11:41:30.000000000 -0400
+++ linus-2.6/Documentation/nmi_watchdog.txt 2008-10-29 16:38:12.000000000 -0400
@@ -69,6 +69,11 @@ to the overall system performance.
On x86 nmi_watchdog is disabled by default so you have to enable it with
a boot time parameter.

+It's possible to disable the NMI watchdog in run-time by writing "0" to
+/proc/sys/kernel/nmi_watchdog. Writing "1" to the same file will re-enable
+the NMI watchdog. Notice that you still need to use "nmi_watchdog=" parameter
+in boot time.
+
NOTE: In kernels prior to 2.4.2-ac18 the NMI-oopser is enabled unconditionally
on x86 SMP boxes.

2008-10-29 21:53:26

by Maciej W. Rozycki

[permalink] [raw]
Subject: Re: [PATCH 1/2] NMI watchdog: add support to enable and disable IOAPIC NMI

On Wed, 29 Oct 2008, Randy Dunlap wrote:

> > This patch adds support to enable/disable IOAPIC NMI watchdog in runtime via
> > procfs.
>
> Some info on how to use this, what to write(?) to what file(?) in procfs
> would be Very Good to have.

I gather this is an extension to the existing interface already covering
the local APIC NMI watchdog, which surely ;) must have been documented at
the time it was added. If it wasn't, then we cannot require it now as a
prerequisite to accept this patch, although such documentation would be
desirable as a separate submission.

Maciej

2008-10-30 00:51:14

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH 1/2] NMI watchdog: add support to enable and disable IOAPIC NMI

On Wed, 29 Oct 2008 16:39:19 -0400 Aristeu Rozanski wrote:

> > > > This patch adds support to enable/disable IOAPIC NMI watchdog in runtime via
> > > > procfs.
> > >
> > > Some info on how to use this, what to write(?) to what file(?) in procfs
> > > would be Very Good to have.
> >
> > I gather this is an extension to the existing interface already covering
> > the local APIC NMI watchdog, which surely ;) must have been documented at
> > the time it was added. If it wasn't, then we cannot require it now as a
> > prerequisite to accept this patch, although such documentation would be
> > desirable as a separate submission.
> What about (if OK, I'll resubmit in a different thread with proper format):
>
> ---
> Documentation/nmi_watchdog.txt | 5 +++++
> 1 file changed, 5 insertions(+)
>
> --- linus-2.6.orig/Documentation/nmi_watchdog.txt 2008-10-24 11:41:30.000000000 -0400
> +++ linus-2.6/Documentation/nmi_watchdog.txt 2008-10-29 16:38:12.000000000 -0400
> @@ -69,6 +69,11 @@ to the overall system performance.
> On x86 nmi_watchdog is disabled by default so you have to enable it with
> a boot time parameter.
>
> +It's possible to disable the NMI watchdog in run-time by writing "0" to
> +/proc/sys/kernel/nmi_watchdog. Writing "1" to the same file will re-enable
> +the NMI watchdog. Notice that you still need to use "nmi_watchdog=" parameter
> +in boot time.
> +
> NOTE: In kernels prior to 2.4.2-ac18 the NMI-oopser is enabled unconditionally
> on x86 SMP boxes.

OK. Or update Documentation/filesystems/proc.txt::nmi_watchdog
(now that I have found it).

---
~Randy