From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 41672280318 for ; Tue, 9 Dec 2025 06:57:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765263422; cv=none; b=HNw5fCV6zlV/rzInJnZnB+TVWfruXT1HlP6utDO0U1/wnFKrDipzj/yRVH29U7P4RlS4RbNarvQGAgOaWvDuOq/0KUBGvXL84HIRm3YHXXlTjfjhA/TLX1nhDCsJYRyyFgMtXWbvHSWCzeuSVeYzG+9uNHgRhpw4x9m9E6IAqVI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765263422; c=relaxed/simple; bh=Q0CnBCPbYP/il9m0K0yXAKzNB/nnzqM/fGCoEqClz6U=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dIv2XQ3z5lfRBHP3UFBvZkrimxuRnEoLP2gmsemBcQCb97Njl1VV5EVSLkUpxghVf0xS64v1lrepW41p6LJPuJVqyxh0hPQ8pWa7BI5Ip2p2yt4/o7jC6C+CQ1iIt2exE9fnGdl1UqDGRh79PRUdszWCvtR1oejzZJSs9yQWuMc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kwLetnHj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="kwLetnHj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7537BC4CEF5; Tue, 9 Dec 2025 06:57:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1765263421; bh=Q0CnBCPbYP/il9m0K0yXAKzNB/nnzqM/fGCoEqClz6U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kwLetnHj9U4jI67ApfPP2uNOVq2PRpKm6bBZgPaaav/KigmuXEAgkr/N0EeBESVtz lpHA8xxExFFy1+rhKfaGzQlgaCfB+h3slBtyfuCBO4EyyzuYQ8gC1oJyXGKpdpYus6 8VStUx1uUIVLGr2+7NF3Wcj7Lx7u2AiU2Syuw/NM= Date: Tue, 9 Dec 2025 15:56:58 +0900 From: Greg KH To: Lance Yang Cc: Aaron Tomlin , sean@ashe.io, linux-kernel@vger.kernel.org, mhiramat@kernel.org, akpm@linux-foundation.org, Petr Mladek Subject: Re: [PATCH 1/2] hung_task: Consolidate hung task warning into an atomic log block Message-ID: <2025120902-residence-maggot-c5f4@gregkh> References: <20251209041218.1583600-1-atomlin@atomlin.com> <20251209041218.1583600-2-atomlin@atomlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Dec 09, 2025 at 01:12:14PM +0800, Lance Yang wrote: > > > On 2025/12/9 12:12, Aaron Tomlin wrote: > > Consolidate the multi-line console output in check_hung_task() into a new > > helper function, hung_task_diagnostics(). > > > > This patch ensures the entire diagnostic block (task info, kernel > > version, and sysctl advice) is logged to the ring buffer via a single > > pr_err() call. This is critical in a concurrent environment to prevent > > message lines from interleaving with other CPU activity, thus > > maintaining contextual integrity of the warning message. > > > > Signed-off-by: Aaron Tomlin > > --- > > kernel/hung_task.c | 37 +++++++++++++++++++++++++++---------- > > 1 file changed, 27 insertions(+), 10 deletions(-) > > > > diff --git a/kernel/hung_task.c b/kernel/hung_task.c > > index d2254c91450b..d5109a0994c5 100644 > > --- a/kernel/hung_task.c > > +++ b/kernel/hung_task.c > > @@ -223,6 +223,32 @@ 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: The struct task_struct of the detected hung task. > > + * > > + * This function consolidates the printing of core diagnostic information > > + * for a task found to be blocked. This approach ensures atomic logging > > + * of the multi-line message block, preventing interleaving by other > > + * console activity, thus maintaining contextual clarity. > > + */ > > +static 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" > > + " %s %s %.*s\n" > > + "%s\n" > > "%s\n" forces an unconditional newline, causing a spurious blank line when > the flag isn't set, right? The first \n should not be there, this should be all one line. If you have multiple lines wanting to be printed, use multiple pr_err() calls. thanks, greg k-h