lkml.org 
[lkml]   [2018]   [Apr]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2] locking/hung_task: Show all hung tasks before panic
From
Date
Hello.

Can we add lockdep functions which print trace of threads with locks held?

For example,

void debug_show_map_users(struct lockdep_map *map)
{
struct task_struct *g, *p;
struct held_lock *hlock;
int i, depth;

rcu_read_lock();
for_each_process_thread(g, p) {
depth = p->lockdep_depth;
hlock = p->held_locks;
for (i = 0; i < depth; i++)
if (map == hlock[i]->instance) {
touch_nmi_watchdog();
touch_all_softlockup_watchdogs();
sched_show_task(p);
lockdep_print_held_locks(p);
break;
}
}
rcu_read_unlock();
}

is for replacing debug_show_all_locks() in oom_reap_task() because
we are interested in only threads holding specific mm->mmap_sem.

For example

void debug_show_relevant_tasks(struct task_struct *origin)
{
struct task_struct *g, *p;
struct held_lock *i_hlock, *j_hlock;
int i, j, i_depth, j_depth;

rcu_read_lock();
i_depth = origin->lockdep_depth;
i_hlock = origin->held_locks;
for_each_process_thread(g, p) {
j_depth = p->lockdep_depth;
j_hlock = p->held_locks;
for (i = 0; i < i_depth; i++)
for (j = 0; j < j_depth; j++)
if (i_hlock[i]->instance == j_hlock[j]->instance)
goto hit;
continue;
hit:
touch_nmi_watchdog();
touch_all_softlockup_watchdogs();
sched_show_task(p);
lockdep_print_held_locks(p);
}
rcu_read_unlock();
}

or

void debug_show_all_locked_tasks(void)
{
struct task_struct *g, *p;

rcu_read_lock();
for_each_process_thread(g, p) {
if (p->lockdep_depth == 0)
continue;
touch_nmi_watchdog();
touch_all_softlockup_watchdogs();
sched_show_task(p);
lockdep_print_held_locks(p);
}
rcu_read_unlock();
}

are for replacing debug_show_all_locks() in check_hung_task() for cases like
https://syzkaller.appspot.com/bug?id=26aa22915f5e3b7ca2cfca76a939f12c25d624db
because we are interested in only threads holding locks.

SysRq-t is too much but SysRq-w is useless for killable/interruptible threads...

\
 
 \ /
  Last update: 2018-04-07 14:31    [W:0.098 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site