linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vegard Nossum <vegard.nossum@oracle.com>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
	akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] locking/hung_task: Defer showing held locks
Date: Sun, 12 Mar 2017 10:00:06 +0100	[thread overview]
Message-ID: <1fbf16fc-037c-893d-7f0b-108e930fca42@oracle.com> (raw)
In-Reply-To: <1489296834-60436-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp>

On 12/03/2017 06:33, Tetsuo Handa wrote:
> When I was running my testcase which may block hundreds of threads
> on fs locks, I got lockup due to output from debug_show_all_locks()
> added by commit b2d4c2edb2e4f89a ("locking/hung_task: Show all locks").
>
> For example, if 1000 threads were blocked in TASK_UNINTERRUPTIBLE state
> and 500 out of 1000 threads hold some lock, debug_show_all_locks() from
> for_each_process_thread() loop will report locks held by 500 threads for
> 1000 times. This is a too much noise.
>
> In order to make sure rcu_lock_break() is called frequently, we should
> avoid calling debug_show_all_locks() from for_each_process_thread() loop
> because debug_show_all_locks() effectively calls for_each_process_thread()
> loop. Let's defer calling debug_show_all_locks() till before panic() or
> leaving for_each_process_thread() loop.
>
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> Cc: Vegard Nossum <vegard.nossum@oracle.com>
> ---
>  kernel/hung_task.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/hung_task.c b/kernel/hung_task.c
> index f0f8e2a..751593e 100644
> --- a/kernel/hung_task.c
> +++ b/kernel/hung_task.c
> @@ -43,6 +43,7 @@
>  int __read_mostly sysctl_hung_task_warnings = 10;
>
>  static int __read_mostly did_panic;
> +static bool hung_task_show_lock;
>
>  static struct task_struct *watchdog_task;
>
> @@ -120,12 +121,14 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
>  		pr_err("\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\""
>  			" disables this message.\n");
>  		sched_show_task(t);
> -		debug_show_all_locks();
> +		hung_task_show_lock = true;
>  	}
>
>  	touch_nmi_watchdog();
>
>  	if (sysctl_hung_task_panic) {
> +		if (hung_task_show_lock)
> +			debug_show_all_locks();
>  		trigger_all_cpu_backtrace();
>  		panic("hung_task: blocked tasks");
>  	}
> @@ -172,6 +175,7 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout)
>  	if (test_taint(TAINT_DIE) || did_panic)
>  		return;
>
> +	hung_task_show_lock = false;
>  	rcu_read_lock();
>  	for_each_process_thread(g, t) {
>  		if (!max_count--)
> @@ -187,6 +191,8 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout)
>  	}
>   unlock:
>  	rcu_read_unlock();
> +	if (hung_task_show_lock)
> +		debug_show_all_locks();
>  }
>
>  static long hung_timeout_jiffies(unsigned long last_checked,
>

Reviewed/Acked-by: Vegard Nossum <vegard.nossum@oracle.com>

Thank you for fixing this.


Vegard

  reply	other threads:[~2017-03-12  9:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-12  5:33 [PATCH] locking/hung_task: Defer showing held locks Tetsuo Handa
2017-03-12  9:00 ` Vegard Nossum [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-12-13 14:45 Tetsuo Handa
2016-12-20  8:14 ` Vegard Nossum
2016-12-20 13:34   ` Tetsuo Handa
2017-02-28  2:05     ` Tetsuo Handa

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=1fbf16fc-037c-893d-7f0b-108e930fca42@oracle.com \
    --to=vegard.nossum@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    /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;
as well as URLs for NNTP newsgroup(s).