[PATCH] Make debugging variant of spinlocks a bit more robust

Petr Vandrovec (vandrove@vc.cvut.cz)
Sat, 10 May 2003 02:48:03 +0200


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)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/