* [PATCH] writeback: Fix wakeup and logging timeouts for !DETECT_HUNG_TASK
@ 2026-01-31 9:07 Huacai Chen
2026-02-02 2:27 ` Julian Sun
2026-02-02 12:49 ` Jan Kara
0 siblings, 2 replies; 4+ messages in thread
From: Huacai Chen @ 2026-01-31 9:07 UTC (permalink / raw)
To: Huacai Chen, Alexander Viro, Christian Brauner
Cc: Jan Kara, linux-fsdevel, Xuefeng Li, Julian Sun, linux-kernel,
Huacai Chen
Recent changes of fs-writeback cause such warnings if DETECT_HUNG_TASK
is not enabled:
INFO: The task sync:1342 has been waiting for writeback completion for more than 1 seconds.
The reason is sysctl_hung_task_timeout_secs is 0 when DETECT_HUNG_TASK
is not enabled, then it causes the warning message even if the writeback
lasts for only one second.
I believe the wakeup and logging is also useful for !DETECT_HUNG_TASK,
so I don't want to disable them completely. As DEFAULT_HUNG_TASK_TIMEOUT
is 120 seconds, so for the !DETECT_HUNG_TASK case let's use 120 seconds
instead of sysctl_hung_task_timeout_secs.
Fixes: 1888635532fb ("writeback: Wake up waiting tasks when finishing the writeback of a chunk.")
Fixes: d6e621590764 ("writeback: Add logging for slow writeback (exceeds sysctl_hung_task_timeout_secs)")
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
fs/fs-writeback.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 5444fc706ac7..847e46f0e019 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -198,10 +198,15 @@ static void wb_queue_work(struct bdi_writeback *wb,
static bool wb_wait_for_completion_cb(struct wb_completion *done)
{
+#ifndef CONFIG_DETECT_HUNG_TASK
+ unsigned long hung_secs = 120;
+#else
+ unsigned long hung_secs = sysctl_hung_task_timeout_secs;
+#endif
unsigned long waited_secs = (jiffies - done->wait_start) / HZ;
done->progress_stamp = jiffies;
- if (waited_secs > sysctl_hung_task_timeout_secs)
+ if (waited_secs > hung_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);
@@ -1947,6 +1952,11 @@ static long writeback_sb_inodes(struct super_block *sb,
long write_chunk;
long total_wrote = 0; /* count both pages and inodes */
unsigned long dirtied_before = jiffies;
+#ifndef CONFIG_DETECT_HUNG_TASK
+ unsigned long hung_secs = 120;
+#else
+ unsigned long hung_secs = sysctl_hung_task_timeout_secs;
+#endif
if (work->for_kupdate)
dirtied_before = jiffies -
@@ -2031,8 +2041,7 @@ static long writeback_sb_inodes(struct super_block *sb,
/* Report progress to inform the hung task detector of the progress. */
if (work->done && work->done->progress_stamp &&
- (jiffies - work->done->progress_stamp) > HZ *
- sysctl_hung_task_timeout_secs / 2)
+ (jiffies - work->done->progress_stamp) > HZ * hung_secs / 2)
wake_up_all(work->done->waitq);
wbc_detach_inode(&wbc);
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] writeback: Fix wakeup and logging timeouts for !DETECT_HUNG_TASK
2026-01-31 9:07 [PATCH] writeback: Fix wakeup and logging timeouts for !DETECT_HUNG_TASK Huacai Chen
@ 2026-02-02 2:27 ` Julian Sun
2026-02-02 12:49 ` Jan Kara
1 sibling, 0 replies; 4+ messages in thread
From: Julian Sun @ 2026-02-02 2:27 UTC (permalink / raw)
To: Huacai Chen, Huacai Chen, Alexander Viro, Christian Brauner
Cc: Jan Kara, linux-fsdevel, Xuefeng Li, linux-kernel
On 1/31/26 5:07 PM, Huacai Chen wrote:
> Recent changes of fs-writeback cause such warnings if DETECT_HUNG_TASK
> is not enabled:
>
> INFO: The task sync:1342 has been waiting for writeback completion for more than 1 seconds.
>
> The reason is sysctl_hung_task_timeout_secs is 0 when DETECT_HUNG_TASK
> is not enabled, then it causes the warning message even if the writeback
> lasts for only one second.
>
> I believe the wakeup and logging is also useful for !DETECT_HUNG_TASK,
> so I don't want to disable them completely. As DEFAULT_HUNG_TASK_TIMEOUT
> is 120 seconds, so for the !DETECT_HUNG_TASK case let's use 120 seconds
> instead of sysctl_hung_task_timeout_secs.
>
> Fixes: 1888635532fb ("writeback: Wake up waiting tasks when finishing the writeback of a chunk.")
> Fixes: d6e621590764 ("writeback: Add logging for slow writeback (exceeds sysctl_hung_task_timeout_secs)")
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> ---
> fs/fs-writeback.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> index 5444fc706ac7..847e46f0e019 100644
> --- a/fs/fs-writeback.c
> +++ b/fs/fs-writeback.c
> @@ -198,10 +198,15 @@ static void wb_queue_work(struct bdi_writeback *wb,
>
> static bool wb_wait_for_completion_cb(struct wb_completion *done)
> {
> +#ifndef CONFIG_DETECT_HUNG_TASK
> + unsigned long hung_secs = 120;
> +#else
> + unsigned long hung_secs = sysctl_hung_task_timeout_secs;
> +#endif
> unsigned long waited_secs = (jiffies - done->wait_start) / HZ;
>
> done->progress_stamp = jiffies;
> - if (waited_secs > sysctl_hung_task_timeout_secs)
> + if (waited_secs > hung_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);
> @@ -1947,6 +1952,11 @@ static long writeback_sb_inodes(struct super_block *sb,
> long write_chunk;
> long total_wrote = 0; /* count both pages and inodes */
> unsigned long dirtied_before = jiffies;
> +#ifndef CONFIG_DETECT_HUNG_TASK
> + unsigned long hung_secs = 120;
> +#else
> + unsigned long hung_secs = sysctl_hung_task_timeout_secs;
> +#endif
>
> if (work->for_kupdate)
> dirtied_before = jiffies -
> @@ -2031,8 +2041,7 @@ static long writeback_sb_inodes(struct super_block *sb,
>
> /* Report progress to inform the hung task detector of the progress. */
> if (work->done && work->done->progress_stamp &&
> - (jiffies - work->done->progress_stamp) > HZ *
> - sysctl_hung_task_timeout_secs / 2)
> + (jiffies - work->done->progress_stamp) > HZ * hung_secs / 2)
> wake_up_all(work->done->waitq);
>
> wbc_detach_inode(&wbc);
Thanks for the patch, looks good to me.
Reviewed-by: Julian Sun <sunjunchao@bytedance.com>
--
Julian Sun <sunjunchao@bytedance.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] writeback: Fix wakeup and logging timeouts for !DETECT_HUNG_TASK
2026-01-31 9:07 [PATCH] writeback: Fix wakeup and logging timeouts for !DETECT_HUNG_TASK Huacai Chen
2026-02-02 2:27 ` Julian Sun
@ 2026-02-02 12:49 ` Jan Kara
2026-02-03 2:46 ` Huacai Chen
1 sibling, 1 reply; 4+ messages in thread
From: Jan Kara @ 2026-02-02 12:49 UTC (permalink / raw)
To: Huacai Chen
Cc: Huacai Chen, Alexander Viro, Christian Brauner, Jan Kara,
linux-fsdevel, Xuefeng Li, Julian Sun, linux-kernel
On Sat 31-01-26 17:07:24, Huacai Chen wrote:
> Recent changes of fs-writeback cause such warnings if DETECT_HUNG_TASK
> is not enabled:
>
> INFO: The task sync:1342 has been waiting for writeback completion for more than 1 seconds.
>
> The reason is sysctl_hung_task_timeout_secs is 0 when DETECT_HUNG_TASK
> is not enabled, then it causes the warning message even if the writeback
> lasts for only one second.
>
> I believe the wakeup and logging is also useful for !DETECT_HUNG_TASK,
> so I don't want to disable them completely. As DEFAULT_HUNG_TASK_TIMEOUT
> is 120 seconds, so for the !DETECT_HUNG_TASK case let's use 120 seconds
> instead of sysctl_hung_task_timeout_secs.
>
> Fixes: 1888635532fb ("writeback: Wake up waiting tasks when finishing the writeback of a chunk.")
> Fixes: d6e621590764 ("writeback: Add logging for slow writeback (exceeds sysctl_hung_task_timeout_secs)")
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Thanks for the patch! I think if !CONFIG_DETECT_HUNG_TASK, we should just
not print the message from wb_wait_for_completion_cb() as well. After all
it's also a type of hung task detection and user explicitely disabled that.
Also there would be no way to tune the timeout so there are high chances
120s will be too much for somebody and too few for somebody else...
> +#ifndef CONFIG_DETECT_HUNG_TASK
> + unsigned long hung_secs = 120;
> +#else
> + unsigned long hung_secs = sysctl_hung_task_timeout_secs;
> +#endif
>
> if (work->for_kupdate)
> dirtied_before = jiffies -
> @@ -2031,8 +2041,7 @@ static long writeback_sb_inodes(struct super_block *sb,
>
> /* Report progress to inform the hung task detector of the progress. */
> if (work->done && work->done->progress_stamp &&
> - (jiffies - work->done->progress_stamp) > HZ *
> - sysctl_hung_task_timeout_secs / 2)
> + (jiffies - work->done->progress_stamp) > HZ * hung_secs / 2)
> wake_up_all(work->done->waitq);
>
> wbc_detach_inode(&wbc);
Similarly here I'd just #ifdef out the wakeup when !CONFIG_DETECT_HUNG_TASK.
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] writeback: Fix wakeup and logging timeouts for !DETECT_HUNG_TASK
2026-02-02 12:49 ` Jan Kara
@ 2026-02-03 2:46 ` Huacai Chen
0 siblings, 0 replies; 4+ messages in thread
From: Huacai Chen @ 2026-02-03 2:46 UTC (permalink / raw)
To: Jan Kara
Cc: Huacai Chen, Alexander Viro, Christian Brauner, linux-fsdevel,
Xuefeng Li, Julian Sun, linux-kernel
On Mon, Feb 2, 2026 at 8:49 PM Jan Kara <jack@suse.cz> wrote:
>
> On Sat 31-01-26 17:07:24, Huacai Chen wrote:
> > Recent changes of fs-writeback cause such warnings if DETECT_HUNG_TASK
> > is not enabled:
> >
> > INFO: The task sync:1342 has been waiting for writeback completion for more than 1 seconds.
> >
> > The reason is sysctl_hung_task_timeout_secs is 0 when DETECT_HUNG_TASK
> > is not enabled, then it causes the warning message even if the writeback
> > lasts for only one second.
> >
> > I believe the wakeup and logging is also useful for !DETECT_HUNG_TASK,
> > so I don't want to disable them completely. As DEFAULT_HUNG_TASK_TIMEOUT
> > is 120 seconds, so for the !DETECT_HUNG_TASK case let's use 120 seconds
> > instead of sysctl_hung_task_timeout_secs.
> >
> > Fixes: 1888635532fb ("writeback: Wake up waiting tasks when finishing the writeback of a chunk.")
> > Fixes: d6e621590764 ("writeback: Add logging for slow writeback (exceeds sysctl_hung_task_timeout_secs)")
> > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
>
> Thanks for the patch! I think if !CONFIG_DETECT_HUNG_TASK, we should just
> not print the message from wb_wait_for_completion_cb() as well. After all
> it's also a type of hung task detection and user explicitely disabled that.
> Also there would be no way to tune the timeout so there are high chances
> 120s will be too much for somebody and too few for somebody else...
OK, make sense.
Huacai
>
> > +#ifndef CONFIG_DETECT_HUNG_TASK
> > + unsigned long hung_secs = 120;
> > +#else
> > + unsigned long hung_secs = sysctl_hung_task_timeout_secs;
> > +#endif
> >
> > if (work->for_kupdate)
> > dirtied_before = jiffies -
> > @@ -2031,8 +2041,7 @@ static long writeback_sb_inodes(struct super_block *sb,
> >
> > /* Report progress to inform the hung task detector of the progress. */
> > if (work->done && work->done->progress_stamp &&
> > - (jiffies - work->done->progress_stamp) > HZ *
> > - sysctl_hung_task_timeout_secs / 2)
> > + (jiffies - work->done->progress_stamp) > HZ * hung_secs / 2)
> > wake_up_all(work->done->waitq);
> >
> > wbc_detach_inode(&wbc);
>
> Similarly here I'd just #ifdef out the wakeup when !CONFIG_DETECT_HUNG_TASK.
>
> Honza
> --
> Jan Kara <jack@suse.com>
> SUSE Labs, CR
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-02-03 2:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-31 9:07 [PATCH] writeback: Fix wakeup and logging timeouts for !DETECT_HUNG_TASK Huacai Chen
2026-02-02 2:27 ` Julian Sun
2026-02-02 12:49 ` Jan Kara
2026-02-03 2:46 ` Huacai Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome