Gmane
Favicon
From: Ingo Molnar <mingo <at> elte.hu>
Subject: [patch] lock validator: clean up IRQ entry/exit
Newsgroups: gmane.linux.kernel
Date: 2006-06-22 08:15:10 GMT (3 years, 1 week, 5 days, 19 hours and 14 minutes ago)
Subject: lock validator: clean up IRQ entry/exit
From: Ingo Molnar <mingo <at> elte.hu>

preparation for the resurrection of handling NMIs under the lock 
validator:

- introduce __irq_exit() as a no-softirqs variant of IRQ exit
- make NMI exit use __irq_exit()
- make the locking API self-tests use irq_enter/__irq_exit.

Signed-off-by: Ingo Molnar <mingo <at> elte.hu>
---
 include/linux/hardirq.h |   23 ++++++++++++++++-------
 lib/locking-selftest.c  |    4 ++--
 2 files changed, 18 insertions(+), 9 deletions(-)

Index: linux/include/linux/hardirq.h
===================================================================
--- linux.orig/include/linux/hardirq.h
+++ linux/include/linux/hardirq.h
@@ -86,13 +86,6 @@ extern void synchronize_irq(unsigned int
 # define synchronize_irq(irq)	barrier()
 #endif

-#define nmi_enter()		irq_enter()
-#define nmi_exit()					\
-	do {						\
-		sub_preempt_count(HARDIRQ_OFFSET);	\
-		trace_hardirq_exit();			\
-	} while (0)
-
 struct task_struct;

 #ifndef CONFIG_VIRT_CPU_ACCOUNTING
@@ -114,6 +107,22 @@ static inline void account_system_vtime(
 		trace_hardirq_enter();			\
 	} while (0)

+/*
+ * Exit irq context without processing softirqs:
+ */
+#define __irq_exit()					\
+	do {						\
+		trace_hardirq_exit();			\
+		account_system_vtime(current);		\
+		sub_preempt_count(HARDIRQ_OFFSET);	\
+	} while (0)
+
+/*
+ * Exit irq context and process softirqs if needed:
+ */
 extern void irq_exit(void);

+#define nmi_enter()		irq_enter()
+#define nmi_exit()		__irq_exit()
+
 #endif /* LINUX_HARDIRQ_H */
Index: linux/lib/locking-selftest.c
===================================================================
--- linux.orig/lib/locking-selftest.c
+++ linux/lib/locking-selftest.c
@@ -144,11 +144,11 @@ static void init_shared_types(void)

 #define HARDIRQ_ENTER()				\
 	local_irq_disable();			\
-	nmi_enter();				\
+	irq_enter();				\
 	WARN_ON(!in_irq());

 #define HARDIRQ_EXIT()				\
-	nmi_exit();				\
+	__irq_exit();				\
 	local_irq_enable();

 #define SOFTIRQ_DISABLE		local_bh_disable