Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

writeback: Wake up waiting tasks when finishing the writeback of a chunk.

Writing back a large number of pages can take a lots of time.
This issue is exacerbated when the underlying device is slow or
subject to block layer rate limiting, which in turn triggers
unexpected hung task warnings.

We can trigger a wake-up once a chunk has been written back and the
waiting time for writeback exceeds half of
sysctl_hung_task_timeout_secs.
This action allows the hung task detector to be aware of the writeback
progress, thereby eliminating these unexpected hung task warnings.

This patch has passed the xfstests 'check -g quick' test based on ext4,
with no additional failures introduced.

Signed-off-by: Julian Sun <sunjunchao@bytedance.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Julian Sun and committed by
Christian Brauner
18886355 3a866087

+10 -1
+9 -1
fs/fs-writeback.c
··· 14 14 * Additions for address_space-based writeback 15 15 */ 16 16 17 + #include <linux/sched/sysctl.h> 17 18 #include <linux/kernel.h> 18 19 #include <linux/export.h> 19 20 #include <linux/spinlock.h> ··· 214 213 void wb_wait_for_completion(struct wb_completion *done) 215 214 { 216 215 atomic_dec(&done->cnt); /* put down the initial count */ 217 - wait_event(*done->waitq, !atomic_read(&done->cnt)); 216 + wait_event(*done->waitq, 217 + ({ done->progress_stamp = jiffies; !atomic_read(&done->cnt); })); 218 218 } 219 219 220 220 #ifdef CONFIG_CGROUP_WRITEBACK ··· 2015 2013 * evict_inode() will wait so the inode cannot be freed. 2016 2014 */ 2017 2015 __writeback_single_inode(inode, &wbc); 2016 + 2017 + /* Report progress to inform the hung task detector of the progress. */ 2018 + if (work->done && work->done->progress_stamp && 2019 + (jiffies - work->done->progress_stamp) > HZ * 2020 + sysctl_hung_task_timeout_secs / 2) 2021 + wake_up_all(work->done->waitq); 2018 2022 2019 2023 wbc_detach_inode(&wbc); 2020 2024 work->nr_pages -= write_chunk - wbc.nr_to_write;
+1
include/linux/backing-dev-defs.h
··· 63 63 struct wb_completion { 64 64 atomic_t cnt; 65 65 wait_queue_head_t *waitq; 66 + unsigned long progress_stamp; /* The jiffies when slow progress is detected */ 66 67 }; 67 68 68 69 #define __WB_COMPLETION_INIT(_waitq) \