From: Aaron Tomlin <atomlin@atomlin.com>
To: akpm@linux-foundation.org, lance.yang@linux.dev,
mhiramat@kernel.org, gregkh@linuxfoundation.org,
pmladek@suse.com, joel.granados@kernel.org
Cc: neelx@suse.com, sean@ashe.io, mproche@gmail.com,
chjohnst@gmail.com, nick.lange@gmail.com,
linux-kernel@vger.kernel.org
Subject: [PATCH] hung_task: Differentiate between I/O and Lock/Resource waits
Date: Sun, 25 Jan 2026 15:39:05 -0500 [thread overview]
Message-ID: <20260125203905.3393869-1-atomlin@atomlin.com> (raw)
Currently, the hung task reporting mechanism does not differentiate
between the underlying causes of a D state, labelling all such tasks
merely as "blocked". Consequently, administrators must perform manual
stack trace inspection to ascertain if the delay stems from an I/O wait
(indicative of hardware or filesystem issues) or a lock wait (indicative
of software contention).
This change utilises the in_iowait field from struct task_struct to
distinguish between two distinct failure modes in the log output:
1. D state "Disk I/O": The task is waiting in io_schedule().
This typically implies a storage device, filesystem, or
network filesystem (e.g., NFS) is unresponsive.
2. D state "Lock/Resource": The task is waiting on a kernel
primitive (e.g., mutex). This typically implies a software
bug, deadlock, or resource starvation.
It is safe to read in_iowait in this manner because
check_hung_uninterruptible_tasks() holds the RCU read lock, preserving
the task structure. Moreover, the task is effectively quiescent (in a
persistent TASK_UNINTERRUPTIBLE state) and thus cannot update its own
in_iowait status, guaranteeing a stable, race-free value.
Signed-off-by: Aaron Tomlin <atomlin@atomlin.com>
---
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 350093de0535..608731c7ccba 100644
--- a/kernel/hung_task.c
+++ b/kernel/hung_task.c
@@ -250,8 +250,9 @@ static void hung_task_info(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("INFO: task %s:%d blocked in %s state for more than %ld seconds.\n",
+ t->comm, t->pid, t->in_iowait ? "D (Disk I/O)" : "D (Lock/Resource)",
+ (jiffies - t->last_switch_time) / HZ);
pr_err(" %s %s %.*s\n",
print_tainted(), init_utsname()->release,
(int)strcspn(init_utsname()->version, " "),
--
2.51.0
next reply other threads:[~2026-01-25 20:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-25 20:39 Aaron Tomlin [this message]
2026-01-26 2:30 ` Lance Yang
2026-01-26 3:41 ` Aaron Tomlin
2026-01-28 8:17 ` Masami Hiramatsu
2026-01-28 8:26 ` Lance Yang
2026-01-28 19:13 ` Aaron Tomlin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260125203905.3393869-1-atomlin@atomlin.com \
--to=atomlin@atomlin.com \
--cc=akpm@linux-foundation.org \
--cc=chjohnst@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=joel.granados@kernel.org \
--cc=lance.yang@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mproche@gmail.com \
--cc=neelx@suse.com \
--cc=nick.lange@gmail.com \
--cc=pmladek@suse.com \
--cc=sean@ashe.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®