mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 20:07:46 +09:00
f2fs: fix the periodic wakeups of discard thread
Fix the unnecessary periodic wakeups of discard thread that happens under below two conditions - 1. When f2fs is heavily utilized over 80%, the current discard policy sets the max sleep timeout of discard thread as 50ms (DEF_MIN_DISCARD_ISSUE_TIME). But this is set even when there are no pending discard commands to be issued. 2. In the issue_discard_thread() path when there are no pending discard commands, it fails to reset the wait_ms to max timeout value. Signed-off-by: Sahitya Tummala <stummala@codeaurora.org> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
committed by
Jaegeuk Kim
parent
d731e43cfc
commit
1757598ffa
@@ -1114,6 +1114,8 @@ static void __init_discard_policy(struct f2fs_sb_info *sbi,
|
|||||||
struct discard_policy *dpolicy,
|
struct discard_policy *dpolicy,
|
||||||
int discard_type, unsigned int granularity)
|
int discard_type, unsigned int granularity)
|
||||||
{
|
{
|
||||||
|
struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
|
||||||
|
|
||||||
/* common policy */
|
/* common policy */
|
||||||
dpolicy->type = discard_type;
|
dpolicy->type = discard_type;
|
||||||
dpolicy->sync = true;
|
dpolicy->sync = true;
|
||||||
@@ -1133,7 +1135,9 @@ static void __init_discard_policy(struct f2fs_sb_info *sbi,
|
|||||||
dpolicy->ordered = true;
|
dpolicy->ordered = true;
|
||||||
if (utilization(sbi) > DEF_DISCARD_URGENT_UTIL) {
|
if (utilization(sbi) > DEF_DISCARD_URGENT_UTIL) {
|
||||||
dpolicy->granularity = 1;
|
dpolicy->granularity = 1;
|
||||||
dpolicy->max_interval = DEF_MIN_DISCARD_ISSUE_TIME;
|
if (atomic_read(&dcc->discard_cmd_cnt))
|
||||||
|
dpolicy->max_interval =
|
||||||
|
DEF_MIN_DISCARD_ISSUE_TIME;
|
||||||
}
|
}
|
||||||
} else if (discard_type == DPOLICY_FORCE) {
|
} else if (discard_type == DPOLICY_FORCE) {
|
||||||
dpolicy->min_interval = DEF_MIN_DISCARD_ISSUE_TIME;
|
dpolicy->min_interval = DEF_MIN_DISCARD_ISSUE_TIME;
|
||||||
@@ -1749,8 +1753,15 @@ static int issue_discard_thread(void *data)
|
|||||||
set_freezable();
|
set_freezable();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
__init_discard_policy(sbi, &dpolicy, DPOLICY_BG,
|
if (sbi->gc_mode == GC_URGENT_HIGH ||
|
||||||
dcc->discard_granularity);
|
!f2fs_available_free_memory(sbi, DISCARD_CACHE))
|
||||||
|
__init_discard_policy(sbi, &dpolicy, DPOLICY_FORCE, 1);
|
||||||
|
else
|
||||||
|
__init_discard_policy(sbi, &dpolicy, DPOLICY_BG,
|
||||||
|
dcc->discard_granularity);
|
||||||
|
|
||||||
|
if (!atomic_read(&dcc->discard_cmd_cnt))
|
||||||
|
wait_ms = dpolicy.max_interval;
|
||||||
|
|
||||||
wait_event_interruptible_timeout(*q,
|
wait_event_interruptible_timeout(*q,
|
||||||
kthread_should_stop() || freezing(current) ||
|
kthread_should_stop() || freezing(current) ||
|
||||||
@@ -1777,10 +1788,6 @@ static int issue_discard_thread(void *data)
|
|||||||
if (!atomic_read(&dcc->discard_cmd_cnt))
|
if (!atomic_read(&dcc->discard_cmd_cnt))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (sbi->gc_mode == GC_URGENT_HIGH ||
|
|
||||||
!f2fs_available_free_memory(sbi, DISCARD_CACHE))
|
|
||||||
__init_discard_policy(sbi, &dpolicy, DPOLICY_FORCE, 1);
|
|
||||||
|
|
||||||
sb_start_intwrite(sbi->sb);
|
sb_start_intwrite(sbi->sb);
|
||||||
|
|
||||||
issued = __issue_discard_cmd(sbi, &dpolicy);
|
issued = __issue_discard_cmd(sbi, &dpolicy);
|
||||||
|
|||||||
Reference in New Issue
Block a user