Skip to contentSkip to conversation

lock validator: reenable NMIs

PATCH New Ingo Molnar 1 participant 1 message Jun 22, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lock validator: reenable NMIs

Subject: lock validator: reenable NMIs
From: Ingo Molnar <[email protected]>

- not touch the irqtrace state in NMI handlers
- re-enable NMIs and oprofile on i386 and x86_64

i have tested this with high-rate (10 KHz per CPU) NMI load on the kernel, and while previously we'd quickly get the irqtrace state confused and a lock validator bug message, with this patch applied it's now working fine.

(note that on x86_64 we only build one variant of the paranoid-exit codepath if IRQTRACE is disabled - so there should be no difference in code generated, as long as the validator is disabled)

---
 arch/i386/kernel/nmi.c       |   10 ---
 arch/i386/oprofile/Kconfig   |    2 
 arch/x86_64/kernel/entry.S   |  133 ++++++++++++++++++++++++-------------------
 arch/x86_64/kernel/nmi.c     |   11 ---
 arch/x86_64/oprofile/Kconfig |    2 
 include/linux/hardirq.h      |    4 -
 kernel/lockdep.c             |   16 ++---
 7 files changed, 89 insertions(+), 89 deletions(-)
arch/i386/kernel/nmi.c +0 -10
Index: linux/arch/i386/kernel/nmi.c
===================================================================
@@ -747,16 +747,6 @@ void setup_apic_nmi_watchdog (void *unus
 {
 	struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
 
-#ifdef CONFIG_LOCKDEP
-	/*
-	 * The NMI watchdog uses spinlocks (notifier chains, etc.),
-	 * so it's not lockdep-safe:
-	 */
-	nmi_watchdog = NMI_NONE;
-	printk("lockdep: disabled NMI watchdog.\n");
-
-	return;
-#endif
 	/* only support LOCAL and IO APICs for now */
 	if ((nmi_watchdog != NMI_LOCAL_APIC) &&
 	    (nmi_watchdog != NMI_IO_APIC))
arch/i386/oprofile/Kconfig +1 -1
Index: linux/arch/i386/oprofile/Kconfig
===================================================================
@@ -7,7 +7,7 @@ config PROFILING
 
 config OPROFILE
 	tristate "OProfile system profiling (EXPERIMENTAL)"
-	depends on PROFILING && !LOCKDEP
+	depends on PROFILING
 	help
 	  OProfile is a profiling system capable of profiling the
 	  whole system, include the kernel, kernel modules, libraries,
arch/x86_64/kernel/entry.S +77 -56

183 lines not on this page · raw message

arch/x86_64/kernel/nmi.c +0 -11
Index: linux/arch/x86_64/kernel/nmi.c
===================================================================
@@ -674,17 +674,6 @@ void setup_apic_nmi_watchdog(void *unuse
 {
 	struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
 
-#ifdef CONFIG_LOCKDEP
-	/*
-	 * The NMI watchdog uses spinlocks (notifier chains, etc.),
-	 * so it's not lockdep-safe:
-	 */
-	nmi_watchdog = NMI_NONE;
-	printk("lockdep: disabled NMI watchdog.\n");
-
-	return;
-#endif
-
 	/* only support LOCAL and IO APICs for now */
 	if ((nmi_watchdog != NMI_LOCAL_APIC) &&
 	    (nmi_watchdog != NMI_IO_APIC))
arch/x86_64/oprofile/Kconfig +1 -1
Index: linux/arch/x86_64/oprofile/Kconfig
===================================================================
@@ -7,7 +7,7 @@ config PROFILING
 
 config OPROFILE
 	tristate "OProfile system profiling (EXPERIMENTAL)"
-	depends on PROFILING && !LOCKDEP
+	depends on PROFILING
 	help
 	  OProfile is a profiling system capable of profiling the
 	  whole system, include the kernel, kernel modules, libraries,
include/linux/hardirq.h +2 -2
Index: linux/include/linux/hardirq.h
===================================================================
@@ -122,7 +122,7 @@ static inline void account_system_vtime(
  */
 extern void irq_exit(void);
 
-#define nmi_enter()		irq_enter()
-#define nmi_exit()		__irq_exit()
+#define nmi_enter()		do { lockdep_off(); irq_enter(); } while (0)
+#define nmi_exit()		do { __irq_exit(); lockdep_on(); } while (0)
 
 #endif /* LINUX_HARDIRQ_H */
kernel/lockdep.c +8 -8
Index: linux/kernel/lockdep.c
===================================================================
@@ -1869,7 +1869,7 @@ void trace_hardirqs_on(void)
 	struct task_struct *curr = current;
 	unsigned long ip;
 
-	if (unlikely(!debug_locks))
+	if (unlikely(!debug_locks || current->lockdep_recursion))
 		return;
 
 	if (DEBUG_WARN_ON(unlikely(!early_boot_irqs_enabled)))
@@ -1916,7 +1916,7 @@ void trace_hardirqs_off(void)
 {
 	struct task_struct *curr = current;
 
-	if (unlikely(!debug_locks))
+	if (unlikely(!debug_locks || current->lockdep_recursion))
 		return;
 
 	if (DEBUG_WARN_ON(!irqs_disabled()))
@@ -2488,16 +2488,16 @@ void lock_acquire(struct lockdep_map *lo
 {
 	unsigned long flags;
 
+	if (unlikely(current->lockdep_recursion))
+		return;
+
 	raw_local_irq_save(flags);
 	check_flags(flags);
 
-	if (unlikely(current->lockdep_recursion))
-		goto out;
 	current->lockdep_recursion = 1;
 	__lock_acquire(lock, subtype, trylock, read, check,
 		       irqs_disabled_flags(flags), ip);
 	current->lockdep_recursion = 0;
-out:
 	raw_local_irq_restore(flags);
 }
 
@@ -2507,14 +2507,14 @@ void lock_release(struct lockdep_map *lo
 {
 	unsigned long flags;
 
+	if (unlikely(current->lockdep_recursion))
+		return;
+
 	raw_local_irq_save(flags);
 	check_flags(flags);
-	if (unlikely(current->lockdep_recursion))
-		goto out;
 	current->lockdep_recursion = 1;
 	__lock_release(lock, nested, ip);
 	current->lockdep_recursion = 0;
-out:
 	raw_local_irq_restore(flags);
 }