locking/lockdep: Use for_each_process_thread() for debug_show_all_locks()
debug_show_all_locks() tries to grab the tasklist_lock for two seconds, but calling while_each_thread() without tasklist_lock held is not safe. See the following commit for more information: 4449a51a7c281602 ("vm_is_stack: use for_each_thread() rather then buggy while_each_thread()") Change debug_show_all_locks() from "do_each_thread()/while_each_thread() with possibility of missing tasklist_lock" to "for_each_process_thread() with RCU", and add a call to touch_all_softlockup_watchdogs() like show_state_filter() does. Change-Id: I502b9ea50d180aedad7f379ffc0b987d0223d739 Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/1523011279-8206-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
parent
8fd63f9bb0
commit
1117984b6e
|
@ -4119,8 +4119,6 @@ EXPORT_SYMBOL_GPL(debug_check_no_locks_held);
|
||||||
void debug_show_all_locks(void)
|
void debug_show_all_locks(void)
|
||||||
{
|
{
|
||||||
struct task_struct *g, *p;
|
struct task_struct *g, *p;
|
||||||
int count = 10;
|
|
||||||
int unlock = 1;
|
|
||||||
|
|
||||||
if (unlikely(!debug_locks)) {
|
if (unlikely(!debug_locks)) {
|
||||||
printk("INFO: lockdep is turned off.\n");
|
printk("INFO: lockdep is turned off.\n");
|
||||||
|
@ -4128,30 +4126,8 @@ void debug_show_all_locks(void)
|
||||||
}
|
}
|
||||||
printk("\nShowing all locks held in the system:\n");
|
printk("\nShowing all locks held in the system:\n");
|
||||||
|
|
||||||
/*
|
rcu_read_lock();
|
||||||
* Here we try to get the tasklist_lock as hard as possible,
|
for_each_process_thread(g, p) {
|
||||||
* if not successful after 2 seconds we ignore it (but keep
|
|
||||||
* trying). This is to enable a debug printout even if a
|
|
||||||
* tasklist_lock-holding task deadlocks or crashes.
|
|
||||||
*/
|
|
||||||
retry:
|
|
||||||
if (!read_trylock(&tasklist_lock)) {
|
|
||||||
if (count == 10)
|
|
||||||
printk("hm, tasklist_lock locked, retrying... ");
|
|
||||||
if (count) {
|
|
||||||
count--;
|
|
||||||
printk(" #%d", 10-count);
|
|
||||||
mdelay(200);
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
printk(" ignoring it.\n");
|
|
||||||
unlock = 0;
|
|
||||||
} else {
|
|
||||||
if (count != 10)
|
|
||||||
printk(KERN_CONT " locked it.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
do_each_thread(g, p) {
|
|
||||||
/*
|
/*
|
||||||
* It's not reliable to print a task's held locks
|
* It's not reliable to print a task's held locks
|
||||||
* if it's not sleeping (or if it's not the current
|
* if it's not sleeping (or if it's not the current
|
||||||
|
@ -4159,19 +4135,16 @@ retry:
|
||||||
*/
|
*/
|
||||||
if (p->state == TASK_RUNNING && p != current)
|
if (p->state == TASK_RUNNING && p != current)
|
||||||
continue;
|
continue;
|
||||||
if (p->lockdep_depth)
|
if (!p->lockdep_depth)
|
||||||
lockdep_print_held_locks(p);
|
continue;
|
||||||
if (!unlock)
|
lockdep_print_held_locks(p);
|
||||||
if (read_trylock(&tasklist_lock))
|
|
||||||
unlock = 1;
|
|
||||||
touch_nmi_watchdog();
|
touch_nmi_watchdog();
|
||||||
} while_each_thread(g, p);
|
touch_all_softlockup_watchdogs();
|
||||||
|
}
|
||||||
|
rcu_read_unlock();
|
||||||
|
|
||||||
printk("\n");
|
printk("\n");
|
||||||
printk("=============================================\n\n");
|
printk("=============================================\n\n");
|
||||||
|
|
||||||
if (unlock)
|
|
||||||
read_unlock(&tasklist_lock);
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(debug_show_all_locks);
|
EXPORT_SYMBOL_GPL(debug_show_all_locks);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue