From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DAF834573C for ; Wed, 17 Dec 2025 09:39:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.65 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765964354; cv=none; b=f4TAmclENeP+h4ahEMnRlAGPDbiENww6xh/a40s5rhltiOILK3NgQZ61f80UULwbvZmV+ozl/4V3A66n1lmCK8hwnj4nIw530dzGjfSVhk5EuSjckNRTbjJerm6CBaQk3LoAq+xScSbU7qVyH0GKJEKXorhtfLNKbMyfVo/MhYQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765964354; c=relaxed/simple; bh=a8DT2TKEX0S8ur07QgdtVishDn1ASS+PJOJHERojTgQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PXp5XKAqswjmApP8D5gzIemBy6ti9Q6SluIYegRiA60LabAJHeVBo8kIR8tNT3Xc3pgiHKM9RaCmVn3WilaYrdCyC8Sq/T2IfcFl9N9SqZpHQL5Sel26iRM1yzAmsEPPAZ1flErA+DOEMvr07wntlsooqlUTT2j4+4RaNQWY6a8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=E9buXwt6; arc=none smtp.client-ip=209.85.128.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="E9buXwt6" Received: by mail-wm1-f65.google.com with SMTP id 5b1f17b1804b1-47789cd2083so29745965e9.2 for ; Wed, 17 Dec 2025 01:39:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1765964350; x=1766569150; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ekONAeIFa5W41JtMXMgFYLtT5JC42pPJLPCwVzl+sAI=; b=E9buXwt6vvuIFwqNd1QkQJmAp00Hy13puk4fYWAdfHAg7erGv8AAZYL19FxkbxrRNX YkWC2BHXK+6ycacKTvAwWvH07VMVHObulqvCEV2m5wGtUMMjCx/oTVHq38jMYzezDq55 VAv73rzkAyJsHLLojJRf9li5mMov8ugduU0any0ddJn54MWrw2IuI8XunWHJdQkNJAqt LrHgYilcazclVjukA/CcXwNSr1E5DeArI+MkTTrGBzhfMrWkvDcNhItKsZiPfJEbS3lx skbPyJMbuV9YCttvN+/vBgu9He/+noHGK6LmNArPIjMfXoWFyxgLBnZqWB0SxYYjPe8t DaYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765964350; x=1766569150; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ekONAeIFa5W41JtMXMgFYLtT5JC42pPJLPCwVzl+sAI=; b=WLi6XngR3LLV8aFfceagv5s3tkimcCo6aXW+2gnp1J/pBleO4Ygzkk7Rz9vVrUVe81 mrsJ0H0tAx2zqJooRG8KMV8Z5QQR+RWxIsQ0FB9vUuD+phgxUiO1eXKT0cs8tsbnhFKT M0BYR9fPKSHI5DLFVK/9C9NqVrRMDbc0k9Ro3eZFhMZCLT6Azh5EztA1sBn525Csc3Ve h0Q3dsZ+7kNLAKGWhIRZycsEWeimyxhaWy4JLA+/338/7E0XS6gUHONGLmKghMKDsZya 8XbVWOm1WfbNzum3JjIUw92oS900eCBwXxdxMnulJBE9WrwL7RQ6Uz7/emrX8L+CsUS3 JAMg== X-Forwarded-Encrypted: i=1; AJvYcCUPJHGvjBVtEZDC4ujWaZ1X2f1kZHqr2i5tWGI7y9qxhNpdAYEUtNr0TwvKTmCnpUTMf1xRadcfj/6Of9k=@vger.kernel.org X-Gm-Message-State: AOJu0YwDTwYSbQFzrCIHbihJmjOSGXS6jPkERLKTqzSQLOgwkAh3zZmy 6zzHVNCaaxkrMYHgR+XqP6b/O/jy+qdFGxRyV2BnbJVOYSytQ42zvSoWauhxGfuZXJI= X-Gm-Gg: AY/fxX577twvquvuJFQ60vUqjk+sKTLajI8rp+/gfIFVfPZWCRHPkFmA5QBsLtJrKJq tIPZROk4vwptA2AwqbKdEUx3FGudgv/B0/1bSQ1XKAgb9bTufGYiFzDtNSpgUAH7935s+1ggxD6 t6WIXhizdwbz7tYDaKJBaLH0YTuOW3Cjrkn3JNjukkeiM4QCYtqiJQdUKo4u3woyUrWAe6PKjhe qj1Tp7rkOgdi0bX/q3XlvbY/vm2+3SkpUOUQp+44YwoJXE25hs8HzKjyGjZgPJ6mDCmCCbRr1r0 ALLxqMZ7iVG8E9CbKTFFswPwNpvV62FimPX0S6Oc1Cn7vDAevzbxm0vVWih0HueLsSOTAwQkOGL h4h6xrGgl/fQOeoyW36FAs4LPRAwkgdEgM1m0KPZQ9omC42DABnzCbJsK9k21qnnmuUkb8pM3Wh JBLrVEG7Jtyd6aYCf018lJRdjG X-Google-Smtp-Source: AGHT+IGReQltJupQuFYuvkVH5CSCTbo3+9McnrRnCyBLXAenxE9/hwqNJL08zNUk/CN/BOgMPA3c5A== X-Received: by 2002:a05:600c:1c91:b0:477:2f7c:314f with SMTP id 5b1f17b1804b1-47a8f8bdc58mr223521725e9.10.1765964349653; Wed, 17 Dec 2025 01:39:09 -0800 (PST) Received: from pathway.suse.cz ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4310adef010sm3781673f8f.35.2025.12.17.01.39.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Dec 2025 01:39:09 -0800 (PST) Date: Wed, 17 Dec 2025 10:39:07 +0100 From: Petr Mladek To: Aaron Tomlin Cc: akpm@linux-foundation.org, lance.yang@linux.dev, mhiramat@kernel.org, gregkh@linuxfoundation.org, sean@ashe.io, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/2] hung_task: Introduce helper for hung task warning Message-ID: References: <20251216030036.1822217-1-atomlin@atomlin.com> <20251216030036.1822217-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: <20251216030036.1822217-2-atomlin@atomlin.com> On Mon 2025-12-15 22:00:35, 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 | 37 +++++++++++++++++++++++++++---------- > 1 file changed, 27 insertions(+), 10 deletions(-) > > diff --git a/kernel/hung_task.c b/kernel/hung_task.c > index d2254c91450b..5902573200c0 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: 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; It makes sense to make the computation separately. > + const char *coredump_msg = " Blocked by coredump."; Honestly, I do not see any advantage in storing the string into a variable and passing it via %s. It does not help with readability because the reader has to lookup the variable definition. And it is less effective code (not a big deal but...). Instead, I would add "\n". It will allow to show the message immediately on consoles. Without the trailing "\n", the message is not finalized because it might still get extended by pr_cont(). > + const char *disable_msg = > + "\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\"" > + " disables this message."; Same here. I would avoid the %s and add the trailing '\n'. Also the message should be on a single line. It makes it easier to find it via "git grep". ./scripts/checkpatch.pl even complain about it: WARNING: quoted string split across lines #37: FILE: kernel/hung_task.c:239: + "\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\"" + " disables this message."; > + 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("%s\n", coredump_msg); > + pr_err("%s\n", disable_msg); > +} Otherwise, I like the change. Best Regards, Petr