linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH v2] f2fs: add gc_boost_gc_greedy sysfs node
@ 2025-07-18 21:50 Daeho Jeong
  2025-07-22  3:24 ` Chao Yu via Linux-f2fs-devel
  0 siblings, 1 reply; 3+ messages in thread
From: Daeho Jeong @ 2025-07-18 21:50 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong

From: Daeho Jeong <daehojeong@google.com>

Add this to control GC algorithm for boost GC.

Signed-off-by: Daeho Jeong <daehojeong@google.com>
---
v2: use GC_GREEDY instead of 1
---
 Documentation/ABI/testing/sysfs-fs-f2fs |  8 +++++++-
 fs/f2fs/gc.c                            |  3 ++-
 fs/f2fs/gc.h                            |  1 +
 fs/f2fs/sysfs.c                         | 16 ++++++++++++++++
 4 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
index 931c1f63aa2e..2158055cd9d1 100644
--- a/Documentation/ABI/testing/sysfs-fs-f2fs
+++ b/Documentation/ABI/testing/sysfs-fs-f2fs
@@ -866,6 +866,12 @@ What:		/sys/fs/f2fs/<disk>/gc_boost_gc_multiple
 Date:		June 2025
 Contact:	"Daeho Jeong" <daehojeong@google.com>
 Description:	Set a multiplier for the background GC migration window when F2FS GC is
-		boosted.
+		boosted. the range should be from 1 to the segment count in a section.
 		Default: 5
 
+What:		/sys/fs/f2fs/<disk>/gc_boost_gc_greedy
+Date:		June 2025
+Contact:	"Daeho Jeong" <daehojeong@google.com>
+Description:	Control GC algorithm for boost GC. 0: cost benefit, 1: greedy
+		Default: 1
+
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index de7e59bc0906..0d7703e7f9e0 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -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 = GC_GREEDY;
 
 	if (f2fs_sb_has_blkzoned(sbi)) {
 		gc_th->min_sleep_time = DEF_GC_THREAD_MIN_SLEEP_TIME_ZONED;
diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h
index efa1968810a0..1a2e7a84b59f 100644
--- a/fs/f2fs/gc.h
+++ b/fs/f2fs/gc.h
@@ -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 {
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index b0270b1c939c..3a52f51ee3c6 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -824,6 +824,20 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
 		return count;
 	}
 
+	if (!strcmp(a->attr.name, "gc_boost_gc_multiple")) {
+		if (t < 1 || t > SEGS_PER_SEC(sbi))
+			return -EINVAL;
+		sbi->gc_thread->boost_gc_multiple = (unsigned int)t;
+		return count;
+	}
+
+	if (!strcmp(a->attr.name, "gc_boost_gc_greedy")) {
+		if (t > GC_GREEDY)
+			return -EINVAL;
+		sbi->gc_thread->boost_gc_greedy = (unsigned int)t;
+		return count;
+	}
+
 	*ui = (unsigned int)t;
 
 	return count;
@@ -1051,6 +1065,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 +1237,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),
-- 
2.50.0.727.gbf7dc18ff4-goog



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [f2fs-dev] [PATCH v2] f2fs: add gc_boost_gc_greedy sysfs node
  2025-07-18 21:50 [f2fs-dev] [PATCH v2] f2fs: add gc_boost_gc_greedy sysfs node Daeho Jeong
@ 2025-07-22  3:24 ` Chao Yu via Linux-f2fs-devel
  2025-07-28 16:40   ` Jaegeuk Kim via Linux-f2fs-devel
  0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2025-07-22  3:24 UTC (permalink / raw)
  To: Daeho Jeong, linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong

On 7/19/25 05:50, Daeho Jeong wrote:
> From: Daeho Jeong <daehojeong@google.com>
> 
> Add this to control GC algorithm for boost GC.
> 
> Signed-off-by: Daeho Jeong <daehojeong@google.com>
> ---
> v2: use GC_GREEDY instead of 1
> ---
>  Documentation/ABI/testing/sysfs-fs-f2fs |  8 +++++++-
>  fs/f2fs/gc.c                            |  3 ++-
>  fs/f2fs/gc.h                            |  1 +
>  fs/f2fs/sysfs.c                         | 16 ++++++++++++++++
>  4 files changed, 26 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
> index 931c1f63aa2e..2158055cd9d1 100644
> --- a/Documentation/ABI/testing/sysfs-fs-f2fs
> +++ b/Documentation/ABI/testing/sysfs-fs-f2fs
> @@ -866,6 +866,12 @@ What:		/sys/fs/f2fs/<disk>/gc_boost_gc_multiple
>  Date:		June 2025
>  Contact:	"Daeho Jeong" <daehojeong@google.com>
>  Description:	Set a multiplier for the background GC migration window when F2FS GC is
> -		boosted.
> +		boosted. the range should be from 1 to the segment count in a section.
>  		Default: 5
>  
> +What:		/sys/fs/f2fs/<disk>/gc_boost_gc_greedy
> +Date:		June 2025
> +Contact:	"Daeho Jeong" <daehojeong@google.com>
> +Description:	Control GC algorithm for boost GC. 0: cost benefit, 1: greedy
> +		Default: 1
> +
> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
> index de7e59bc0906..0d7703e7f9e0 100644
> --- a/fs/f2fs/gc.c
> +++ b/fs/f2fs/gc.c
> @@ -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 = GC_GREEDY;
>  
>  	if (f2fs_sb_has_blkzoned(sbi)) {
>  		gc_th->min_sleep_time = DEF_GC_THREAD_MIN_SLEEP_TIME_ZONED;
> diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h
> index efa1968810a0..1a2e7a84b59f 100644
> --- a/fs/f2fs/gc.h
> +++ b/fs/f2fs/gc.h
> @@ -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 {
> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> index b0270b1c939c..3a52f51ee3c6 100644
> --- a/fs/f2fs/sysfs.c
> +++ b/fs/f2fs/sysfs.c
> @@ -824,6 +824,20 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
>  		return count;
>  	}
>  
> +	if (!strcmp(a->attr.name, "gc_boost_gc_multiple")) {
> +		if (t < 1 || t > SEGS_PER_SEC(sbi))
> +			return -EINVAL;
> +		sbi->gc_thread->boost_gc_multiple = (unsigned int)t;
> +		return count;
> +	}

This check should be in ("f2fs: add gc_boost_gc_multiple sysfs node"), right?

Thanks,

> +
> +	if (!strcmp(a->attr.name, "gc_boost_gc_greedy")) {
> +		if (t > GC_GREEDY)
> +			return -EINVAL;
> +		sbi->gc_thread->boost_gc_greedy = (unsigned int)t;
> +		return count;
> +	}
> +
>  	*ui = (unsigned int)t;
>  
>  	return count;
> @@ -1051,6 +1065,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 +1237,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),



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [f2fs-dev] [PATCH v2] f2fs: add gc_boost_gc_greedy sysfs node
  2025-07-22  3:24 ` Chao Yu via Linux-f2fs-devel
@ 2025-07-28 16:40   ` Jaegeuk Kim via Linux-f2fs-devel
  0 siblings, 0 replies; 3+ messages in thread
From: Jaegeuk Kim via Linux-f2fs-devel @ 2025-07-28 16:40 UTC (permalink / raw)
  To: Chao Yu; +Cc: Daeho Jeong, kernel-team, linux-kernel, linux-f2fs-devel

On 07/22, Chao Yu wrote:
> On 7/19/25 05:50, Daeho Jeong wrote:
> > From: Daeho Jeong <daehojeong@google.com>
> > 
> > Add this to control GC algorithm for boost GC.
> > 
> > Signed-off-by: Daeho Jeong <daehojeong@google.com>
> > ---
> > v2: use GC_GREEDY instead of 1
> > ---
> >  Documentation/ABI/testing/sysfs-fs-f2fs |  8 +++++++-
> >  fs/f2fs/gc.c                            |  3 ++-
> >  fs/f2fs/gc.h                            |  1 +
> >  fs/f2fs/sysfs.c                         | 16 ++++++++++++++++
> >  4 files changed, 26 insertions(+), 2 deletions(-)
> > 
> > diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
> > index 931c1f63aa2e..2158055cd9d1 100644
> > --- a/Documentation/ABI/testing/sysfs-fs-f2fs
> > +++ b/Documentation/ABI/testing/sysfs-fs-f2fs
> > @@ -866,6 +866,12 @@ What:		/sys/fs/f2fs/<disk>/gc_boost_gc_multiple
> >  Date:		June 2025
> >  Contact:	"Daeho Jeong" <daehojeong@google.com>
> >  Description:	Set a multiplier for the background GC migration window when F2FS GC is
> > -		boosted.
> > +		boosted. the range should be from 1 to the segment count in a section.
> >  		Default: 5
> >  
> > +What:		/sys/fs/f2fs/<disk>/gc_boost_gc_greedy
> > +Date:		June 2025
> > +Contact:	"Daeho Jeong" <daehojeong@google.com>
> > +Description:	Control GC algorithm for boost GC. 0: cost benefit, 1: greedy
> > +		Default: 1
> > +
> > diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
> > index de7e59bc0906..0d7703e7f9e0 100644
> > --- a/fs/f2fs/gc.c
> > +++ b/fs/f2fs/gc.c
> > @@ -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 = GC_GREEDY;
> >  
> >  	if (f2fs_sb_has_blkzoned(sbi)) {
> >  		gc_th->min_sleep_time = DEF_GC_THREAD_MIN_SLEEP_TIME_ZONED;
> > diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h
> > index efa1968810a0..1a2e7a84b59f 100644
> > --- a/fs/f2fs/gc.h
> > +++ b/fs/f2fs/gc.h
> > @@ -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 {
> > diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> > index b0270b1c939c..3a52f51ee3c6 100644
> > --- a/fs/f2fs/sysfs.c
> > +++ b/fs/f2fs/sysfs.c
> > @@ -824,6 +824,20 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
> >  		return count;
> >  	}
> >  
> > +	if (!strcmp(a->attr.name, "gc_boost_gc_multiple")) {
> > +		if (t < 1 || t > SEGS_PER_SEC(sbi))
> > +			return -EINVAL;
> > +		sbi->gc_thread->boost_gc_multiple = (unsigned int)t;
> > +		return count;
> > +	}
> 
> This check should be in ("f2fs: add gc_boost_gc_multiple sysfs node"), right?

Applied with the fix.

> 
> Thanks,
> 
> > +
> > +	if (!strcmp(a->attr.name, "gc_boost_gc_greedy")) {
> > +		if (t > GC_GREEDY)
> > +			return -EINVAL;
> > +		sbi->gc_thread->boost_gc_greedy = (unsigned int)t;
> > +		return count;
> > +	}
> > +
> >  	*ui = (unsigned int)t;
> >  
> >  	return count;
> > @@ -1051,6 +1065,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 +1237,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),
> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-07-28 16:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-18 21:50 [f2fs-dev] [PATCH v2] f2fs: add gc_boost_gc_greedy sysfs node Daeho Jeong
2025-07-22  3:24 ` Chao Yu via Linux-f2fs-devel
2025-07-28 16:40   ` Jaegeuk Kim via Linux-f2fs-devel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).