diff options
| author | Julian Sun <sunjunchao@bytedance.com> | 2025-09-30 15:18:29 +0800 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2025-10-20 20:22:39 +0200 |
| commit | d6e6215907640801b1f407dc9e871b19ca5a3805 (patch) | |
| tree | 8395a9f976b2d27e8b52734f85a2fc130d298cd8 /fs/fs-writeback.c | |
| parent | 1888635532fbbd6be4a4368621085c3a197279f8 (diff) | |
| download | tip-d6e6215907640801b1f407dc9e871b19ca5a3805.tar.gz | |
writeback: Add logging for slow writeback (exceeds sysctl_hung_task_timeout_secs)
When a writeback work lasts for sysctl_hung_task_timeout_secs, we want
to identify that there are tasks waiting for a long time-this helps us
pinpoint potential issues.
Additionally, recording the starting jiffies is useful when debugging a
crashed vmcore.
Signed-off-by: Julian Sun <sunjunchao@bytedance.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/fs-writeback.c')
| -rw-r--r-- | fs/fs-writeback.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 61a980a06ceeb3..e76192d140e3d8 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -201,6 +201,19 @@ static void wb_queue_work(struct bdi_writeback *wb, spin_unlock_irq(&wb->work_lock); } +static bool wb_wait_for_completion_cb(struct wb_completion *done) +{ + unsigned long waited_secs = (jiffies - done->wait_start) / HZ; + + done->progress_stamp = jiffies; + if (waited_secs > sysctl_hung_task_timeout_secs) + pr_info("INFO: The task %s:%d has been waiting for writeback " + "completion for more than %lu seconds.", + current->comm, current->pid, waited_secs); + + return !atomic_read(&done->cnt); +} + /** * wb_wait_for_completion - wait for completion of bdi_writeback_works * @done: target wb_completion @@ -213,9 +226,9 @@ static void wb_queue_work(struct bdi_writeback *wb, */ void wb_wait_for_completion(struct wb_completion *done) { + done->wait_start = jiffies; atomic_dec(&done->cnt); /* put down the initial count */ - wait_event(*done->waitq, - ({ done->progress_stamp = jiffies; !atomic_read(&done->cnt); })); + wait_event(*done->waitq, wb_wait_for_completion_cb(done)); } #ifdef CONFIG_CGROUP_WRITEBACK |
