mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
To: peterz@infradead.org, mingo@kernel.org
Cc: akpm@linux-foundation.org, dvyukov@google.com,
	paulmck@linux.vnet.ibm.com, linux-kernel@vger.kernel.org,
	torvalds@linux-foundation.org, msb@chromium.org,
	tglx@linutronix.de, vegard.nossum@oracle.com
Subject: Re: [PATCH v2] locking/hung_task: Show all hung tasks before panic
Date: Sat, 7 Apr 2018 21:31:19 +0900	[thread overview]
Message-ID: <201804072131.AEF86988.OFOQLJMVFFtOSH@I-love.SAKURA.ne.jp> (raw)
In-Reply-To: <201804050705.BHE57833.HVFOFtSOMQJFOL@I-love.SAKURA.ne.jp>

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...

  reply	other threads:[~2018-04-07 12:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-02 14:12 [PATCH] " Tetsuo Handa
2018-04-02 15:35 ` Paul E. McKenney
2018-04-02 21:09   ` Tetsuo Handa
2018-04-03 15:23   ` Dmitry Vyukov
2018-04-04 22:05     ` [PATCH v2] " Tetsuo Handa
2018-04-07 12:31       ` Tetsuo Handa [this message]
2018-04-07 15:39         ` Peter Zijlstra
2018-04-07 16:03           ` Dmitry Vyukov
2018-04-07 16:24             ` Tetsuo Handa
2018-04-09  9:03               ` Dmitry Vyukov
2018-04-09 11:13                 ` Tetsuo Handa
2018-04-09 11:50                   ` Dmitry Vyukov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201804072131.AEF86988.OFOQLJMVFFtOSH@I-love.SAKURA.ne.jp \
    --to=penguin-kernel@i-love.sakura.ne.jp \
    --cc=akpm@linux-foundation.org \
    --cc=dvyukov@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=msb@chromium.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=vegard.nossum@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®