Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796086242; b=JXOA14rN5qNPEIe/sTUbOG3fuQgzk3zq4UwmI2YvxKFue4es7o5LmA7HHQbTVPZMaHJe /FUUY1IitbN3ADZIWfUqv8BwgFNurxS0T/4sMK0ZFRFGgYBnEG4eoHtDP92LpHe9aqYKg I8YU25UujmE87mc+GXF4MqBbaBPHdbslo6CHaXFewIoDKVUT+zkFUYQd5jacvqPWg+rQM 0/NmZAk2mV3W5fi23SmgeY0EOnXIUFPVRqn65nBzQmc+hxlxOiDGWGzaENV4HW8wwhXum w29hw926VxpdE+CmtRX4VDZfFKruyML1MwhgCj2vWVa/AzkWSDwvHYvYkkyiDEPJ3pw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796086242; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-Id: In-Reply-To:References:X-Mailer:Mime-Version:Content-Type: Content-Transfer-Encoding; bh=u9k4+SIJNBibuEfcdohti1I1G3RRJhlwh+VdMRU0SN4=; b=wDlICr7PDEaPVXb8GsF02xL5L289RStpjkyGCreTvTazFw2ywXfHW4Srx7muqOaTuBfZ umjm8oJjZpth0obVNExFmIXciaYwUQjnxEp9m5LtafinugAN4Q8CCuuX/N878UgleEs64 9i0K0iBFVC2o+1b35cSahDn5Pmqb0+pQUQkI6qQBggvF+hVJgc8NYq/kuxhs7k81BCmRg qgL/66zGp2IEJQIbNl4Tksg7oNggCo6UcNXeXi5NiOUwhNT7dRFqR5IF5sGohgEgFHL5J +dm+0dj/W1OqLwlsSV01ZElzQJc6bimGJ92CvOECjJtNVLM01We70voakR7AWd8JAuw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=lTvSGZSo; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B31EF606A31A for ; Tue, 1 Dec 2026 00:50:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=lTvSGZSo Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84FB61F00893; Tue, 1 Dec 2026 00:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796086242; bh=u9k4+SIJNBibuEfcdohti1I1G3RRJhlwh+VdMRU0SN4=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=lTvSGZSoXjhOkBRTsc9vR8L2WL6doXRQ5QHix/QjM5LdKnuTi/xPYRb95wD+gFq// mMGrtnCPUTYmEyQ+LQ5YIvVHVtRjpYu+hlLT0hU3cslIA12/ImHUn8N6bzGXq608Rp cAiGyV6hxG9q0haQ3i01/aar7DocPrrmE5a1KA4s= Date: Mon, 30 Nov 2026 16:50:41 -0800 From: Andrew Morton To: Leon Hwang Cc: Lance Yang , Masami Hiramatsu , Petr Mladek , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , Feng Tang , linux-kernel@vger.kernel.org Subject: Re: [PATCH] hung_task: avoid duplicate stack dumps in sys_info() Message-Id: <20261130165041.323f372cd6435bcab0f13c0f@linux-foundation.org> In-Reply-To: <20261130151156.22234-1-leon.hwang@linux.dev> References: <20261130151156.22234-1-leon.hwang@linux.dev> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 30 Nov 2026 23:11:56 +0800 Leon Hwang wrote: > When hung_task_sys_info includes blocked_tasks, khungtaskd dumps each > reported hung task's stack, then calls sys_info() to dump D-state tasks. > A task that stays blocked gets its stack printed twice in the same scan. > > Track the tasks khungtaskd reports during the scan. If a recorded task > still appears blocked at the same switch count, print a short message > in place of the second stack dump. > > With this change, the second dump would be replaced with a log. > > [ 20.143549] INFO: task cat:607 blocked for more than 5 seconds. > [ 20.143560] Not tainted 7.4.0-rc4-gfb22a6547753-dirty #12 > [ 20.143564] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. > [ 20.143567] task:cat state:D stack:0 pid:607 tgid:607 ppid:603 task_flags:0x400000 flags:0x00080000 > > ... > > [ 20.144250] task cat:607 has been reported by hung task detector. OK. This is a pretty minor bug! And userspace can filter out the duplicates easily enough (I assume). > --- > include/linux/hung_task.h | 9 +++++ > kernel/hung_task.c | 76 ++++++++++++++++++++++++++++++++++++--- > kernel/sched/core.c | 4 +++ > 3 files changed, 85 insertions(+), 4 deletions(-) And that's a lot of churn. task_struct.atomic_flags has plenty of unused bits and using one of them for this purpose seems appropriate. Can we set one of those bits for deduplication and later test-n-clear it in check_hung_uninterruptible_tasks() ->sys_info(si_mask) ->show_state_filter(TASK_UNINTERRUPTIBLE)? Or something along these lines?