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: trace elapsed time for cp_global_sem lock

Use f2fs_{down,up}_write_trace for cp_global_sem to trace lock elapsed time.

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
ce9fe67c e605302c

+16 -10
+6 -4
fs/f2fs/checkpoint.c
··· 513 513 struct writeback_control *wbc) 514 514 { 515 515 struct f2fs_sb_info *sbi = F2FS_M_SB(mapping); 516 + struct f2fs_lock_context lc; 516 517 long diff, written; 517 518 518 519 if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING))) ··· 526 525 goto skip_write; 527 526 528 527 /* if locked failed, cp will flush dirty pages instead */ 529 - if (!f2fs_down_write_trylock(&sbi->cp_global_sem)) 528 + if (!f2fs_down_write_trylock_trace(&sbi->cp_global_sem, &lc)) 530 529 goto skip_write; 531 530 532 531 trace_f2fs_writepages(mapping->host, wbc, META); 533 532 diff = nr_pages_to_write(sbi, META, wbc); 534 533 written = f2fs_sync_meta_pages(sbi, META, wbc->nr_to_write, FS_META_IO); 535 - f2fs_up_write(&sbi->cp_global_sem); 534 + f2fs_up_write_trace(&sbi->cp_global_sem, &lc); 536 535 wbc->nr_to_write = max((long)0, wbc->nr_to_write - written - diff); 537 536 return 0; 538 537 ··· 1781 1780 int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) 1782 1781 { 1783 1782 struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); 1783 + struct f2fs_lock_context lc; 1784 1784 unsigned long long ckpt_ver; 1785 1785 int err = 0; 1786 1786 ··· 1796 1794 f2fs_warn(sbi, "Start checkpoint disabled!"); 1797 1795 } 1798 1796 if (cpc->reason != CP_RESIZE) 1799 - f2fs_down_write(&sbi->cp_global_sem); 1797 + f2fs_down_write_trace(&sbi->cp_global_sem, &lc); 1800 1798 1801 1799 stat_cp_time(cpc, CP_TIME_LOCK); 1802 1800 ··· 1886 1884 trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, CP_PHASE_FINISH_CHECKPOINT); 1887 1885 out: 1888 1886 if (cpc->reason != CP_RESIZE) 1889 - f2fs_up_write(&sbi->cp_global_sem); 1887 + f2fs_up_write_trace(&sbi->cp_global_sem, &lc); 1890 1888 return err; 1891 1889 } 1892 1890
+1
fs/f2fs/f2fs.h
··· 179 179 LOCK_NAME_NODE_CHANGE, 180 180 LOCK_NAME_NODE_WRITE, 181 181 LOCK_NAME_GC_LOCK, 182 + LOCK_NAME_CP_GLOBAL, 182 183 }; 183 184 184 185 /*
+3 -2
fs/f2fs/gc.c
··· 2267 2267 struct cp_control cpc = { CP_RESIZE, 0, 0, 0 }; 2268 2268 struct f2fs_lock_context lc; 2269 2269 struct f2fs_lock_context glc; 2270 + struct f2fs_lock_context clc; 2270 2271 unsigned int secs; 2271 2272 int err = 0; 2272 2273 __u32 rem; ··· 2351 2350 } 2352 2351 2353 2352 f2fs_down_write_trace(&sbi->gc_lock, &glc); 2354 - f2fs_down_write(&sbi->cp_global_sem); 2353 + f2fs_down_write_trace(&sbi->cp_global_sem, &clc); 2355 2354 2356 2355 spin_lock(&sbi->stat_lock); 2357 2356 if (shrunk_blocks + valid_user_blocks(sbi) + ··· 2399 2398 spin_unlock(&sbi->stat_lock); 2400 2399 } 2401 2400 out_err: 2402 - f2fs_up_write(&sbi->cp_global_sem); 2401 + f2fs_up_write_trace(&sbi->cp_global_sem, &clc); 2403 2402 f2fs_up_write_trace(&sbi->gc_lock, &glc); 2404 2403 thaw_super(sbi->sb, FREEZE_HOLDER_KERNEL, NULL); 2405 2404 return err;
+3 -2
fs/f2fs/recovery.c
··· 875 875 LIST_HEAD(inode_list); 876 876 LIST_HEAD(tmp_inode_list); 877 877 LIST_HEAD(dir_list); 878 + struct f2fs_lock_context lc; 878 879 int err; 879 880 int ret = 0; 880 881 unsigned long s_flags = sbi->sb->s_flags; ··· 889 888 f2fs_info(sbi, "recover fsync data on readonly fs"); 890 889 891 890 /* prevent checkpoint */ 892 - f2fs_down_write(&sbi->cp_global_sem); 891 + f2fs_down_write_trace(&sbi->cp_global_sem, &lc); 893 892 894 893 /* step #1: find fsynced inode numbers */ 895 894 err = find_fsync_dnodes(sbi, &inode_list, check_only, &new_inode); ··· 933 932 if (!err) 934 933 clear_sbi_flag(sbi, SBI_POR_DOING); 935 934 936 - f2fs_up_write(&sbi->cp_global_sem); 935 + f2fs_up_write_trace(&sbi->cp_global_sem, &lc); 937 936 938 937 /* let's drop all the directory inodes for clean checkpoint */ 939 938 destroy_fsync_dnodes(&dir_list, err);
+1 -1
fs/f2fs/super.c
··· 4897 4897 /* initialize locks within allocated memory */ 4898 4898 init_f2fs_rwsem_trace(&sbi->gc_lock, sbi, LOCK_NAME_GC_LOCK); 4899 4899 mutex_init(&sbi->writepages); 4900 - init_f2fs_rwsem(&sbi->cp_global_sem); 4900 + init_f2fs_rwsem_trace(&sbi->cp_global_sem, sbi, LOCK_NAME_CP_GLOBAL); 4901 4901 init_f2fs_rwsem_trace(&sbi->node_write, sbi, LOCK_NAME_NODE_WRITE); 4902 4902 init_f2fs_rwsem_trace(&sbi->node_change, sbi, LOCK_NAME_NODE_CHANGE); 4903 4903 spin_lock_init(&sbi->stat_lock);
+2 -1
include/trace/events/f2fs.h
··· 189 189 { LOCK_NAME_CP_RWSEM, "cp_rwsem" }, \ 190 190 { LOCK_NAME_NODE_CHANGE, "node_change" }, \ 191 191 { LOCK_NAME_NODE_WRITE, "node_write" }, \ 192 - { LOCK_NAME_GC_LOCK, "gc_lock" }) 192 + { LOCK_NAME_GC_LOCK, "gc_lock" }, \ 193 + { LOCK_NAME_CP_GLOBAL, "cp_global" }) 193 194 194 195 struct f2fs_sb_info; 195 196 struct f2fs_io_info;