Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933428AbcLMOqi (ORCPT ); Tue, 13 Dec 2016 09:46:38 -0500 Received: from www262.sakura.ne.jp ([202.181.97.72]:58986 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932414AbcLMOqe (ORCPT ); Tue, 13 Dec 2016 09:46:34 -0500 From: Tetsuo Handa To: linux-kernel@vger.kernel.org Cc: Tetsuo Handa , Vegard Nossum , Andrew Morton , Linus Torvalds , Mandeep Singh Baines , "Paul E. McKenney" , Peter Zijlstra , Thomas Gleixner , Ingo Molnar Subject: [PATCH] locking/hung_task: Defer showing held locks Date: Tue, 13 Dec 2016 23:45:25 +0900 Message-Id: <1481640325-7076-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2193 Lines: 68 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"). I think we don't need to call debug_show_all_locks() on each blocked thread. Let's defer calling debug_show_all_locks() till before panic() or leaving for_each_process_thread() loop. Signed-off-by: Tetsuo Handa Cc: Vegard Nossum Cc: Andrew Morton Cc: Linus Torvalds Cc: Mandeep Singh Baines Cc: Paul E. McKenney Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Ingo Molnar --- 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 2b59c82..a9ada5d 100644 --- a/kernel/hung_task.c +++ b/kernel/hung_task.c @@ -40,6 +40,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; @@ -116,12 +117,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"); } @@ -168,6 +171,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--) @@ -183,6 +187,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, -- 1.8.3.1