Skip to contentSkip to conversation

x86, nmi_watchdog: Remove ARCH_HAS_NMI_WATCHDOG and rely on CONFIG_HARDLOCKUP_DETECTOR

PATCH Superseded Don Zickus 2 participants 4 messages Dec 17, 2010 – Dec 22, 2010

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Don Zickus

author
#0 lore raw

PATCH 1/1 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. :-)

---
 arch/x86/include/asm/irq.h    |    4 ----
 arch/x86/include/asm/nmi.h    |    2 +-
 arch/x86/kernel/apic/hw_nmi.c |   10 ----------
 drivers/watchdog/hpwdt.c      |    4 ++--
 include/linux/nmi.h           |    6 +-----
 lib/Kconfig.debug             |    3 ++-
 6 files changed, 6 insertions(+), 23 deletions(-)
arch/x86/include/asm/irq.h +0 -4
index 13b0eba..ba870bb 100644
@@ -15,10 +15,6 @@ static inline int irq_canonicalize(int irq)
 	return ((irq == 2) ? 9 : irq);
 }
 
-#ifdef CONFIG_X86_LOCAL_APIC
-# define ARCH_HAS_NMI_WATCHDOG
-#endif
-
 #ifdef CONFIG_X86_32
 extern void irq_ctx_init(int cpu);
 #else
arch/x86/include/asm/nmi.h +1 -1
index 3545838..c4021b9 100644
@@ -5,7 +5,7 @@
 #include <asm/irq.h>
 #include <asm/io.h>
 
-#ifdef ARCH_HAS_NMI_WATCHDOG
+#ifdef CONFIG_X86_LOCAL_APIC
 
 extern void die_nmi(char *str, struct pt_regs *regs, int do_panic);
 extern int avail_to_resrv_perfctr_nmi_bit(unsigned int);
arch/x86/kernel/apic/hw_nmi.c +0 -10
index a4fa849..c57d0b5 100644
@@ -24,16 +24,6 @@ u64 hw_nmi_get_sample_period(void)
 }
 #endif
 
-#ifdef ARCH_HAS_NMI_WATCHDOG
-#ifndef CONFIG_HARDLOCKUP_DETECTOR
-void touch_nmi_watchdog(void)
-{
-	touch_softlockup_watchdog();
-}
-EXPORT_SYMBOL(touch_nmi_watchdog);
-#endif
-#endif
-
 #ifdef arch_trigger_all_cpu_backtrace
 /* For reliability, we're prepared to waste bits here. */
 static DECLARE_BITMAP(backtrace_mask, NR_CPUS) __read_mostly;
drivers/watchdog/hpwdt.c +2 -2
index c19f4a2..dea7b5b 100644
@@ -642,7 +642,7 @@ static struct notifier_block die_notifier = {
  */
 
 #ifdef CONFIG_HPWDT_NMI_DECODING
-#ifdef ARCH_HAS_NMI_WATCHDOG
+#ifdef CONFIG_X86_LOCAL_APIC
 static void __devinit hpwdt_check_nmi_decoding(struct pci_dev *dev)
 {
 	/*
@@ -657,7 +657,7 @@ static void __devinit hpwdt_check_nmi_decoding(struct pci_dev *dev)
 	dev_warn(&dev->dev, "NMI decoding is disabled. "
 		"Your kernel does not support a NMI Watchdog.\n");
 }
-#endif /* ARCH_HAS_NMI_WATCHDOG */
+#endif /* CONFIG_X86_LOCAL_APIC */
 
 static int __devinit hpwdt_init_nmi_decoding(struct pci_dev *dev)
 {
include/linux/nmi.h +1 -5
index 17ccf44..c536f85 100644
@@ -14,18 +14,14 @@
  * may be used to reset the timeout - for code which intentionally
  * disables interrupts for a long time. This call is stateless.
  */
-#ifdef ARCH_HAS_NMI_WATCHDOG
+#if defined(ARCH_HAS_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
 #include <asm/nmi.h>
 extern void touch_nmi_watchdog(void);
 #else
-#ifndef CONFIG_HARDLOCKUP_DETECTOR
 static inline void touch_nmi_watchdog(void)
 {
 	touch_softlockup_watchdog();
 }
-#else
-extern void touch_nmi_watchdog(void);
-#endif
 #endif
 
 /*
lib/Kconfig.debug +2 -1
index 28b42b9..2d05adb 100644
@@ -173,7 +173,8 @@ config LOCKUP_DETECTOR
 	  An NMI is generated every 60 seconds or so to check for hardlockups.
 
 config HARDLOCKUP_DETECTOR
-	def_bool LOCKUP_DETECTOR && PERF_EVENTS && HAVE_PERF_EVENTS_NMI
+	def_bool LOCKUP_DETECTOR && PERF_EVENTS && HAVE_PERF_EVENTS_NMI && \
+		 !ARCH_HAS_NMI_WATCHDOG
 
 config BOOTPARAM_SOFTLOCKUP_PANIC
 	bool "Panic (Reboot) On Soft Lockups"
Signature · 1 line
1.7.3.2
#1 lore raw
Quoted 4 lines · Don Zickus

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.

ok, this patch is looking better - but even after applying it to -tip (and resolving the conflict) i get this link failure on 64-bit allyesconfig:

watchdog.c:(.text+0x7eacc): undefined reference to `hw_nmi_get_sample_period'

Thanks,

Ingo

author
#2 lore raw
Quoted 10 lines · Ingo Molnar
Quoted 4 lines · Don Zickus

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.

ok, this patch is looking better - but even after applying it to -tip (and resolving the conflict) i get this link failure on 64-bit allyesconfig:

Sorry about the conflict. I guess I stupidly based the patch ontop of the small hack patch I sent to you a couple of hours before I sent this patch.

Quoted 2 lines

watchdog.c:(.text+0x7eacc): undefined reference to `hw_nmi_get_sample_period'

That said, I'm not sure how you resolved the conflict, but the define ARCH_HAS_NMI_WATCHDOG should not be in the arch/x86/kernel/apic/hw_nmi.c file.

Other than that, I am unable to reproduce the error you are seeing. Looking at the code, 'hw_nmi_get_sample_period' is defined in one file and called in one spot in another file. Both cases that code is wrapped only with CONFIG_HARDLOCKUP_DETECTOR, so I at a loss on where it would fail.

Do you have a branch I can look at it, just to double check?

Cheers,
Don

#3 lore raw
Quoted 22 lines · Don Zickus
Quoted 10 lines · Ingo Molnar
Quoted 4 lines · Don Zickus

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.

ok, this patch is looking better - but even after applying it to -tip (and resolving the conflict) i get this link failure on 64-bit allyesconfig:

Sorry about the conflict. I guess I stupidly based the patch ontop of the small hack patch I sent to you a couple of hours before I sent this patch.

Quoted 2 lines

watchdog.c:(.text+0x7eacc): undefined reference to `hw_nmi_get_sample_period'

That said, I'm not sure how you resolved the conflict, but the define ARCH_HAS_NMI_WATCHDOG should not be in the arch/x86/kernel/apic/hw_nmi.c file.

Quoted 6 lines

Other than that, I am unable to reproduce the error you are seeing. Looking at the code, 'hw_nmi_get_sample_period' is defined in one file and called in one spot in another file. Both cases that code is wrapped only with CONFIG_HARDLOCKUP_DETECTOR, so I at a loss on where it would fail.

Do you have a branch I can look at it, just to double check?

Not anymore - could you please send a patch that applies cleanly to -tip - that way we eliminate all misinterpretation.

Thanks,

Ingo