public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix to keep watchdog disabled by default for i386/x86_64
@ 2007-08-10 22:29 Daniel Gollub
  2007-08-10 23:32 ` Andi Kleen
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Gollub @ 2007-08-10 22:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andi Kleen

Fixed wrong expression which enabled watchdogs even if nmi_watchdog kernel 
parameter wasn't set. This regression got slightly introduced with commit 
b7471c6da94d30d3deadc55986cc38d1ff57f9ca.

Introduced NMI_DISABLED (-1) which allows to switch the value of NMI_DEFAULT 
without breaking the APIC NMI watchdog code (again).

Fixes:
https://bugzilla.novell.com/show_bug.cgi?id=298084
http://bugzilla.kernel.org/show_bug.cgi?id=7839
And likely some more nmi_watchdog=0 related issues.

Signed-off-by: Daniel Gollub <dgollub@suse.de>
---
diff -rup a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
--- a/arch/i386/kernel/apic.c	2007-08-04 04:49:55.000000000 +0200
+++ b/arch/i386/kernel/apic.c	2007-08-10 21:38:37.000000000 +0200
@@ -1087,7 +1087,7 @@ static int __init detect_init_APIC (void
 	if (l & MSR_IA32_APICBASE_ENABLE)
 		mp_lapic_addr = l & MSR_IA32_APICBASE_BASE;
 
-	if (nmi_watchdog != NMI_NONE)
+	if (nmi_watchdog != NMI_NONE && nmi_watchdog != NMI_DISABLED)
 		nmi_watchdog = NMI_LOCAL_APIC;
 
 	printk(KERN_INFO "Found and enabled local APIC!\n");
diff -rup a/arch/i386/kernel/nmi.c b/arch/i386/kernel/nmi.c
--- a/arch/i386/kernel/nmi.c	2007-08-04 04:49:55.000000000 +0200
+++ b/arch/i386/kernel/nmi.c	2007-08-10 22:00:40.000000000 +0200
@@ -77,7 +77,7 @@ static int __init check_nmi_watchdog(voi
 	unsigned int *prev_nmi_count;
 	int cpu;
 
-	if ((nmi_watchdog == NMI_NONE) || (nmi_watchdog == NMI_DEFAULT))
+	if ((nmi_watchdog == NMI_NONE) || (nmi_watchdog == NMI_DISABLED))
 		return 0;
 
 	if (!atomic_read(&nmi_active))
@@ -424,7 +424,7 @@ int proc_nmi_enabled(struct ctl_table *t
 	if (!!old_state == !!nmi_watchdog_enabled)
 		return 0;
 
-	if (atomic_read(&nmi_active) < 0) {
+	if (atomic_read(&nmi_active) < 0 || nmi_watchdog == NMI_DISABLED) {
 		printk( KERN_WARNING "NMI watchdog is permanently disabled\n");
 		return -EIO;
 	}
diff -rup a/arch/x86_64/kernel/nmi.c b/arch/x86_64/kernel/nmi.c
--- a/arch/x86_64/kernel/nmi.c	2007-08-04 04:49:55.000000000 +0200
+++ b/arch/x86_64/kernel/nmi.c	2007-08-10 21:59:36.000000000 +0200
@@ -85,7 +85,7 @@ int __init check_nmi_watchdog (void)
 	int *counts;
 	int cpu;
 
-	if ((nmi_watchdog == NMI_NONE) || (nmi_watchdog == NMI_DEFAULT))
+	if ((nmi_watchdog == NMI_NONE) || (nmi_watchdog == NMI_DISABLED)) 
 		return 0;
 
 	if (!atomic_read(&nmi_active))
@@ -442,7 +442,7 @@ int proc_nmi_enabled(struct ctl_table *t
 	if (!!old_state == !!nmi_watchdog_enabled)
 		return 0;
 
-	if (atomic_read(&nmi_active) < 0) {
+	if (atomic_read(&nmi_active) < 0 || nmi_watchdog == NMI_DISABLED) {
 		printk( KERN_WARNING "NMI watchdog is permanently disabled\n");
 		return -EIO;
 	}
diff -rup a/include/asm-i386/nmi.h b/include/asm-i386/nmi.h
--- a/include/asm-i386/nmi.h	2007-08-04 04:49:55.000000000 +0200
+++ b/include/asm-i386/nmi.h	2007-08-10 22:04:51.000000000 +0200
@@ -33,11 +33,12 @@ extern int nmi_watchdog_tick (struct pt_
 
 extern atomic_t nmi_active;
 extern unsigned int nmi_watchdog;
-#define NMI_DEFAULT     -1
+#define NMI_DISABLED    -1
 #define NMI_NONE	0
 #define NMI_IO_APIC	1
 #define NMI_LOCAL_APIC	2
 #define NMI_INVALID	3
+#define NMI_DEFAULT	NMI_DISABLED
 
 struct ctl_table;
 struct file;
diff -rup a/include/asm-x86_64/nmi.h b/include/asm-x86_64/nmi.h
--- a/include/asm-x86_64/nmi.h	2007-08-04 04:49:55.000000000 +0200
+++ b/include/asm-x86_64/nmi.h	2007-08-10 22:04:41.000000000 +0200
@@ -64,11 +64,12 @@ extern int setup_nmi_watchdog(char *);
 
 extern atomic_t nmi_active;
 extern unsigned int nmi_watchdog;
-#define NMI_DEFAULT	-1
+#define NMI_DISABLED    -1
 #define NMI_NONE	0
 #define NMI_IO_APIC	1
 #define NMI_LOCAL_APIC	2
 #define NMI_INVALID	3
+#deifne NMI_DEFAULT	NMI_DISABLED
 
 struct ctl_table;
 struct file;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix to keep watchdog disabled by default for i386/x86_64
  2007-08-10 22:29 [PATCH] Fix to keep watchdog disabled by default for i386/x86_64 Daniel Gollub
@ 2007-08-10 23:32 ` Andi Kleen
  2007-08-11  0:25   ` [PATCHv2] " Daniel Gollub
  0 siblings, 1 reply; 3+ messages in thread
From: Andi Kleen @ 2007-08-10 23:32 UTC (permalink / raw)
  To: Daniel Gollub; +Cc: linux-kernel


> +#deifne NMI_DEFAULT	NMI_DISABLED

Actually tested?

-Andi

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCHv2] Fix to keep watchdog disabled by default for i386/x86_64
  2007-08-10 23:32 ` Andi Kleen
@ 2007-08-11  0:25   ` Daniel Gollub
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Gollub @ 2007-08-11  0:25 UTC (permalink / raw)
  To: Andi Kleen; +Cc: linux-kernel

Fixed wrong expression which enabled watchdogs even if nmi_watchdog kernel 
parameter wasn't set. This regression got slightly introduced with commit 
b7471c6da94d30d3deadc55986cc38d1ff57f9ca.

Introduced NMI_DISABLED (-1) which allows to switch the value of NMI_DEFAULT 
without breaking the APIC NMI watchdog code (again).

Fixes:
https://bugzilla.novell.com/show_bug.cgi?id=298084
http://bugzilla.kernel.org/show_bug.cgi?id=7839
And likely some more nmi_watchdog=0 related issues.

Resubmit: x86_64 changes compiled but untested. Shame on me!

Signed-off-by: Daniel Gollub <dgollub@suse.de>
---
 arch/i386/kernel/apic.c  |    2 +-
 arch/i386/kernel/nmi.c   |    4 ++--
 arch/x86_64/kernel/nmi.c |    4 ++--
 include/asm-i386/nmi.h   |    3 ++-
 include/asm-x86_64/nmi.h |    3 ++-
 5 files changed, 9 insertions(+), 7 deletions(-)

diff -rup a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
--- a/arch/i386/kernel/apic.c	2007-08-04 04:49:55.000000000 +0200
+++ b/arch/i386/kernel/apic.c	2007-08-10 21:38:37.000000000 +0200
@@ -1087,7 +1087,7 @@ static int __init detect_init_APIC (void
 	if (l & MSR_IA32_APICBASE_ENABLE)
 		mp_lapic_addr = l & MSR_IA32_APICBASE_BASE;
 
-	if (nmi_watchdog != NMI_NONE)
+	if (nmi_watchdog != NMI_NONE && nmi_watchdog != NMI_DISABLED)
 		nmi_watchdog = NMI_LOCAL_APIC;
 
 	printk(KERN_INFO "Found and enabled local APIC!\n");
diff -rup a/arch/i386/kernel/nmi.c b/arch/i386/kernel/nmi.c
--- a/arch/i386/kernel/nmi.c	2007-08-04 04:49:55.000000000 +0200
+++ b/arch/i386/kernel/nmi.c	2007-08-10 22:00:40.000000000 +0200
@@ -77,7 +77,7 @@ static int __init check_nmi_watchdog(voi
 	unsigned int *prev_nmi_count;
 	int cpu;
 
-	if ((nmi_watchdog == NMI_NONE) || (nmi_watchdog == NMI_DEFAULT))
+	if ((nmi_watchdog == NMI_NONE) || (nmi_watchdog == NMI_DISABLED))
 		return 0;
 
 	if (!atomic_read(&nmi_active))
@@ -424,7 +424,7 @@ int proc_nmi_enabled(struct ctl_table *t
 	if (!!old_state == !!nmi_watchdog_enabled)
 		return 0;
 
-	if (atomic_read(&nmi_active) < 0) {
+	if (atomic_read(&nmi_active) < 0 || nmi_watchdog == NMI_DISABLED) {
 		printk( KERN_WARNING "NMI watchdog is permanently disabled\n");
 		return -EIO;
 	}
diff -rup a/arch/x86_64/kernel/nmi.c b/arch/x86_64/kernel/nmi.c
--- a/arch/x86_64/kernel/nmi.c	2007-08-04 04:49:55.000000000 +0200
+++ b/arch/x86_64/kernel/nmi.c	2007-08-10 21:59:36.000000000 +0200
@@ -85,7 +85,7 @@ int __init check_nmi_watchdog (void)
 	int *counts;
 	int cpu;
 
-	if ((nmi_watchdog == NMI_NONE) || (nmi_watchdog == NMI_DEFAULT))
+	if ((nmi_watchdog == NMI_NONE) || (nmi_watchdog == NMI_DISABLED)) 
 		return 0;
 
 	if (!atomic_read(&nmi_active))
@@ -442,7 +442,7 @@ int proc_nmi_enabled(struct ctl_table *t
 	if (!!old_state == !!nmi_watchdog_enabled)
 		return 0;
 
-	if (atomic_read(&nmi_active) < 0) {
+	if (atomic_read(&nmi_active) < 0 || nmi_watchdog == NMI_DISABLED) {
 		printk( KERN_WARNING "NMI watchdog is permanently disabled\n");
 		return -EIO;
 	}
diff -rup a/include/asm-i386/nmi.h b/include/asm-i386/nmi.h
--- a/include/asm-i386/nmi.h	2007-08-04 04:49:55.000000000 +0200
+++ b/include/asm-i386/nmi.h	2007-08-10 22:04:51.000000000 +0200
@@ -33,11 +33,12 @@ extern int nmi_watchdog_tick (struct pt_
 
 extern atomic_t nmi_active;
 extern unsigned int nmi_watchdog;
-#define NMI_DEFAULT     -1
+#define NMI_DISABLED    -1
 #define NMI_NONE	0
 #define NMI_IO_APIC	1
 #define NMI_LOCAL_APIC	2
 #define NMI_INVALID	3
+#define NMI_DEFAULT	NMI_DISABLED
 
 struct ctl_table;
 struct file;
diff -rup a/include/asm-x86_64/nmi.h b/include/asm-x86_64/nmi.h
--- a/include/asm-x86_64/nmi.h	2007-08-04 04:49:55.000000000 +0200
+++ b/include/asm-x86_64/nmi.h	2007-08-10 22:04:41.000000000 +0200
@@ -64,11 +64,12 @@ extern int setup_nmi_watchdog(char *);
 
 extern atomic_t nmi_active;
 extern unsigned int nmi_watchdog;
-#define NMI_DEFAULT	-1
+#define NMI_DISABLED    -1
 #define NMI_NONE	0
 #define NMI_IO_APIC	1
 #define NMI_LOCAL_APIC	2
 #define NMI_INVALID	3
+#define NMI_DEFAULT	NMI_DISABLED
 
 struct ctl_table;
 struct file;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-08-11  0:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-10 22:29 [PATCH] Fix to keep watchdog disabled by default for i386/x86_64 Daniel Gollub
2007-08-10 23:32 ` Andi Kleen
2007-08-11  0:25   ` [PATCHv2] " Daniel Gollub

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox