Commit 427a5f53 authored by Andrew Morton's avatar Andrew Morton Committed by Patrick Mochel

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

From: Petr Vandrovec <vandrove@vc.cvut.cz>

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.

The problem is that these spinlocks first print warning, and then
decrement babble.  So if the lock is used by printk code (like runqueue
lock was), we get nothing, just a lockup or a double fault...  When we
first decrement babble and then print the error message we can break
this unfortunate situation and the error message (5 of the same...)
appear on screen.
parent 18916f56
...@@ -79,10 +79,10 @@ typedef struct { ...@@ -79,10 +79,10 @@ typedef struct {
do { \ do { \
CHECK_LOCK(x); \ CHECK_LOCK(x); \
if ((x)->lock&&(x)->babble) { \ if ((x)->lock&&(x)->babble) { \
(x)->babble--; \
printk("%s:%d: spin_lock(%s:%p) already locked by %s/%d\n", \ printk("%s:%d: spin_lock(%s:%p) already locked by %s/%d\n", \
__FILE__,__LINE__, (x)->module, \ __FILE__,__LINE__, (x)->module, \
(x), (x)->owner, (x)->oline); \ (x), (x)->owner, (x)->oline); \
(x)->babble--; \
} \ } \
(x)->lock = 1; \ (x)->lock = 1; \
(x)->owner = __FILE__; \ (x)->owner = __FILE__; \
...@@ -95,10 +95,10 @@ typedef struct { ...@@ -95,10 +95,10 @@ typedef struct {
({ \ ({ \
CHECK_LOCK(x); \ CHECK_LOCK(x); \
if ((x)->lock&&(x)->babble) { \ if ((x)->lock&&(x)->babble) { \
(x)->babble--; \
printk("%s:%d: spin_is_locked(%s:%p) already locked by %s/%d\n", \ printk("%s:%d: spin_is_locked(%s:%p) already locked by %s/%d\n", \
__FILE__,__LINE__, (x)->module, \ __FILE__,__LINE__, (x)->module, \
(x), (x)->owner, (x)->oline); \ (x), (x)->owner, (x)->oline); \
(x)->babble--; \
} \ } \
0; \ 0; \
}) })
...@@ -109,10 +109,10 @@ typedef struct { ...@@ -109,10 +109,10 @@ typedef struct {
({ \ ({ \
CHECK_LOCK(x); \ CHECK_LOCK(x); \
if ((x)->lock&&(x)->babble) { \ if ((x)->lock&&(x)->babble) { \
(x)->babble--; \
printk("%s:%d: spin_trylock(%s:%p) already locked by %s/%d\n", \ printk("%s:%d: spin_trylock(%s:%p) already locked by %s/%d\n", \
__FILE__,__LINE__, (x)->module, \ __FILE__,__LINE__, (x)->module, \
(x), (x)->owner, (x)->oline); \ (x), (x)->owner, (x)->oline); \
(x)->babble--; \
} \ } \
(x)->lock = 1; \ (x)->lock = 1; \
(x)->owner = __FILE__; \ (x)->owner = __FILE__; \
...@@ -124,10 +124,10 @@ typedef struct { ...@@ -124,10 +124,10 @@ typedef struct {
do { \ do { \
CHECK_LOCK(x); \ CHECK_LOCK(x); \
if ((x)->lock&&(x)->babble) { \ if ((x)->lock&&(x)->babble) { \
(x)->babble--; \
printk("%s:%d: spin_unlock_wait(%s:%p) owned by %s/%d\n", \ printk("%s:%d: spin_unlock_wait(%s:%p) owned by %s/%d\n", \
__FILE__,__LINE__, (x)->module, (x), \ __FILE__,__LINE__, (x)->module, (x), \
(x)->owner, (x)->oline); \ (x)->owner, (x)->oline); \
(x)->babble--; \
}\ }\
} while (0) } while (0)
...@@ -135,9 +135,9 @@ typedef struct { ...@@ -135,9 +135,9 @@ typedef struct {
do { \ do { \
CHECK_LOCK(x); \ CHECK_LOCK(x); \
if (!(x)->lock&&(x)->babble) { \ if (!(x)->lock&&(x)->babble) { \
(x)->babble--; \
printk("%s:%d: spin_unlock(%s:%p) not locked\n", \ printk("%s:%d: spin_unlock(%s:%p) not locked\n", \
__FILE__,__LINE__, (x)->module, (x));\ __FILE__,__LINE__, (x)->module, (x));\
(x)->babble--; \
} \ } \
(x)->lock = 0; \ (x)->lock = 0; \
} while (0) } while (0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment