2007-06-07 11:07:41

by Satyam Sharma

[permalink] [raw]
Subject: [PATCH] i386/x86_64: NMI watchdog: Protect smp_call_function() within CONFIG_SMP and some trivialities

a. arch/i386/kernel/nmi.c:check_nmi_watchdog() calls
smp_call_function() unconditionally. Protect it inside
a #ifdef CONFIG_SMP, as it is meaningless for UP, also
making i386's version similar to x86_64's.
b. Also update the filename in the comment on top of
arch/{i386, x86_64}/kernel/nmi.c, while we're editing
these files.

BTW: smp_call_function() simply returns 0 and
smp_call_function_single() simply returns -EBUSY when !SMP.
These appear to be just some ad hoc values. IMHO, we should
be going BUG() in both these cases because "other" CPUs for
!SMP are undefined / meaningless. [ Copying Alan Cox. ]

Signed-off-by: Satyam Sharma <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Alan Cox <[email protected]>

---

arch/i386/kernel/nmi.c | 4 +++-
arch/x86_64/kernel/nmi.c | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)

---

diff -ruNp a/arch/i386/kernel/nmi.c b/arch/i386/kernel/nmi.c
--- a/arch/i386/kernel/nmi.c 2007-06-07 12:46:34.000000000 +0530
+++ b/arch/i386/kernel/nmi.c 2007-06-07 15:43:52.000000000 +0530
@@ -1,5 +1,5 @@
/*
- * linux/arch/i386/nmi.c
+ * linux/arch/i386/kernel/nmi.c
*
* NMI watchdog support on APIC systems
*
@@ -89,8 +89,10 @@ static int __init check_nmi_watchdog(voi

printk(KERN_INFO "Testing NMI watchdog ... ");

+#ifdef CONFIG_SMP
if (nmi_watchdog == NMI_LOCAL_APIC)
smp_call_function(nmi_cpu_busy, (void *)&endflag, 0, 0);
+#endif

for_each_possible_cpu(cpu)
prev_nmi_count[cpu] = per_cpu(irq_stat, cpu).__nmi_count;
diff -ruNp a/arch/x86_64/kernel/nmi.c b/arch/x86_64/kernel/nmi.c
--- a/arch/x86_64/kernel/nmi.c 2007-06-07 12:46:39.000000000 +0530
+++ b/arch/x86_64/kernel/nmi.c 2007-06-07 15:43:13.000000000 +0530
@@ -1,5 +1,5 @@
/*
- * linux/arch/x86_64/nmi.c
+ * linux/arch/x86_64/kernel/nmi.c
*
* NMI watchdog support on APIC systems
*