Skip to contentSkip to conversation

spinlock: frob debug bits

RFC PATCH New Peter Zijlstra 1 participant 1 message Sep 2, 2011 Library code

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 spinlock: frob debug bits

Not sure this is actually worth it, but since I wrote it I thought I might as well send it out. Didn't actually need it. Once I frobbed the printk stuff to work again there were plenty error to point out what gone wrong.

---
Subject: spinlock: frob debug bits
From: Peter Zijlstra <[email protected]>
Date: Fri Sep 02 14:29:30 CEST 2011

gets more debug on a spinlock lockup, but also destroys all lock debugging.. you win some, you loose some..

---
 lib/spinlock_debug.c |   19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
lib/spinlock_debug.c +7 -12
Index: linux-2.6/lib/spinlock_debug.c
===================================================================
@@ -54,7 +54,7 @@ static void spin_bug(raw_spinlock_t *loc
 {
 	struct task_struct *owner = NULL;
 
-	if (!debug_locks_off())
+	if (unlikely(!debug_locks))
 		return;
 
 	if (lock->owner && lock->owner != SPINLOCK_OWNER_INIT)
@@ -69,6 +69,11 @@ static void spin_bug(raw_spinlock_t *loc
 		owner ? task_pid_nr(owner) : -1,
 		lock->owner_cpu);
 	dump_stack();
+	debug_show_all_locks();
+#ifdef CONFIG_SMP
+	trigger_all_cpu_backtrace();
+#endif
+	debug_locks_off();
 }
 
 #define SPIN_BUG_ON(cond, lock, msg) if (unlikely(cond)) spin_bug(lock, msg)
@@ -112,17 +117,7 @@ static void __spin_lock_debug(raw_spinlo
 			__delay(1);
 		}
 		/* lockup suspected: */
-		if (print_once) {
-			print_once = 0;
-			printk(KERN_EMERG "BUG: spinlock lockup on CPU#%d, "
-					"%s/%d, %p\n",
-				raw_smp_processor_id(), current->comm,
-				task_pid_nr(current), lock);
-			dump_stack();
-#ifdef CONFIG_SMP
-			trigger_all_cpu_backtrace();
-#endif
-		}
+		SPIN_BUG_ON(1, lock, "timeout");
 	}
 }