From nobody Mon Sep 15 11:17:12 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA6D0C54EBC for ; Thu, 12 Jan 2023 09:28:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240212AbjALJ2X (ORCPT ); Thu, 12 Jan 2023 04:28:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240131AbjALJ1Z (ORCPT ); Thu, 12 Jan 2023 04:27:25 -0500 X-Greylist: delayed 122 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 12 Jan 2023 01:19:56 PST Received: from mx6.didiglobal.com (mx6.didiglobal.com [111.202.70.123]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 46DB6CFF for ; Thu, 12 Jan 2023 01:19:55 -0800 (PST) Received: from mail.didiglobal.com (unknown [10.79.65.15]) by mx6.didiglobal.com (Maildata Gateway V2.8) with ESMTPS id DF8121100FBE32; Thu, 12 Jan 2023 17:17:50 +0800 (CST) Received: from zwp-5820-Tower (10.79.65.102) by ZJY02-ACTMBX-05.didichuxing.com (10.79.65.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 12 Jan 2023 17:17:50 +0800 Date: Thu, 12 Jan 2023 17:17:45 +0800 X-MD-Sfrom: zhangweiping@didiglobal.com X-MD-SrcIP: 10.79.65.15 From: Weiping Zhang To: , , CC: , Subject: [RFC PATCH] hung_task: show sysctl_hung_task_warnings Message-ID: Mail-Followup-To: pmladek@suse.com, akpm@linux-foundation.org, peterz@infradead.org, linux-kernel@vger.kernel.org, zwp10758@gmail.com MIME-Version: 1.0 Content-Disposition: inline X-Originating-IP: [10.79.65.102] X-ClientProxiedBy: ZJY03-PUBMBX-01.didichuxing.com (10.79.71.12) To ZJY02-ACTMBX-05.didichuxing.com (10.79.65.15) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This patch try to add more debug info to detect lost kernel log or no hung task was detected. The user set 10 to the hung_task_timeout_secs, the kernel log: [ 3942.642220] INFO: task mount:19066 blocked for more than 10 seconds. [ 3952.876768] INFO: task kworker/u81:0:7 blocked for more than 10 seconds. [ 3952.877088] INFO: task scsi_eh_0:506 blocked for more than 10 seconds. [ 3952.878212] INFO: task mount:19066 blocked for more than 10 seconds. [ 3963.116805] INFO: task kworker/u81:0:7 blocked for more than 10 seconds. [ 3963.117137] INFO: task scsi_eh_0:506 blocked for more than 10 seconds. [ 3963.118275] INFO: task mount:19066 blocked for more than 10 seconds. [ 3973.356837] INFO: task kworker/u81:0:7 blocked for more than 10 seconds. [ 3973.357148] INFO: task scsi_eh_0:506 blocked for more than 10 seconds. [ 3973.358247] INFO: task mount:19066 blocked for more than 10 seconds. [ 3993.836899] INFO: task kworker/u81:0:7 blocked for more than 10 seconds. [ 3993.837238] INFO: task scsi_eh_0:506 blocked for more than 10 seconds. [ 3993.838356] INFO: task mount:19066 blocked for more than 10 seconds. There is no any log at about 3983, it's hard to know if kernel log was lost or there is no hung task was detected at that moment. So this patch print sysctl_hung_task_warnings to distinguish the above two cases. Signed-off-by: Weiping Zhang --- kernel/hung_task.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/hung_task.c b/kernel/hung_task.c index c71889f3f3fc..ca917931473d 100644 --- a/kernel/hung_task.c +++ b/kernel/hung_task.c @@ -127,8 +127,11 @@ static void check_hung_task(struct task_struct *t, uns= igned long timeout) * complain: */ if (sysctl_hung_task_warnings) { - if (sysctl_hung_task_warnings > 0) + if (sysctl_hung_task_warnings > 0) { sysctl_hung_task_warnings--; + pr_err("sysctl_hung_task_warnings: %d\n", + sysctl_hung_task_warnings); + } pr_err("INFO: task %s:%d blocked for more than %ld seconds.\n", t->comm, t->pid, (jiffies - t->last_switch_time) / HZ); pr_err(" %s %s %.*s\n", --=20 2.34.1