All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Don't sleep in oops_begin()
@ 2007-09-17 18:12 Andi Kleen
  2007-09-17 18:28 ` Daniel Walker
  0 siblings, 1 reply; 13+ messages in thread
From: Andi Kleen @ 2007-09-17 18:12 UTC (permalink / raw)
  To: mingo, Thomas Gleixner; +Cc: linux-rt-users

When the kernel is oopsing no realtime guarantees are needed anymore and sleeping
here is unsafe; e.g. in case the crash site had interrupts disabled.

- Convert die_lock to a raw spinlock
- Really disable interrupts

Signed-off-by: Andi Kleen <ak@suse.de>

Index: linux-2.6.23-rc4-rt1/arch/x86_64/kernel/traps.c
===================================================================
--- linux-2.6.23-rc4-rt1.orig/arch/x86_64/kernel/traps.c
+++ linux-2.6.23-rc4-rt1/arch/x86_64/kernel/traps.c
@@ -467,7 +467,7 @@ void out_of_line_bug(void)
 EXPORT_SYMBOL(out_of_line_bug);
 #endif
 
-static DEFINE_SPINLOCK(die_lock);
+static __raw_spinlock_t die_lock = __RAW_SPIN_LOCK_UNLOCKED;
 static int die_owner = -1;
 static unsigned int die_nest_count;
 
@@ -479,13 +479,13 @@ unsigned __kprobes long oops_begin(void)
 	oops_enter();
 
 	/* racy, but better than risking deadlock. */
-	local_irq_save(flags);
+	raw_local_irq_save(flags);
 	cpu = smp_processor_id();
-	if (!spin_trylock(&die_lock)) { 
+	if (!__raw_spin_trylock(&die_lock)) { 
 		if (cpu == die_owner) 
 			/* nested oops. should stop eventually */;
 		else
-			spin_lock(&die_lock);
+			__raw_spin_lock(&die_lock);
 	}
 	die_nest_count++;
 	die_owner = cpu;
@@ -499,12 +499,10 @@ void __kprobes oops_end(unsigned long fl
 	die_owner = -1;
 	bust_spinlocks(0);
 	die_nest_count--;
-	if (die_nest_count)
-		/* We still own the lock */
-		local_irq_restore(flags);
-	else
+	if (!die_nest_count)
 		/* Nest count reaches zero, release the lock. */
-		spin_unlock_irqrestore(&die_lock, flags);
+		__raw_spin_unlock(&die_lock);
+	raw_local_irq_restore(flags);
 	if (panic_on_oops)
 		panic("Fatal exception");
 	oops_exit();

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2007-09-18  8:30 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-17 18:12 [PATCH] Don't sleep in oops_begin() Andi Kleen
2007-09-17 18:28 ` Daniel Walker
2007-09-17 18:46   ` Andi Kleen
2007-09-17 18:54     ` Daniel Walker
2007-09-17 19:00       ` Andi Kleen
2007-09-17 19:07         ` Daniel Walker
2007-09-17 19:38           ` Sven-Thorsten Dietrich
2007-09-17 20:20             ` Andi Kleen
2007-09-17 20:30               ` Sven-Thorsten Dietrich
2007-09-18  0:10               ` Daniel Walker
2007-09-18  8:05                 ` Andi Kleen
2007-09-18  8:30                   ` Thomas Gleixner
2007-09-17 23:13             ` Gregory Haskins

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.