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.

f2fs: introduce f2fs_schedule_timeout()

In f2fs retry logic, we will call f2fs_io_schedule_timeout() to sleep as
uninterruptible state (waiting for IO) for a while, however, in several
paths below, we are not blocked by IO:
- f2fs_write_single_data_page() return -EAGAIN due to racing on cp_rwsem.
- f2fs_flush_device_cache() failed to submit preflush command.
- __issue_discard_cmd_range() sleeps periodically in between two in batch
discard submissions.

So, in order to reveal state of task more accurate, let's introduce
f2fs_schedule_timeout() and call it in above paths in where we are waiting
for non-IO reasons.

Then we can get real reason of uninterruptible sleep for a thread in
tracepoint, perfetto, etc.

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

authored by

Chao Yu and committed by
Jaegeuk Kim
76e780d8 30a84966

+24 -16
+2 -2
fs/f2fs/checkpoint.c
··· 1318 1318 f2fs_submit_merged_write(sbi, DATA); 1319 1319 1320 1320 prepare_to_wait(&sbi->cp_wait, &wait, TASK_UNINTERRUPTIBLE); 1321 - io_schedule_timeout(DEFAULT_IO_TIMEOUT); 1321 + io_schedule_timeout(DEFAULT_SCHEDULE_TIMEOUT); 1322 1322 } 1323 1323 finish_wait(&sbi->cp_wait, &wait); 1324 1324 } ··· 1974 1974 1975 1975 /* Let's wait for the previous dispatched checkpoint. */ 1976 1976 while (atomic_read(&cprc->queued_ckpt)) 1977 - io_schedule_timeout(DEFAULT_IO_TIMEOUT); 1977 + io_schedule_timeout(DEFAULT_SCHEDULE_TIMEOUT); 1978 1978 } 1979 1979 1980 1980 void f2fs_init_ckpt_req_control(struct f2fs_sb_info *sbi)
+2 -2
fs/f2fs/compress.c
··· 1057 1057 f2fs_submit_merged_write(F2FS_I_SB(cc->inode), DATA); 1058 1058 while (atomic_read(&cic->pending_pages) != 1059 1059 (cc->valid_nr_cpages - submitted + 1)) 1060 - f2fs_io_schedule_timeout(DEFAULT_IO_TIMEOUT); 1060 + f2fs_io_schedule_timeout(DEFAULT_SCHEDULE_TIMEOUT); 1061 1061 } 1062 1062 1063 1063 /* Cancel writeback and stay locked. */ ··· 1574 1574 */ 1575 1575 if (IS_NOQUOTA(cc->inode)) 1576 1576 goto out; 1577 - f2fs_io_schedule_timeout(DEFAULT_IO_TIMEOUT); 1577 + f2fs_schedule_timeout(DEFAULT_SCHEDULE_TIMEOUT); 1578 1578 goto retry_write; 1579 1579 } 1580 1580 goto out;
+2 -2
fs/f2fs/data.c
··· 3141 3141 } else if (ret == -EAGAIN) { 3142 3142 ret = 0; 3143 3143 if (wbc->sync_mode == WB_SYNC_ALL) { 3144 - f2fs_io_schedule_timeout( 3145 - DEFAULT_IO_TIMEOUT); 3144 + f2fs_schedule_timeout( 3145 + DEFAULT_SCHEDULE_TIMEOUT); 3146 3146 goto retry_write; 3147 3147 } 3148 3148 goto next;
+15 -7
fs/f2fs/f2fs.h
··· 656 656 657 657 #define DEFAULT_RETRY_IO_COUNT 8 /* maximum retry read IO or flush count */ 658 658 659 - /* congestion wait timeout value, default: 20ms */ 660 - #define DEFAULT_IO_TIMEOUT (msecs_to_jiffies(20)) 659 + /* IO/non-IO congestion wait timeout value, default: 20ms */ 660 + #define DEFAULT_SCHEDULE_TIMEOUT (msecs_to_jiffies(20)) 661 661 662 662 /* timeout value injected, default: 1000ms */ 663 663 #define DEFAULT_FAULT_TIMEOUT (msecs_to_jiffies(1000)) ··· 4908 4908 return F2FS_OPTION(sbi).discard_unit == DISCARD_UNIT_BLOCK; 4909 4909 } 4910 4910 4911 - static inline void f2fs_io_schedule_timeout(long timeout) 4911 + static inline void __f2fs_schedule_timeout(long timeout, bool io) 4912 4912 { 4913 4913 set_current_state(TASK_UNINTERRUPTIBLE); 4914 - io_schedule_timeout(timeout); 4914 + if (io) 4915 + io_schedule_timeout(timeout); 4916 + else 4917 + schedule_timeout(timeout); 4915 4918 } 4919 + 4920 + #define f2fs_io_schedule_timeout(timeout) \ 4921 + __f2fs_schedule_timeout(timeout, true) 4922 + #define f2fs_schedule_timeout(timeout) \ 4923 + __f2fs_schedule_timeout(timeout, false) 4916 4924 4917 4925 static inline void f2fs_io_schedule_timeout_killable(long timeout) 4918 4926 { ··· 4928 4920 if (fatal_signal_pending(current)) 4929 4921 return; 4930 4922 set_current_state(TASK_UNINTERRUPTIBLE); 4931 - io_schedule_timeout(DEFAULT_IO_TIMEOUT); 4932 - if (timeout <= DEFAULT_IO_TIMEOUT) 4923 + io_schedule_timeout(DEFAULT_SCHEDULE_TIMEOUT); 4924 + if (timeout <= DEFAULT_SCHEDULE_TIMEOUT) 4933 4925 return; 4934 - timeout -= DEFAULT_IO_TIMEOUT; 4926 + timeout -= DEFAULT_SCHEDULE_TIMEOUT; 4935 4927 } 4936 4928 } 4937 4929
+2 -2
fs/f2fs/segment.c
··· 750 750 do { 751 751 ret = __submit_flush_wait(sbi, FDEV(i).bdev); 752 752 if (ret) 753 - f2fs_io_schedule_timeout(DEFAULT_IO_TIMEOUT); 753 + f2fs_schedule_timeout(DEFAULT_SCHEDULE_TIMEOUT); 754 754 } while (ret && --count); 755 755 756 756 if (ret) { ··· 3471 3471 blk_finish_plug(&plug); 3472 3472 mutex_unlock(&dcc->cmd_lock); 3473 3473 trimmed += __wait_all_discard_cmd(sbi, NULL); 3474 - f2fs_io_schedule_timeout(DEFAULT_IO_TIMEOUT); 3474 + f2fs_schedule_timeout(DEFAULT_SCHEDULE_TIMEOUT); 3475 3475 goto next; 3476 3476 } 3477 3477 skip:
+1 -1
fs/f2fs/super.c
··· 2652 2652 /* we should flush all the data to keep data consistency */ 2653 2653 while (get_pages(sbi, F2FS_DIRTY_DATA)) { 2654 2654 writeback_inodes_sb_nr(sbi->sb, nr_pages, WB_REASON_SYNC); 2655 - f2fs_io_schedule_timeout(DEFAULT_IO_TIMEOUT); 2655 + f2fs_io_schedule_timeout(DEFAULT_SCHEDULE_TIMEOUT); 2656 2656 2657 2657 if (f2fs_time_over(sbi, ENABLE_TIME)) 2658 2658 break;