f2fs: avoid high cpu usage in discard thread
We take very long time to finish generic/476, this is because we will check consistence of all discard entries in global rb tree while traversing all different granularity pending lists, even when the list is empty, in order to avoid that unneeded overhead, we have to skip the check when coming up an empty list. generic/476 time consumption: cost Before patch & w/o consistence check 57s Before patch & w/ consistence check 1426s After patch 78s Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
94b1e10e74
commit
49c60c67d2
|
@ -1204,6 +1204,8 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi,
|
||||||
pend_list = &dcc->pend_list[i];
|
pend_list = &dcc->pend_list[i];
|
||||||
|
|
||||||
mutex_lock(&dcc->cmd_lock);
|
mutex_lock(&dcc->cmd_lock);
|
||||||
|
if (list_empty(pend_list))
|
||||||
|
goto next;
|
||||||
f2fs_bug_on(sbi, !__check_rb_tree_consistence(sbi, &dcc->root));
|
f2fs_bug_on(sbi, !__check_rb_tree_consistence(sbi, &dcc->root));
|
||||||
blk_start_plug(&plug);
|
blk_start_plug(&plug);
|
||||||
list_for_each_entry_safe(dc, tmp, pend_list, list) {
|
list_for_each_entry_safe(dc, tmp, pend_list, list) {
|
||||||
|
@ -1222,6 +1224,7 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
blk_finish_plug(&plug);
|
blk_finish_plug(&plug);
|
||||||
|
next:
|
||||||
mutex_unlock(&dcc->cmd_lock);
|
mutex_unlock(&dcc->cmd_lock);
|
||||||
|
|
||||||
if (iter >= dpolicy->max_requests)
|
if (iter >= dpolicy->max_requests)
|
||||||
|
|
Loading…
Reference in New Issue