Skip to contentSkip to conversation

IOAPIC NMI watchdog fixes

PATCH In review Aristeu Rozanski 4 participants 11 messages Oct 27, 2008 – Dec 16, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover IOAPIC NMI watchdog fixes

These two patches make use of __acpi_nmi_disable() to make possible to:
- enable and disable IOAPIC NMI watchdog using procfs
- disable NMI generation if the NMI watchdog is not working on boot time

Signature · 1 line
Aristeu
#1 lore raw

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.

---
 arch/x86/kernel/nmi.c |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
arch/x86/kernel/nmi.c +25 -0
@@ -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");
Signature · 1 line
Aristeu
#2 lore raw

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

Quoted 2 lines · 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.

Quoted 56 lines
---
 arch/x86/kernel/nmi.c |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
arch/x86/kernel/nmi.c +25 -0
@@ -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");
Signature · 1 line
-- 

---
~Randy

#3 lore raw

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

Quoted 5 lines · Randy Dunlap
Quoted 2 lines

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

#4 lore raw

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

Quoted 11 lines
Quoted 5 lines
Quoted 2 lines

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(+)
Documentation/nmi_watchdog.txt +5 -0
@@ -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.
 
#5 lore raw

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

Quoted 20 lines · On Wed, 29 Oct 2008 16:39:19 -0400 Aristeu Rozanski wrote:
Quoted 11 lines
Quoted 5 lines
Quoted 2 lines

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(+)

Documentation/nmi_watchdog.txt to the overall system performance. · line 78

Quoted 10 lines
Documentation/nmi_watchdog.txt +5 -0
@@ -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

#6 lore raw

PATCH 2/2 NMI watchdog: disable NMIs on LVT0 in case NMI watchdog is not working

In reply to Aristeu Rozanski

Currently, if the NMI watchdog fails using IOAPIC method, it'll only disable interrupts on 8259 if the timer is passing thru it. This patch disables NMI delivery on LINT0 if the NMI watchdog initial test fails, just for safety.

---
 arch/x86/kernel/nmi.c |   18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
arch/x86/kernel/nmi.c +11 -7
@@ -131,6 +131,11 @@ static void report_broken_nmi(int cpu, i
 	atomic_dec(&nmi_active);
 }
 
+static void __acpi_nmi_disable(void *__unused)
+{
+	apic_write(APIC_LVT0, APIC_DM_NMI | APIC_LVT_MASKED);
+}
+
 int __init check_nmi_watchdog(void)
 {
 	unsigned int *prev_nmi_count;
@@ -179,8 +184,12 @@ int __init check_nmi_watchdog(void)
 	kfree(prev_nmi_count);
 	return 0;
 error:
-	if (nmi_watchdog == NMI_IO_APIC && !timer_through_8259)
-		disable_8259A_irq(0);
+	if (nmi_watchdog == NMI_IO_APIC) {
+		if (!timer_through_8259)
+			disable_8259A_irq(0);
+		on_each_cpu(__acpi_nmi_disable, NULL, 1);
+	}
+
 #ifdef CONFIG_X86_32
 	timer_ack = 0;
 #endif
@@ -285,11 +294,6 @@ void acpi_nmi_enable(void)
 		on_each_cpu(__acpi_nmi_enable, NULL, 1);
 }
 
-static void __acpi_nmi_disable(void *__unused)
-{
-	apic_write(APIC_LVT0, APIC_DM_NMI | APIC_LVT_MASKED);
-}
-
 /*
  * Disable timer based NMIs on all CPUs:
  */
Signature · 1 line
Aristeu
#7 lore raw
In reply to Aristeu Rozanski
Quoted 3 lines · Aristeu Rozanski

These two patches make use of __acpi_nmi_disable() to make possible to:
- enable and disable IOAPIC NMI watchdog using procfs
- disable NMI generation if the NMI watchdog is not working on boot time

Thanks, I'll see if I can find some time soon to give them a hit -- I've
got a serial console on my laptop now, :) so any odd boot-time tests will be easier for me. These would be best tested with Ingo's APIC tree, a current snapshot of which I may not have handy. Ping me if I don't respond within a few days.

Maciej

#8 lore raw
Quoted 11 lines · Maciej W. Rozycki
Quoted 3 lines · Aristeu Rozanski

These two patches make use of __acpi_nmi_disable() to make possible to:
- enable and disable IOAPIC NMI watchdog using procfs
- disable NMI generation if the NMI watchdog is not working on boot time

Thanks, I'll see if I can find some time soon to give them a hit --
I've got a serial console on my laptop now, :) so any odd boot-time tests will be easier for me. These would be best tested with Ingo's APIC tree, a current snapshot of which I may not have handy. Ping me if I don't respond within a few days.

okay - they look reasonable so i've applied Aristeu's patches to tip/x86/apic and integrated them into tip/master, we'll see how they work out.

Please Ack/Nak them once you have the time to have a close look.

Ingo

#9 lore raw
In reply to Maciej W. Rozycki
Quoted 9 lines
Quoted 3 lines

These two patches make use of __acpi_nmi_disable() to make possible to:
- enable and disable IOAPIC NMI watchdog using procfs
- disable NMI generation if the NMI watchdog is not working on boot time

Thanks, I'll see if I can find some time soon to give them a hit -- I've
got a serial console on my laptop now, :) so any odd boot-time tests will be easier for me. These would be best tested with Ingo's APIC tree, a current snapshot of which I may not have handy. Ping me if I don't respond within a few days.

ping :)

Signature · 1 line
Aristeu
#10 lore raw
Quoted 6 lines · Aristeu Rozanski
Quoted 5 lines

Thanks, I'll see if I can find some time soon to give them a hit -- I've
got a serial console on my laptop now, :) so any odd boot-time tests will be easier for me. These would be best tested with Ingo's APIC tree, a current snapshot of which I may not have handy. Ping me if I don't respond within a few days.

ping :)

Pong. Recent weeks have been rather hectic for me. I'll see if I can
find an hour or so over the Christmas period. The thing is to test 2/2 properly I need to tweak the sources to pretend the IRQ routing tables on my system are different than they really are and it takes a short while. We shall see. Thanks for your patience. :)

Maciej