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: Fix wakeup and logging timeouts for !DETECT_HUNG_TASK

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.

Guard the wakeup and logging with "#ifdef CONFIG_DETECT_HUNG_TASK" can
eliminate the warning messages. But on the other hand, it is possible
that sysctl_hung_task_timeout_secs be also 0 when DETECT_HUNG_TASK is
enabled. So let's just check the value of sysctl_hung_task_timeout_secs
to decide whether do wakeup and logging.

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>
Link: https://patch.msgid.link/20260203094014.2273240-1-chenhuacai@loongson.cn
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Huacai Chen and committed by
Christian Brauner
9eed043d cb184dd1

+5 -4
+5 -4
fs/fs-writeback.c
··· 198 198 199 199 static bool wb_wait_for_completion_cb(struct wb_completion *done) 200 200 { 201 + unsigned long timeout = sysctl_hung_task_timeout_secs; 201 202 unsigned long waited_secs = (jiffies - done->wait_start) / HZ; 202 203 203 204 done->progress_stamp = jiffies; 204 - if (waited_secs > sysctl_hung_task_timeout_secs) 205 + if (timeout && (waited_secs > timeout)) 205 206 pr_info("INFO: The task %s:%d has been waiting for writeback " 206 207 "completion for more than %lu seconds.", 207 208 current->comm, current->pid, waited_secs); ··· 1956 1955 .range_end = LLONG_MAX, 1957 1956 }; 1958 1957 unsigned long start_time = jiffies; 1958 + unsigned long timeout = sysctl_hung_task_timeout_secs; 1959 1959 long write_chunk; 1960 1960 long total_wrote = 0; /* count both pages and inodes */ 1961 1961 unsigned long dirtied_before = jiffies; ··· 2043 2041 __writeback_single_inode(inode, &wbc); 2044 2042 2045 2043 /* Report progress to inform the hung task detector of the progress. */ 2046 - if (work->done && work->done->progress_stamp && 2047 - (jiffies - work->done->progress_stamp) > HZ * 2048 - sysctl_hung_task_timeout_secs / 2) 2044 + if (work->done && work->done->progress_stamp && timeout && 2045 + (jiffies - work->done->progress_stamp) > HZ * timeout / 2) 2049 2046 wake_up_all(work->done->waitq); 2050 2047 2051 2048 wbc_detach_inode(&wbc);