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: 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>

authored by

Julian Sun and committed by
Christian Brauner
d6e62159 18886355

+16 -2
+15 -2
fs/fs-writeback.c
··· 201 201 spin_unlock_irq(&wb->work_lock); 202 202 } 203 203 204 + static bool wb_wait_for_completion_cb(struct wb_completion *done) 205 + { 206 + unsigned long waited_secs = (jiffies - done->wait_start) / HZ; 207 + 208 + done->progress_stamp = jiffies; 209 + if (waited_secs > sysctl_hung_task_timeout_secs) 210 + pr_info("INFO: The task %s:%d has been waiting for writeback " 211 + "completion for more than %lu seconds.", 212 + current->comm, current->pid, waited_secs); 213 + 214 + return !atomic_read(&done->cnt); 215 + } 216 + 204 217 /** 205 218 * wb_wait_for_completion - wait for completion of bdi_writeback_works 206 219 * @done: target wb_completion ··· 226 213 */ 227 214 void wb_wait_for_completion(struct wb_completion *done) 228 215 { 216 + done->wait_start = jiffies; 229 217 atomic_dec(&done->cnt); /* put down the initial count */ 230 - wait_event(*done->waitq, 231 - ({ done->progress_stamp = jiffies; !atomic_read(&done->cnt); })); 218 + wait_event(*done->waitq, wb_wait_for_completion_cb(done)); 232 219 } 233 220 234 221 #ifdef CONFIG_CGROUP_WRITEBACK
+1
include/linux/backing-dev-defs.h
··· 64 64 atomic_t cnt; 65 65 wait_queue_head_t *waitq; 66 66 unsigned long progress_stamp; /* The jiffies when slow progress is detected */ 67 + unsigned long wait_start; /* The jiffies when waiting for the writeback work to finish */ 67 68 }; 68 69 69 70 #define __WB_COMPLETION_INIT(_waitq) \