linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Make debugging variant of spinlocks a bit more robust
@ 2003-05-10  0:48 Petr Vandrovec
  0 siblings, 0 replies; only message in thread
From: Petr Vandrovec @ 2003-05-10  0:48 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel

Hi,
  While I was trying to hunt down problem with spin_lock_irq
in send_sig_info, I noticed that debugging spinlocks are a bit
unusable.

  Problem is that these spinlocks first print warning, and
then decrement babble. So if lock is used by printk code (like
runqueue lock was), we get nothing, just lockup or double fault...
When we first decrement babble and then printing error message
we can break this unfortunate situation and error message
(5 same error messages...) appear on screen.
					Thanks,
						Petr Vandrovec
						vandrove@vc.cvut.cz


diff -urdN linux/include/linux/spinlock.h linux/include/linux/spinlock.h
--- linux/include/linux/spinlock.h	2003-05-09 04:35:34.000000000 +0200
+++ linux/include/linux/spinlock.h	2003-05-09 22:12:21.000000000 +0200
@@ -79,10 +79,10 @@
 	do { \
 	 	CHECK_LOCK(x); \
 		if ((x)->lock&&(x)->babble) { \
+			(x)->babble--; \
 			printk("%s:%d: spin_lock(%s:%p) already locked by %s/%d\n", \
 					__FILE__,__LINE__, (x)->module, \
 					(x), (x)->owner, (x)->oline); \
-			(x)->babble--; \
 		} \
 		(x)->lock = 1; \
 		(x)->owner = __FILE__; \
@@ -95,10 +95,10 @@
 	({ \
 	 	CHECK_LOCK(x); \
 		if ((x)->lock&&(x)->babble) { \
+			(x)->babble--; \
 			printk("%s:%d: spin_is_locked(%s:%p) already locked by %s/%d\n", \
 					__FILE__,__LINE__, (x)->module, \
 					(x), (x)->owner, (x)->oline); \
-			(x)->babble--; \
 		} \
 		0; \
 	})
@@ -109,10 +109,10 @@
 	({ \
 	 	CHECK_LOCK(x); \
 		if ((x)->lock&&(x)->babble) { \
+			(x)->babble--; \
 			printk("%s:%d: spin_trylock(%s:%p) already locked by %s/%d\n", \
 					__FILE__,__LINE__, (x)->module, \
 					(x), (x)->owner, (x)->oline); \
-			(x)->babble--; \
 		} \
 		(x)->lock = 1; \
 		(x)->owner = __FILE__; \
@@ -124,10 +124,10 @@
 	do { \
 	 	CHECK_LOCK(x); \
 		if ((x)->lock&&(x)->babble) { \
+			(x)->babble--; \
 			printk("%s:%d: spin_unlock_wait(%s:%p) owned by %s/%d\n", \
 					__FILE__,__LINE__, (x)->module, (x), \
 					(x)->owner, (x)->oline); \
-			(x)->babble--; \
 		}\
 	} while (0)
 
@@ -135,9 +135,9 @@
 	do { \
 	 	CHECK_LOCK(x); \
 		if (!(x)->lock&&(x)->babble) { \
+			(x)->babble--; \
 			printk("%s:%d: spin_unlock(%s:%p) not locked\n", \
 					__FILE__,__LINE__, (x)->module, (x));\
-			(x)->babble--; \
 		} \
 		(x)->lock = 0; \
 	} while (0)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-05-10  0:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-10  0:48 [PATCH] Make debugging variant of spinlocks a bit more robust Petr Vandrovec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).