Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8764546rwb; Thu, 24 Nov 2022 04:06:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf4UqVcO3jJqUZtwcLro6nKVQLPyEGFHy0rRiQwF4+zGB7lZKrpBPmbeRvOlZyRLFGF5olrx X-Received: by 2002:a17:906:6703:b0:7ae:5dd6:e62d with SMTP id a3-20020a170906670300b007ae5dd6e62dmr17887461ejp.518.1669291607301; Thu, 24 Nov 2022 04:06:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669291607; cv=none; d=google.com; s=arc-20160816; b=TIfFzd6n0+FunN83VgsshH0SkZDrHQAIqixBNUIhl7ThjdwzI8gr3H614s73zA2u/a UvgCgySwoe5oKQmlH2NOgBilBu3T11icmRjDVFc1BJ9cScctlfIQinmWN5FDCTJnOPw2 c2O4MKr/smCIHZ+tFupM055WA/cMV58PUlqAMey1MHyDq34oxro7qTRNRUKR1LypAvBI r9wLbCAoQe98/+S6aWk/9EJGseN1skBWJEbzkx8X0/OvlGsJl2urtg/9dgjQ1ikhFQCl q9wQA1dKbnvZj214XxOLUfjAYbLKcIB+C82pqtLm+4Flcy0CTy+LUP/9iIh/XaSWkieE fbUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :mail-followup-to:message-id:subject:cc:to:from:date; bh=mjwNGUGDx2hEmP5V5vNvkvIzvP1N5Ewds/21cj5Rcpw=; b=y1wht+Qs2uvB24tfd9qnJkFOOU4xM2FufUCE9hfw/RWoP2NXNYFspCo1/t3mGojtZ/ 16WTLaAdbTfYW9bdzW5WnMI9/7q5fVNuDZX9tKQJlA9YzZpZC1p6011aWHhTuRUbhB9J 756qY40BuRW70/HMtuy3ZvcSJHU0ubIY1xEaCmLG5T60Ln3pF2O18Rn19IiSNMI5jYEG v+4nq+A+LZdkQtmY2i/QBcTihta/N8SOhq5QUmclHRP0i1D0A6AQmblVqLw65TJ3gkux cJp0qk7IzefklT6z6uB497NFR/5Bug5NA4Wk14qJEdgou0jyYPHzDeyH6fuHe7WuINLX DO9g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dr5-20020a170907720500b007a7a3b40920si377905ejc.995.2022.11.24.04.06.25; Thu, 24 Nov 2022 04:06:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230126AbiKXL1p (ORCPT + 86 others); Thu, 24 Nov 2022 06:27:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230079AbiKXL1l (ORCPT ); Thu, 24 Nov 2022 06:27:41 -0500 X-Greylist: delayed 121 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 24 Nov 2022 03:27:39 PST Received: from mx5.didiglobal.com (mx5.didiglobal.com [111.202.70.122]) by lindbergh.monkeyblade.net (Postfix) with SMTP id D3FD511466 for ; Thu, 24 Nov 2022 03:27:37 -0800 (PST) Received: from mail.didiglobal.com (unknown [10.79.65.12]) by mx5.didiglobal.com (Maildata Gateway V2.8) with ESMTPS id ECB8CB0148E0B; Thu, 24 Nov 2022 19:25:33 +0800 (CST) Received: from didi-ThinkCentre-M930t-N000 (10.79.64.101) by ZJY02-ACTMBX-02.didichuxing.com (10.79.65.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Thu, 24 Nov 2022 19:25:33 +0800 Date: Thu, 24 Nov 2022 19:25:26 +0800 X-MD-Sfrom: tiozhang@didiglobal.com X-MD-SrcIP: 10.79.65.12 From: Tio Zhang To: , , CC: , Subject: [PATCH] kernel/hung_task: print real_parent->comm, pid in check_hung_task Message-ID: <20221124112526.GA21832@didi-ThinkCentre-M930t-N000> Mail-Followup-To: pmladek@suse.com, akpm@linux-foundation.org, peterz@infradead.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-Originating-IP: [10.79.64.101] X-ClientProxiedBy: ZJY03-PUBMBX-01.didichuxing.com (10.79.71.12) To ZJY02-ACTMBX-02.didichuxing.com (10.79.65.12) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We can avoid a hung task by fixing the process who causes it. But sometimes it is difficult to find out which service the bad process belongs to by only knowing its pid and comm. Since userspace tools to learn who launches the bad process do not always work when we get a hung task, it is helpful printing the parent by kernel. Signed-off-by: Tio Zhang --- kernel/hung_task.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/hung_task.c b/kernel/hung_task.c index c71889f3f3fc..33543d27bd5c 100644 --- a/kernel/hung_task.c +++ b/kernel/hung_task.c @@ -89,6 +89,7 @@ static struct notifier_block panic_block = { static void check_hung_task(struct task_struct *t, unsigned long timeout) { + struct task_struct *p = t->real_parent; unsigned long switch_count = t->nvcsw + t->nivcsw; /* @@ -129,8 +130,8 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout) if (sysctl_hung_task_warnings) { if (sysctl_hung_task_warnings > 0) 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("INFO: task %s:%d, parent %s:%d blocked for more than %ld seconds.\n", + t->comm, t->pid, p->comm, p->pid, (jiffies - t->last_switch_time) / HZ); pr_err(" %s %s %.*s\n", print_tainted(), init_utsname()->release, (int)strcspn(init_utsname()->version, " "), -- 2.17.1