diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2011-10-31 20:12:29 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-10-31 20:30:56 -0400 |
commit | 4e101b0e6aa885f5786a058eefc1ce4b7cc7c44e (patch) | |
tree | 427a6aa51ec4a278bcfc749d4a8129cf9fe20f83 /lib | |
parent | 1dff46d6987484eaa31f2fb1425216ba06418be3 (diff) |
lib/spinlock_debug.c: print owner on spinlock lockup
When SPIN_BUG_ON is triggered, the lock owner information is reported.
But it is omitted when spinlock lockup is detected.
This information is useful especially on the architectures which don't
implement trigger_all_cpu_backtrace() that is called just after detecting
lockup. So report it and also avoid message format duplication.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spinlock_debug.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/spinlock_debug.c b/lib/spinlock_debug.c index 4755b98b6dfb..5f3eacdd6178 100644 --- a/lib/spinlock_debug.c +++ b/lib/spinlock_debug.c | |||
@@ -49,13 +49,10 @@ void __rwlock_init(rwlock_t *lock, const char *name, | |||
49 | 49 | ||
50 | EXPORT_SYMBOL(__rwlock_init); | 50 | EXPORT_SYMBOL(__rwlock_init); |
51 | 51 | ||
52 | static void spin_bug(raw_spinlock_t *lock, const char *msg) | 52 | static void spin_dump(raw_spinlock_t *lock, const char *msg) |
53 | { | 53 | { |
54 | struct task_struct *owner = NULL; | 54 | struct task_struct *owner = NULL; |
55 | 55 | ||
56 | if (!debug_locks_off()) | ||
57 | return; | ||
58 | |||
59 | if (lock->owner && lock->owner != SPINLOCK_OWNER_INIT) | 56 | if (lock->owner && lock->owner != SPINLOCK_OWNER_INIT) |
60 | owner = lock->owner; | 57 | owner = lock->owner; |
61 | printk(KERN_EMERG "BUG: spinlock %s on CPU#%d, %s/%d\n", | 58 | printk(KERN_EMERG "BUG: spinlock %s on CPU#%d, %s/%d\n", |
@@ -70,6 +67,14 @@ static void spin_bug(raw_spinlock_t *lock, const char *msg) | |||
70 | dump_stack(); | 67 | dump_stack(); |
71 | } | 68 | } |
72 | 69 | ||
70 | static void spin_bug(raw_spinlock_t *lock, const char *msg) | ||
71 | { | ||
72 | if (!debug_locks_off()) | ||
73 | return; | ||
74 | |||
75 | spin_dump(lock, msg); | ||
76 | } | ||
77 | |||
73 | #define SPIN_BUG_ON(cond, lock, msg) if (unlikely(cond)) spin_bug(lock, msg) | 78 | #define SPIN_BUG_ON(cond, lock, msg) if (unlikely(cond)) spin_bug(lock, msg) |
74 | 79 | ||
75 | static inline void | 80 | static inline void |
@@ -113,11 +118,7 @@ static void __spin_lock_debug(raw_spinlock_t *lock) | |||
113 | /* lockup suspected: */ | 118 | /* lockup suspected: */ |
114 | if (print_once) { | 119 | if (print_once) { |
115 | print_once = 0; | 120 | print_once = 0; |
116 | printk(KERN_EMERG "BUG: spinlock lockup on CPU#%d, " | 121 | spin_dump(lock, "lockup"); |
117 | "%s/%d, %p\n", | ||
118 | raw_smp_processor_id(), current->comm, | ||
119 | task_pid_nr(current), lock); | ||
120 | dump_stack(); | ||
121 | #ifdef CONFIG_SMP | 122 | #ifdef CONFIG_SMP |
122 | trigger_all_cpu_backtrace(); | 123 | trigger_all_cpu_backtrace(); |
123 | #endif | 124 | #endif |