提交 4e101b0e 编写于 作者: A Akinobu Mita 提交者: Linus Torvalds

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: NAkinobu Mita <akinobu.mita@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 1dff46d6
...@@ -49,13 +49,10 @@ void __rwlock_init(rwlock_t *lock, const char *name, ...@@ -49,13 +49,10 @@ void __rwlock_init(rwlock_t *lock, const char *name,
EXPORT_SYMBOL(__rwlock_init); EXPORT_SYMBOL(__rwlock_init);
static void spin_bug(raw_spinlock_t *lock, const char *msg) static void spin_dump(raw_spinlock_t *lock, const char *msg)
{ {
struct task_struct *owner = NULL; struct task_struct *owner = NULL;
if (!debug_locks_off())
return;
if (lock->owner && lock->owner != SPINLOCK_OWNER_INIT) if (lock->owner && lock->owner != SPINLOCK_OWNER_INIT)
owner = lock->owner; owner = lock->owner;
printk(KERN_EMERG "BUG: spinlock %s on CPU#%d, %s/%d\n", 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,6 +67,14 @@ static void spin_bug(raw_spinlock_t *lock, const char *msg)
dump_stack(); dump_stack();
} }
static void spin_bug(raw_spinlock_t *lock, const char *msg)
{
if (!debug_locks_off())
return;
spin_dump(lock, msg);
}
#define SPIN_BUG_ON(cond, lock, msg) if (unlikely(cond)) spin_bug(lock, msg) #define SPIN_BUG_ON(cond, lock, msg) if (unlikely(cond)) spin_bug(lock, msg)
static inline void static inline void
...@@ -113,11 +118,7 @@ static void __spin_lock_debug(raw_spinlock_t *lock) ...@@ -113,11 +118,7 @@ static void __spin_lock_debug(raw_spinlock_t *lock)
/* lockup suspected: */ /* lockup suspected: */
if (print_once) { if (print_once) {
print_once = 0; print_once = 0;
printk(KERN_EMERG "BUG: spinlock lockup on CPU#%d, " spin_dump(lock, "lockup");
"%s/%d, %p\n",
raw_smp_processor_id(), current->comm,
task_pid_nr(current), lock);
dump_stack();
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
trigger_all_cpu_backtrace(); trigger_all_cpu_backtrace();
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册