Commit 4a7863cc2eb5f9804f1c4e9156619a801cd7f14f

Authored by Don Zickus
Committed by Ingo Molnar
1 parent 9fb67204d7

x86, nmi_watchdog: Remove ARCH_HAS_NMI_WATCHDOG and rely on CONFIG_HARDLOCKUP_DETECTOR

The x86 arch has shifted its use of the nmi_watchdog from a
local implementation to the global one provide by
kernel/watchdog.c.  This shift has caused a whole bunch of
compile problems under different config options.  I attempt to
simplify things with the patch below.

In order to simplify things, I had to come to terms with the
meaning of two terms ARCH_HAS_NMI_WATCHDOG and
CONFIG_HARDLOCKUP_DETECTOR.  Basically they mean the same thing,
the former on a local level and the latter on a global level.

With the old x86 nmi watchdog gone, there is no need to rely on
defining the ARCH_HAS_NMI_WATCHDOG variable because it doesn't
make sense any more.  x86 will now use the global
implementation.

The changes below do a few things.  First it changes the few
places that relied on ARCH_HAS_NMI_WATCHDOG to use
CONFIG_X86_LOCAL_APIC (the former was an alias for the latter
anyway, so nothing unusual here).  Those pieces of code were
relying more on local apic functionality the nmi watchdog
functionality, so the change should make sense.

Second, I removed the x86 implementation of
touch_nmi_watchdog().  It isn't need now, instead x86 will rely
on kernel/watchdog.c's implementation.

Third, I removed the #define ARCH_HAS_NMI_WATCHDOG itself from
x86.  And tweaked the include/linux/nmi.h file to tell users to
look for an externally defined touch_nmi_watchdog in the case of
ARCH_HAS_NMI_WATCHDOG _or_ CONFIG_HARDLOCKUP_DETECTOR. This
changes removes some of the ugliness in that file.

Finally, I added a Kconfig dependency for
CONFIG_HARDLOCKUP_DETECTOR that said you can't have
ARCH_HAS_NMI_WATCHDOG _and_ CONFIG_HARDLOCKUP_DETECTOR.  You can
only have one nmi_watchdog.

Tested with
ARCH=i386: allnoconfig, defconfig, allyesconfig, (various broken
configs) ARCH=x86_64: allnoconfig, defconfig, allyesconfig,
(various broken configs)

Hopefully, after this patch I won't get any more compile broken
emails. :-)

v3:
  changed a couple of 'linux/nmi.h' -> 'asm/nmi.h' to pick-up correct function
  prototypes when CONFIG_HARDLOCKUP_DETECTOR is not set.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: fweisbec@gmail.com
LKML-Reference: <1293044403-14117-1-git-send-email-dzickus@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

Showing 8 changed files with 8 additions and 25 deletions Side-by-side Diff

arch/x86/include/asm/irq.h
... ... @@ -15,10 +15,6 @@
15 15 return ((irq == 2) ? 9 : irq);
16 16 }
17 17  
18   -#ifdef CONFIG_X86_LOCAL_APIC
19   -# define ARCH_HAS_NMI_WATCHDOG
20   -#endif
21   -
22 18 #ifdef CONFIG_X86_32
23 19 extern void irq_ctx_init(int cpu);
24 20 #else
arch/x86/include/asm/nmi.h
... ... @@ -5,7 +5,7 @@
5 5 #include <asm/irq.h>
6 6 #include <asm/io.h>
7 7  
8   -#ifdef ARCH_HAS_NMI_WATCHDOG
  8 +#ifdef CONFIG_X86_LOCAL_APIC
9 9  
10 10 extern void die_nmi(char *str, struct pt_regs *regs, int do_panic);
11 11 extern int avail_to_resrv_perfctr_nmi_bit(unsigned int);
arch/x86/kernel/apic/hw_nmi.c
... ... @@ -17,21 +17,11 @@
17 17 #include <linux/nmi.h>
18 18 #include <linux/module.h>
19 19  
20   -#ifdef ARCH_HAS_NMI_WATCHDOG
21 20 #ifdef CONFIG_HARDLOCKUP_DETECTOR
22 21 u64 hw_nmi_get_sample_period(void)
23 22 {
24 23 return (u64)(cpu_khz) * 1000 * 60;
25 24 }
26   -#endif
27   -
28   -#ifndef CONFIG_HARDLOCKUP_DETECTOR
29   -void touch_nmi_watchdog(void)
30   -{
31   - touch_softlockup_watchdog();
32   -}
33   -EXPORT_SYMBOL(touch_nmi_watchdog);
34   -#endif
35 25 #endif
36 26  
37 27 #ifdef arch_trigger_all_cpu_backtrace
arch/x86/kernel/cpu/perfctr-watchdog.c
... ... @@ -16,7 +16,7 @@
16 16 #include <linux/kernel.h>
17 17 #include <linux/bitops.h>
18 18 #include <linux/smp.h>
19   -#include <linux/nmi.h>
  19 +#include <asm/nmi.h>
20 20 #include <linux/kprobes.h>
21 21  
22 22 #include <asm/apic.h>
arch/x86/oprofile/op_model_p4.c
... ... @@ -11,7 +11,7 @@
11 11 #include <linux/oprofile.h>
12 12 #include <linux/smp.h>
13 13 #include <linux/ptrace.h>
14   -#include <linux/nmi.h>
  14 +#include <asm/nmi.h>
15 15 #include <asm/msr.h>
16 16 #include <asm/fixmap.h>
17 17 #include <asm/apic.h>
drivers/watchdog/hpwdt.c
... ... @@ -642,7 +642,7 @@
642 642 */
643 643  
644 644 #ifdef CONFIG_HPWDT_NMI_DECODING
645   -#ifdef ARCH_HAS_NMI_WATCHDOG
  645 +#ifdef CONFIG_X86_LOCAL_APIC
646 646 static void __devinit hpwdt_check_nmi_decoding(struct pci_dev *dev)
647 647 {
648 648 /*
... ... @@ -657,7 +657,7 @@
657 657 dev_warn(&dev->dev, "NMI decoding is disabled. "
658 658 "Your kernel does not support a NMI Watchdog.\n");
659 659 }
660   -#endif /* ARCH_HAS_NMI_WATCHDOG */
  660 +#endif /* CONFIG_X86_LOCAL_APIC */
661 661  
662 662 static int __devinit hpwdt_init_nmi_decoding(struct pci_dev *dev)
663 663 {
... ... @@ -14,18 +14,14 @@
14 14 * may be used to reset the timeout - for code which intentionally
15 15 * disables interrupts for a long time. This call is stateless.
16 16 */
17   -#ifdef ARCH_HAS_NMI_WATCHDOG
  17 +#if defined(ARCH_HAS_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
18 18 #include <asm/nmi.h>
19 19 extern void touch_nmi_watchdog(void);
20 20 #else
21   -#ifndef CONFIG_HARDLOCKUP_DETECTOR
22 21 static inline void touch_nmi_watchdog(void)
23 22 {
24 23 touch_softlockup_watchdog();
25 24 }
26   -#else
27   -extern void touch_nmi_watchdog(void);
28   -#endif
29 25 #endif
30 26  
31 27 /*
... ... @@ -173,7 +173,8 @@
173 173 An NMI is generated every 60 seconds or so to check for hardlockups.
174 174  
175 175 config HARDLOCKUP_DETECTOR
176   - def_bool LOCKUP_DETECTOR && PERF_EVENTS && HAVE_PERF_EVENTS_NMI
  176 + def_bool LOCKUP_DETECTOR && PERF_EVENTS && HAVE_PERF_EVENTS_NMI && \
  177 + !ARCH_HAS_NMI_WATCHDOG
177 178  
178 179 config BOOTPARAM_SOFTLOCKUP_PANIC
179 180 bool "Panic (Reboot) On Soft Lockups"