From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-183.mta0.migadu.com (out-183.mta0.migadu.com [91.218.175.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABBF12E40E for ; Thu, 1 Jan 2026 09:50:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.183 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767261010; cv=none; b=qr0xh8+c7Mi9lgt77sg1+kgrTMvAyeSinXlyNwJoebB2D0VeNLdHBxbovsZhnODB9+ck8Sh1GY/rkuoC5M9ERBbF+rLQVCh/a1Viu3jVOnr16R87fxTuFieP6sIKyIaziykK70DqOOjkqm4X2cg9rOlMDhNBR6wj6k/HDP2BzgQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767261010; c=relaxed/simple; bh=heHvNmRvxeaCOEKVX630+tyq337QWeVz8g5pzeS8lqA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=lEk66Rnvwbg838oOSyNLeM0/s4PWhD1sMgtzXRbJSlSfQgB9aw0sOdTt0TjiVkccScNQunPJsIVXy+6jwOM2k+F/7XHOdAagAVFkaIlXLGOnKcfQKBoTe0Zbefde/lB/GXfFoDbuhxEbf5cOkzOOfyEMxRdNlSkAYHPQ35jEuro= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=EzstT3gV; arc=none smtp.client-ip=91.218.175.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="EzstT3gV" Message-ID: <8a82158f-370a-4c6d-b7f8-71f80aa3e3d2@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1767261005; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dDl4ENVl4GheVyMdQWWRvaN63Sf/yPc+8Uspb0c5Hcs=; b=EzstT3gVDFQ4YUO3wM6n+QfejC2GFh0R2wp9mxqG15W9if20e4F6HkaBqGtBTAsQ69QMBE W4HmFnjPOFICbj6f5wM1KjGKH9QVKU3un81HSTxp+IQiQcmepdHIhhnBohJqZFYjgZTfxC EjE/LWUkahP7fwkVnTMAuFm/rVb3k7s= Date: Thu, 1 Jan 2026 17:49:59 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [v5 PATCH 1/2] hung_task: Introduce helper for hung task warning Content-Language: en-US To: Aaron Tomlin Cc: sean@ashe.io, akpm@linux-foundation.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, joel.granados@kernel.org, pmladek@suse.com, mhiramat@kernel.org References: <20251231004125.2380105-1-atomlin@atomlin.com> <20251231004125.2380105-2-atomlin@atomlin.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Lance Yang In-Reply-To: <20251231004125.2380105-2-atomlin@atomlin.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 2025/12/31 08:41, Aaron Tomlin wrote: > Consolidate the multi-line console output block for reporting a hung > task into a new helper function, hung_task_diagnostics(). This improves > readability in the main check_hung_task() loop and makes the diagnostic > output structure easier to maintain and update in the future. > > Signed-off-by: Aaron Tomlin > --- > kernel/hung_task.c | 33 +++++++++++++++++++++++---------- > 1 file changed, 23 insertions(+), 10 deletions(-) > > diff --git a/kernel/hung_task.c b/kernel/hung_task.c > index d2254c91450b..00c3296fd692 100644 > --- a/kernel/hung_task.c > +++ b/kernel/hung_task.c > @@ -223,6 +223,28 @@ static inline void debug_show_blocker(struct task_struct *task, unsigned long ti > } > #endif > > +/** > + * hung_task_diagnostics - Print structured diagnostic info for a hung task. > + * @t: Pointer to the detected hung task. > + * > + * This function consolidates the printing of core diagnostic information > + * for a task found to be blocked. > + */ > +static inline void hung_task_diagnostics(struct task_struct *t) > +{ > + unsigned long blocked_secs = (jiffies - t->last_switch_time) / HZ; > + > + pr_err("INFO: task %s:%d blocked for more than %ld seconds.\n", > + t->comm, t->pid, blocked_secs); > + pr_err(" %s %s %.*s\n", > + print_tainted(), init_utsname()->release, > + (int)strcspn(init_utsname()->version, " "), > + init_utsname()->version); > + if (t->flags & PF_POSTCOREDUMP) > + pr_err(" Blocked by coredump.\n"); > + pr_err("\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\" disables this message.\n"); > +} > + > static void check_hung_task(struct task_struct *t, unsigned long timeout, > unsigned long prev_detect_count) > { > @@ -252,16 +274,7 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout, > if (sysctl_hung_task_warnings || hung_task_call_panic) { > 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(" %s %s %.*s\n", > - print_tainted(), init_utsname()->release, > - (int)strcspn(init_utsname()->version, " "), > - init_utsname()->version); > - if (t->flags & PF_POSTCOREDUMP) > - pr_err(" Blocked by coredump.\n"); > - pr_err("\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\"" > - " disables this message.\n"); > + hung_task_diagnostics(t); I am wondering whether we should leave that code as-is to avoid unnecessary churn ... That code was not particularly complex or duplicated :) > sched_show_task(t); > debug_show_blocker(t, timeout); >