f2fs: add gc_boost_gc_greedy sysfs node
PATCH 1/1 f2fs: add gc_boost_gc_greedy sysfs node
From: Daeho Jeong <[email protected]>
Add this to control GC algorithm for boost GC.
Signed-off-by Daeho Jeong <[email protected]>
--- Documentation/ABI/testing/sysfs-fs-f2fs | 6 ++++++ fs/f2fs/gc.c | 3 ++- fs/f2fs/gc.h | 1 + fs/f2fs/sysfs.c | 7 +++++++ 4 files changed, 16 insertions(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-fs-f2fs +6 -0
@@ -869,3 +869,9 @@ Description: Set a multiplier for the background GC migration window when F2FS G boosted. Default: 5 +What: /sys/fs/f2fs/<disk>/gc_boost_gc_greedy +Date: June 2025 +Contact: "Daeho Jeong" <[email protected]> +Description: Control GC algorithm for boost GC. 0: cost benefit, 1: greedy + Default: 1 +
fs/f2fs/gc.c +2 -1
@@ -141,7 +141,7 @@ static int gc_thread_func(void *data) FOREGROUND : BACKGROUND); sync_mode = (F2FS_OPTION (sbi).bggc_mode ==BGGC_MODE_SYNC ) || - gc_control.one_time; + (gc_control.one_time && gc_th->boost_gc_greedy);/* foreground GC was been triggered via f2fs_balance_fs() */ if (foreground)
@@ -198,6 +198,7 @@ int f2fs_start_gc_thread(struct f2fs_sb_info *sbi) gc_th->urgent_sleep_time =DEF_GC_THREAD_URGENT_SLEEP_TIME ; gc_th->valid_thresh_ratio =DEF_GC_THREAD_VALID_THRESH_RATIO ; gc_th->boost_gc_multiple =BOOST_GC_MULTIPLE ; + gc_th->boost_gc_greedy =1 ;if (f2fs_sb_has_blkzoned (sbi)) { gc_th->min_sleep_time =DEF_GC_THREAD_MIN_SLEEP_TIME_ZONED ;
fs/f2fs/gc.h +1 -0
@@ -69,6 +69,7 @@ struct f2fs_gc_kthread {unsigned int boost_zoned_gc_percent;unsigned int valid_thresh_ratio;unsigned int boost_gc_multiple; +unsigned int boost_gc_greedy; };struct gc_inode_list {
fs/f2fs/sysfs.c +7 -0
@@ -824,6 +824,11 @@ static ssize_t __sbi_store(struct f2fs_attr *a,return count; } +if (!strcmp (a->attr.name,"gc_boost_gc_greedy" )) { +if (t >1 ) +return -EINVAL ; + } + *ui = (unsigned int )t;return count;
@@ -1051,6 +1056,7 @@ GC_THREAD_RW_ATTR(gc_no_zoned_gc_percent, no_zoned_gc_percent);GC_THREAD_RW_ATTR (gc_boost_zoned_gc_percent, boost_zoned_gc_percent);GC_THREAD_RW_ATTR (gc_valid_thresh_ratio, valid_thresh_ratio);GC_THREAD_RW_ATTR (gc_boost_gc_multiple, boost_gc_multiple); +GC_THREAD_RW_ATTR (gc_boost_gc_greedy, boost_gc_greedy);/* SM_INFO ATTR */ SM_INFO_RW_ATTR (reclaim_segments, rec_prefree_segments);
@@ -1222,6 +1228,7 @@ static struct attribute *f2fs_attrs[] = {ATTR_LIST (gc_boost_zoned_gc_percent),ATTR_LIST (gc_valid_thresh_ratio),ATTR_LIST (gc_boost_gc_multiple), +ATTR_LIST (gc_boost_gc_greedy),ATTR_LIST (gc_idle),ATTR_LIST (gc_urgent), ATTR_LIST(reclaim_segments),
Signature · 1 line
2.50.0.rc0.604.gd4ff7b7c86-goog
Chao Yu
maintainerQuoted 40 lines · Daeho Jeong
From: Daeho Jeong <[email protected]>
Add this to control GC algorithm for boost GC.
Signed-off-by Daeho Jeong <[email protected]>--- Documentation/ABI/testing/sysfs-fs-f2fs | 6 ++++++ fs/f2fs/gc.c | 3 ++- fs/f2fs/gc.h | 1 + fs/f2fs/sysfs.c | 7 +++++++ 4 files changed, 16 insertions(+), 1 deletion(-)Documentation/ABI/testing/sysfs-fs-f2fs +6
-0@@ -869,3 +869,9 @@ Description: Set a multiplier for the background GC migration window when F2FS G boosted. Default: 5 +What: /sys/fs/f2fs/<disk>/gc_boost_gc_greedy +Date: June 2025 +Contact: "Daeho Jeong" <[email protected]> +Description: Control GC algorithm for boost GC. 0: cost benefit, 1: greedy + Default: 1 +fs/f2fs/gc.c +1
-1@@ -141,7 +141,7 @@ static int gc_thread_func(void *data) FOREGROUND : BACKGROUND); sync_mode = (F2FS_OPTION (sbi).bggc_mode ==BGGC_MODE_SYNC ) || - gc_control.one_time; + (gc_control.one_time && gc_th->boost_gc_greedy);/* foreground GC was been triggered via f2fs_balance_fs() */ if (foreground)
fs/f2fs/gc.c int f2fs_start_gc_thread(struct f2fs_sb_info *sbi) · line 201
Quoted 4 lines
fs/f2fs/gc.c +1
-0@@ -198,6 +198,7 @@ int f2fs_start_gc_thread(struct f2fs_sb_info *sbi) gc_th->urgent_sleep_time =DEF_GC_THREAD_URGENT_SLEEP_TIME ; gc_th->valid_thresh_ratio =DEF_GC_THREAD_VALID_THRESH_RATIO ; gc_th->boost_gc_multiple =BOOST_GC_MULTIPLE ; + gc_th->boost_gc_greedy =1 ;
How about using GC_GREEDY macro instead?
Quoted 20 lines
fs/f2fs/gc.c +0
-0if (f2fs_sb_has_blkzoned (sbi)) { gc_th->min_sleep_time =DEF_GC_THREAD_MIN_SLEEP_TIME_ZONED ;fs/f2fs/gc.h +1
-0@@ -69,6 +69,7 @@ struct f2fs_gc_kthread {unsigned int boost_zoned_gc_percent;unsigned int valid_thresh_ratio;unsigned int boost_gc_multiple; +unsigned int boost_gc_greedy; };struct gc_inode_list {fs/f2fs/sysfs.c +0
-0
fs/f2fs/sysfs.c static ssize_t __sbi_store(struct f2fs_attr *a, · line 828
Quoted 5 lines
fs/f2fs/sysfs.c +2
-0@@ -824,6 +824,11 @@ static ssize_t __sbi_store(struct f2fs_attr *a,return count; } +if (!strcmp (a->attr.name,"gc_boost_gc_greedy" )) { +if (t >1 )
Ditto,
Thanks,
Quoted 22 lines
fs/f2fs/sysfs.c +5
-0+return -EINVAL ; + } + *ui = (unsigned int )t;return count;@@ -1051,6 +1056,7 @@ GC_THREAD_RW_ATTR(gc_no_zoned_gc_percent, no_zoned_gc_percent);GC_THREAD_RW_ATTR (gc_boost_zoned_gc_percent, boost_zoned_gc_percent);GC_THREAD_RW_ATTR (gc_valid_thresh_ratio, valid_thresh_ratio);GC_THREAD_RW_ATTR (gc_boost_gc_multiple, boost_gc_multiple); +GC_THREAD_RW_ATTR (gc_boost_gc_greedy, boost_gc_greedy);/* SM_INFO ATTR */ SM_INFO_RW_ATTR (reclaim_segments, rec_prefree_segments);@@ -1222,6 +1228,7 @@ static struct attribute *f2fs_attrs[] = {ATTR_LIST (gc_boost_zoned_gc_percent),ATTR_LIST (gc_valid_thresh_ratio),ATTR_LIST (gc_boost_gc_multiple), +ATTR_LIST (gc_boost_gc_greedy),ATTR_LIST (gc_idle),ATTR_LIST (gc_urgent), ATTR_LIST(reclaim_segments),