From: Breno Leitao <leitao@debian.org>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Julian Sun <sunjunchao@bytedance.com>,
Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>,
Lorenzo Stoakes <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Muchun Song <muchun.song@linux.dev>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, cgroups@vger.kernel.org,
Breno Leitao <leitao@debian.org>,
kernel-team@meta.com
Subject: [PATCH v2 3/4] writeback: log the end of a slow writeback wait
Date: Tue, 10 Nov 2026 03:39:29 -0800 [thread overview]
Message-ID: <20261110-writeback_stall_report-v2-3-9e0ed75074ca@debian.org> (raw)
In-Reply-To: <20261110-writeback_stall_report-v2-0-9e0ed75074ca@debian.org>
A slow writeback wait ends with one more "has been waiting" report,
printed by the wakeup that sees the last work item complete:
[ 31.763963] INFO: The task sync:276 has been waiting for writeback completion for more than 29 seconds (bdi 252:0, work items left: 0).
That line reads as if the task were still waiting. To tell a slow
writeback from a stuck one, the reader has to notice that the reports
stopped, which is easy to miss in a busy log.
Report only while work items are outstanding, and log how long the wait
took once it is over:
[ 31.807879] The task sync:275 waited 29 seconds for writeback completion on bdi 252:0
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Breno Leitao <leitao@debian.org>
---
fs/fs-writeback.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index c5e9e5c0d506a9..e2da4781b5e00b 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -201,15 +201,16 @@ static bool wb_wait_for_completion_cb(struct wb_completion *done,
{
unsigned long timeout = sysctl_hung_task_timeout_secs;
unsigned long waited_secs = (jiffies - done->wait_start) / HZ;
+ int left = atomic_read(&done->cnt);
done->progress_stamp = jiffies;
- if (timeout && (waited_secs > timeout))
+ if (left && timeout && (waited_secs > timeout))
pr_info("INFO: The task %s:%d has been waiting for writeback "
"completion for more than %lu seconds (bdi %s, work items left: %d).\n",
current->comm, current->pid, waited_secs,
- bdi_dev_name(bdi), atomic_read(&done->cnt));
+ bdi_dev_name(bdi), left);
- return !atomic_read(&done->cnt);
+ return !left;
}
/**
@@ -226,9 +227,18 @@ static bool wb_wait_for_completion_cb(struct wb_completion *done,
void wb_wait_for_completion(struct wb_completion *done,
struct backing_dev_info *bdi)
{
+ unsigned long timeout, waited;
+
done->wait_start = jiffies;
atomic_dec(&done->cnt); /* put down the initial count */
wait_event(*done->waitq, wb_wait_for_completion_cb(done, bdi));
+
+ timeout = sysctl_hung_task_timeout_secs;
+ waited = jiffies - done->wait_start;
+ if (timeout && waited > timeout * HZ)
+ pr_info("The task %s:%d waited %lu seconds for writeback completion on bdi %s\n",
+ current->comm, current->pid, waited / HZ,
+ bdi_dev_name(bdi));
}
#ifdef CONFIG_CGROUP_WRITEBACK
--
2.53.0-Meta
next prev parent reply other threads:[~2026-11-10 11:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 11:39 [PATCH v2 0/4] writeback: make slow writeback report more actionable Breno Leitao
2026-11-10 11:39 ` [PATCH v2 1/4] writeback: add the missing newline to the slow writeback report Breno Leitao
2026-11-10 11:39 ` [PATCH v2 2/4] writeback: name the bdi in " Breno Leitao
2026-11-10 13:27 ` Jan Kara
2026-11-10 11:39 ` Breno Leitao [this message]
2026-11-10 11:39 ` [PATCH v2 4/4] writeback: report a slow writeback wait once per timeout Breno Leitao
2026-11-10 13:29 ` Jan Kara
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=20261110-writeback_stall_report-v2-3-9e0ed75074ca@debian.org \
--to=leitao@debian.org \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=jack@suse.cz \
--cc=kernel-team@meta.com \
--cc=liam@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=rppt@kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=sunjunchao@bytedance.com \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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®