All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] f2fs: introduce gc_urgent_mid_remaining sysfs node
@ 2022-10-18  7:46 ` Yangtao Li via Linux-f2fs-devel
  0 siblings, 0 replies; 6+ messages in thread
From: Yangtao Li @ 2022-10-18  7:46 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-f2fs-devel, linux-kernel, Yangtao Li

Added a new sysfs node called gc_urgent_mid_remaining. The user can
set the trial count limit for GC urgent mid mode with this value. If
GC thread gets to the limit, the mode will turn back to GC normal mode.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 Documentation/ABI/testing/sysfs-fs-f2fs |  7 +++++++
 fs/f2fs/f2fs.h                          |  2 ++
 fs/f2fs/gc.c                            |  8 ++++++++
 fs/f2fs/super.c                         |  1 +
 fs/f2fs/sysfs.c                         | 10 ++++++++++
 5 files changed, 28 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
index 483639fb727b..11ce4a8bdacd 100644
--- a/Documentation/ABI/testing/sysfs-fs-f2fs
+++ b/Documentation/ABI/testing/sysfs-fs-f2fs
@@ -599,6 +599,13 @@ Description:	You can set the trial count limit for GC urgent high mode with this
 		If GC thread gets to the limit, the mode will turn back to GC normal mode.
 		By default, the value is zero, which means there is no limit like before.
 
+What:		/sys/fs/f2fs/<disk>/gc_urgent_mid_remaining
+Date:		October 2022
+Contact:	"Yangtao Li" <frank.li@vivo.com>
+Description:	You can set the trial count limit for GC urgent mid mode with this value.
+		If GC thread gets to the limit, the mode will turn back to GC normal mode.
+		By default, the value is zero.
+
 What:		/sys/fs/f2fs/<disk>/max_roll_forward_node_blocks
 Date:		January 2022
 Contact:	"Jaegeuk Kim" <jaegeuk@kernel.org>
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index e6355a5683b7..2f33d6f23a26 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1736,6 +1736,8 @@ struct f2fs_sb_info {
 	unsigned int next_victim_seg[2];	/* next segment in victim section */
 	spinlock_t gc_urgent_high_lock;
 	unsigned int gc_urgent_high_remaining;	/* remaining trial count for GC_URGENT_HIGH */
+	spinlock_t gc_urgent_mid_lock;
+	unsigned int gc_urgent_mid_remaining;	/* remaining trial count for GC_URGENT_MID */
 
 	/* for skip statistic */
 	unsigned long long skipped_gc_rwsem;		/* FG_GC only */
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 4546e01b2ee0..39d794b33d27 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -104,6 +104,14 @@ static int gc_thread_func(void *data)
 					sbi->gc_mode = GC_NORMAL;
 			}
 			spin_unlock(&sbi->gc_urgent_high_lock);
+		} else if (sbi->gc_mode == GC_URGENT_MID) {
+			spin_lock(&sbi->gc_urgent_mid_lock);
+			if (sbi->gc_urgent_mid_remaining) {
+				sbi->gc_urgent_mid_remaining--;
+				if (!sbi->gc_urgent_mid_remaining)
+					sbi->gc_mode = GC_NORMAL;
+			}
+			spin_unlock(&sbi->gc_urgent_mid_lock);
 		}
 
 		if (sbi->gc_mode == GC_URGENT_HIGH ||
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 3834ead04620..13919ad152b7 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -3617,6 +3617,7 @@ static void init_sb_info(struct f2fs_sb_info *sbi)
 	sbi->max_fragment_chunk = DEF_FRAGMENT_SIZE;
 	sbi->max_fragment_hole = DEF_FRAGMENT_SIZE;
 	spin_lock_init(&sbi->gc_urgent_high_lock);
+	spin_lock_init(&sbi->gc_urgent_mid_lock);
 	atomic64_set(&sbi->current_atomic_write, 0);
 
 	sbi->dir_level = DEF_DIR_LEVEL;
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index df27afd71ef4..b4476adea776 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -539,6 +539,14 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
 		return count;
 	}
 
+	if (!strcmp(a->attr.name, "gc_urgent_mid_remaining")) {
+		spin_lock(&sbi->gc_urgent_mid_lock);
+		sbi->gc_urgent_mid_remaining = t;
+		spin_unlock(&sbi->gc_urgent_mid_lock);
+
+		return count;
+	}
+
 #ifdef CONFIG_F2FS_IOSTAT
 	if (!strcmp(a->attr.name, "iostat_enable")) {
 		sbi->iostat_enable = !!t;
@@ -826,6 +834,7 @@ F2FS_RW_ATTR(FAULT_INFO_TYPE, f2fs_fault_info, inject_type, inject_type);
 F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, data_io_flag, data_io_flag);
 F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, node_io_flag, node_io_flag);
 F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_urgent_high_remaining, gc_urgent_high_remaining);
+F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_urgent_mid_remaining, gc_urgent_mid_remaining);
 F2FS_RW_ATTR(CPRC_INFO, ckpt_req_control, ckpt_thread_ioprio, ckpt_thread_ioprio);
 F2FS_GENERAL_RO_ATTR(dirty_segments);
 F2FS_GENERAL_RO_ATTR(free_segments);
@@ -953,6 +962,7 @@ static struct attribute *f2fs_attrs[] = {
 	ATTR_LIST(data_io_flag),
 	ATTR_LIST(node_io_flag),
 	ATTR_LIST(gc_urgent_high_remaining),
+	ATTR_LIST(gc_urgent_mid_remaining),
 	ATTR_LIST(ckpt_thread_ioprio),
 	ATTR_LIST(dirty_segments),
 	ATTR_LIST(free_segments),
-- 
2.25.1


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

* [f2fs-dev] [PATCH] f2fs: introduce gc_urgent_mid_remaining sysfs node
@ 2022-10-18  7:46 ` Yangtao Li via Linux-f2fs-devel
  0 siblings, 0 replies; 6+ messages in thread
From: Yangtao Li via Linux-f2fs-devel @ 2022-10-18  7:46 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: Yangtao Li, linux-kernel, linux-f2fs-devel

Added a new sysfs node called gc_urgent_mid_remaining. The user can
set the trial count limit for GC urgent mid mode with this value. If
GC thread gets to the limit, the mode will turn back to GC normal mode.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 Documentation/ABI/testing/sysfs-fs-f2fs |  7 +++++++
 fs/f2fs/f2fs.h                          |  2 ++
 fs/f2fs/gc.c                            |  8 ++++++++
 fs/f2fs/super.c                         |  1 +
 fs/f2fs/sysfs.c                         | 10 ++++++++++
 5 files changed, 28 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
index 483639fb727b..11ce4a8bdacd 100644
--- a/Documentation/ABI/testing/sysfs-fs-f2fs
+++ b/Documentation/ABI/testing/sysfs-fs-f2fs
@@ -599,6 +599,13 @@ Description:	You can set the trial count limit for GC urgent high mode with this
 		If GC thread gets to the limit, the mode will turn back to GC normal mode.
 		By default, the value is zero, which means there is no limit like before.
 
+What:		/sys/fs/f2fs/<disk>/gc_urgent_mid_remaining
+Date:		October 2022
+Contact:	"Yangtao Li" <frank.li@vivo.com>
+Description:	You can set the trial count limit for GC urgent mid mode with this value.
+		If GC thread gets to the limit, the mode will turn back to GC normal mode.
+		By default, the value is zero.
+
 What:		/sys/fs/f2fs/<disk>/max_roll_forward_node_blocks
 Date:		January 2022
 Contact:	"Jaegeuk Kim" <jaegeuk@kernel.org>
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index e6355a5683b7..2f33d6f23a26 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1736,6 +1736,8 @@ struct f2fs_sb_info {
 	unsigned int next_victim_seg[2];	/* next segment in victim section */
 	spinlock_t gc_urgent_high_lock;
 	unsigned int gc_urgent_high_remaining;	/* remaining trial count for GC_URGENT_HIGH */
+	spinlock_t gc_urgent_mid_lock;
+	unsigned int gc_urgent_mid_remaining;	/* remaining trial count for GC_URGENT_MID */
 
 	/* for skip statistic */
 	unsigned long long skipped_gc_rwsem;		/* FG_GC only */
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 4546e01b2ee0..39d794b33d27 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -104,6 +104,14 @@ static int gc_thread_func(void *data)
 					sbi->gc_mode = GC_NORMAL;
 			}
 			spin_unlock(&sbi->gc_urgent_high_lock);
+		} else if (sbi->gc_mode == GC_URGENT_MID) {
+			spin_lock(&sbi->gc_urgent_mid_lock);
+			if (sbi->gc_urgent_mid_remaining) {
+				sbi->gc_urgent_mid_remaining--;
+				if (!sbi->gc_urgent_mid_remaining)
+					sbi->gc_mode = GC_NORMAL;
+			}
+			spin_unlock(&sbi->gc_urgent_mid_lock);
 		}
 
 		if (sbi->gc_mode == GC_URGENT_HIGH ||
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 3834ead04620..13919ad152b7 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -3617,6 +3617,7 @@ static void init_sb_info(struct f2fs_sb_info *sbi)
 	sbi->max_fragment_chunk = DEF_FRAGMENT_SIZE;
 	sbi->max_fragment_hole = DEF_FRAGMENT_SIZE;
 	spin_lock_init(&sbi->gc_urgent_high_lock);
+	spin_lock_init(&sbi->gc_urgent_mid_lock);
 	atomic64_set(&sbi->current_atomic_write, 0);
 
 	sbi->dir_level = DEF_DIR_LEVEL;
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index df27afd71ef4..b4476adea776 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -539,6 +539,14 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
 		return count;
 	}
 
+	if (!strcmp(a->attr.name, "gc_urgent_mid_remaining")) {
+		spin_lock(&sbi->gc_urgent_mid_lock);
+		sbi->gc_urgent_mid_remaining = t;
+		spin_unlock(&sbi->gc_urgent_mid_lock);
+
+		return count;
+	}
+
 #ifdef CONFIG_F2FS_IOSTAT
 	if (!strcmp(a->attr.name, "iostat_enable")) {
 		sbi->iostat_enable = !!t;
@@ -826,6 +834,7 @@ F2FS_RW_ATTR(FAULT_INFO_TYPE, f2fs_fault_info, inject_type, inject_type);
 F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, data_io_flag, data_io_flag);
 F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, node_io_flag, node_io_flag);
 F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_urgent_high_remaining, gc_urgent_high_remaining);
+F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_urgent_mid_remaining, gc_urgent_mid_remaining);
 F2FS_RW_ATTR(CPRC_INFO, ckpt_req_control, ckpt_thread_ioprio, ckpt_thread_ioprio);
 F2FS_GENERAL_RO_ATTR(dirty_segments);
 F2FS_GENERAL_RO_ATTR(free_segments);
@@ -953,6 +962,7 @@ static struct attribute *f2fs_attrs[] = {
 	ATTR_LIST(data_io_flag),
 	ATTR_LIST(node_io_flag),
 	ATTR_LIST(gc_urgent_high_remaining),
+	ATTR_LIST(gc_urgent_mid_remaining),
 	ATTR_LIST(ckpt_thread_ioprio),
 	ATTR_LIST(dirty_segments),
 	ATTR_LIST(free_segments),
-- 
2.25.1



_______________________________________________
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] 6+ messages in thread

* Re: [PATCH] f2fs: introduce gc_urgent_mid_remaining sysfs node
  2022-10-18  7:46 ` [f2fs-dev] " Yangtao Li via Linux-f2fs-devel
@ 2022-10-20  7:54   ` Chao Yu
  -1 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2022-10-20  7:54 UTC (permalink / raw)
  To: Yangtao Li, jaegeuk; +Cc: linux-f2fs-devel, linux-kernel

Yangtao,

On 2022/10/18 15:46, Yangtao Li wrote:
> Added a new sysfs node called gc_urgent_mid_remaining. The user can
> set the trial count limit for GC urgent mid mode with this value. If
> GC thread gets to the limit, the mode will turn back to GC normal mode.

Not sure, we will add gc_urgent_low_remaining later...

Can we share the same interface for all gc_mode? since each mode is
exclusive.

Thoughts?

Thanks,

> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>   Documentation/ABI/testing/sysfs-fs-f2fs |  7 +++++++
>   fs/f2fs/f2fs.h                          |  2 ++
>   fs/f2fs/gc.c                            |  8 ++++++++
>   fs/f2fs/super.c                         |  1 +
>   fs/f2fs/sysfs.c                         | 10 ++++++++++
>   5 files changed, 28 insertions(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
> index 483639fb727b..11ce4a8bdacd 100644
> --- a/Documentation/ABI/testing/sysfs-fs-f2fs
> +++ b/Documentation/ABI/testing/sysfs-fs-f2fs
> @@ -599,6 +599,13 @@ Description:	You can set the trial count limit for GC urgent high mode with this
>   		If GC thread gets to the limit, the mode will turn back to GC normal mode.
>   		By default, the value is zero, which means there is no limit like before.
>   
> +What:		/sys/fs/f2fs/<disk>/gc_urgent_mid_remaining
> +Date:		October 2022
> +Contact:	"Yangtao Li" <frank.li@vivo.com>
> +Description:	You can set the trial count limit for GC urgent mid mode with this value.
> +		If GC thread gets to the limit, the mode will turn back to GC normal mode.
> +		By default, the value is zero.
> +
>   What:		/sys/fs/f2fs/<disk>/max_roll_forward_node_blocks
>   Date:		January 2022
>   Contact:	"Jaegeuk Kim" <jaegeuk@kernel.org>
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index e6355a5683b7..2f33d6f23a26 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -1736,6 +1736,8 @@ struct f2fs_sb_info {
>   	unsigned int next_victim_seg[2];	/* next segment in victim section */
>   	spinlock_t gc_urgent_high_lock;
>   	unsigned int gc_urgent_high_remaining;	/* remaining trial count for GC_URGENT_HIGH */
> +	spinlock_t gc_urgent_mid_lock;
> +	unsigned int gc_urgent_mid_remaining;	/* remaining trial count for GC_URGENT_MID */
>   
>   	/* for skip statistic */
>   	unsigned long long skipped_gc_rwsem;		/* FG_GC only */
> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
> index 4546e01b2ee0..39d794b33d27 100644
> --- a/fs/f2fs/gc.c
> +++ b/fs/f2fs/gc.c
> @@ -104,6 +104,14 @@ static int gc_thread_func(void *data)
>   					sbi->gc_mode = GC_NORMAL;
>   			}
>   			spin_unlock(&sbi->gc_urgent_high_lock);
> +		} else if (sbi->gc_mode == GC_URGENT_MID) {
> +			spin_lock(&sbi->gc_urgent_mid_lock);
> +			if (sbi->gc_urgent_mid_remaining) {
> +				sbi->gc_urgent_mid_remaining--;
> +				if (!sbi->gc_urgent_mid_remaining)
> +					sbi->gc_mode = GC_NORMAL;
> +			}
> +			spin_unlock(&sbi->gc_urgent_mid_lock);
>   		}
>   
>   		if (sbi->gc_mode == GC_URGENT_HIGH ||
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 3834ead04620..13919ad152b7 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -3617,6 +3617,7 @@ static void init_sb_info(struct f2fs_sb_info *sbi)
>   	sbi->max_fragment_chunk = DEF_FRAGMENT_SIZE;
>   	sbi->max_fragment_hole = DEF_FRAGMENT_SIZE;
>   	spin_lock_init(&sbi->gc_urgent_high_lock);
> +	spin_lock_init(&sbi->gc_urgent_mid_lock);
>   	atomic64_set(&sbi->current_atomic_write, 0);
>   
>   	sbi->dir_level = DEF_DIR_LEVEL;
> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> index df27afd71ef4..b4476adea776 100644
> --- a/fs/f2fs/sysfs.c
> +++ b/fs/f2fs/sysfs.c
> @@ -539,6 +539,14 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
>   		return count;
>   	}
>   
> +	if (!strcmp(a->attr.name, "gc_urgent_mid_remaining")) {
> +		spin_lock(&sbi->gc_urgent_mid_lock);
> +		sbi->gc_urgent_mid_remaining = t;
> +		spin_unlock(&sbi->gc_urgent_mid_lock);
> +
> +		return count;
> +	}
> +
>   #ifdef CONFIG_F2FS_IOSTAT
>   	if (!strcmp(a->attr.name, "iostat_enable")) {
>   		sbi->iostat_enable = !!t;
> @@ -826,6 +834,7 @@ F2FS_RW_ATTR(FAULT_INFO_TYPE, f2fs_fault_info, inject_type, inject_type);
>   F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, data_io_flag, data_io_flag);
>   F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, node_io_flag, node_io_flag);
>   F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_urgent_high_remaining, gc_urgent_high_remaining);
> +F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_urgent_mid_remaining, gc_urgent_mid_remaining);
>   F2FS_RW_ATTR(CPRC_INFO, ckpt_req_control, ckpt_thread_ioprio, ckpt_thread_ioprio);
>   F2FS_GENERAL_RO_ATTR(dirty_segments);
>   F2FS_GENERAL_RO_ATTR(free_segments);
> @@ -953,6 +962,7 @@ static struct attribute *f2fs_attrs[] = {
>   	ATTR_LIST(data_io_flag),
>   	ATTR_LIST(node_io_flag),
>   	ATTR_LIST(gc_urgent_high_remaining),
> +	ATTR_LIST(gc_urgent_mid_remaining),
>   	ATTR_LIST(ckpt_thread_ioprio),
>   	ATTR_LIST(dirty_segments),
>   	ATTR_LIST(free_segments),

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

* Re: [f2fs-dev] [PATCH] f2fs: introduce gc_urgent_mid_remaining sysfs node
@ 2022-10-20  7:54   ` Chao Yu
  0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2022-10-20  7:54 UTC (permalink / raw)
  To: Yangtao Li, jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

Yangtao,

On 2022/10/18 15:46, Yangtao Li wrote:
> Added a new sysfs node called gc_urgent_mid_remaining. The user can
> set the trial count limit for GC urgent mid mode with this value. If
> GC thread gets to the limit, the mode will turn back to GC normal mode.

Not sure, we will add gc_urgent_low_remaining later...

Can we share the same interface for all gc_mode? since each mode is
exclusive.

Thoughts?

Thanks,

> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>   Documentation/ABI/testing/sysfs-fs-f2fs |  7 +++++++
>   fs/f2fs/f2fs.h                          |  2 ++
>   fs/f2fs/gc.c                            |  8 ++++++++
>   fs/f2fs/super.c                         |  1 +
>   fs/f2fs/sysfs.c                         | 10 ++++++++++
>   5 files changed, 28 insertions(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
> index 483639fb727b..11ce4a8bdacd 100644
> --- a/Documentation/ABI/testing/sysfs-fs-f2fs
> +++ b/Documentation/ABI/testing/sysfs-fs-f2fs
> @@ -599,6 +599,13 @@ Description:	You can set the trial count limit for GC urgent high mode with this
>   		If GC thread gets to the limit, the mode will turn back to GC normal mode.
>   		By default, the value is zero, which means there is no limit like before.
>   
> +What:		/sys/fs/f2fs/<disk>/gc_urgent_mid_remaining
> +Date:		October 2022
> +Contact:	"Yangtao Li" <frank.li@vivo.com>
> +Description:	You can set the trial count limit for GC urgent mid mode with this value.
> +		If GC thread gets to the limit, the mode will turn back to GC normal mode.
> +		By default, the value is zero.
> +
>   What:		/sys/fs/f2fs/<disk>/max_roll_forward_node_blocks
>   Date:		January 2022
>   Contact:	"Jaegeuk Kim" <jaegeuk@kernel.org>
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index e6355a5683b7..2f33d6f23a26 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -1736,6 +1736,8 @@ struct f2fs_sb_info {
>   	unsigned int next_victim_seg[2];	/* next segment in victim section */
>   	spinlock_t gc_urgent_high_lock;
>   	unsigned int gc_urgent_high_remaining;	/* remaining trial count for GC_URGENT_HIGH */
> +	spinlock_t gc_urgent_mid_lock;
> +	unsigned int gc_urgent_mid_remaining;	/* remaining trial count for GC_URGENT_MID */
>   
>   	/* for skip statistic */
>   	unsigned long long skipped_gc_rwsem;		/* FG_GC only */
> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
> index 4546e01b2ee0..39d794b33d27 100644
> --- a/fs/f2fs/gc.c
> +++ b/fs/f2fs/gc.c
> @@ -104,6 +104,14 @@ static int gc_thread_func(void *data)
>   					sbi->gc_mode = GC_NORMAL;
>   			}
>   			spin_unlock(&sbi->gc_urgent_high_lock);
> +		} else if (sbi->gc_mode == GC_URGENT_MID) {
> +			spin_lock(&sbi->gc_urgent_mid_lock);
> +			if (sbi->gc_urgent_mid_remaining) {
> +				sbi->gc_urgent_mid_remaining--;
> +				if (!sbi->gc_urgent_mid_remaining)
> +					sbi->gc_mode = GC_NORMAL;
> +			}
> +			spin_unlock(&sbi->gc_urgent_mid_lock);
>   		}
>   
>   		if (sbi->gc_mode == GC_URGENT_HIGH ||
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 3834ead04620..13919ad152b7 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -3617,6 +3617,7 @@ static void init_sb_info(struct f2fs_sb_info *sbi)
>   	sbi->max_fragment_chunk = DEF_FRAGMENT_SIZE;
>   	sbi->max_fragment_hole = DEF_FRAGMENT_SIZE;
>   	spin_lock_init(&sbi->gc_urgent_high_lock);
> +	spin_lock_init(&sbi->gc_urgent_mid_lock);
>   	atomic64_set(&sbi->current_atomic_write, 0);
>   
>   	sbi->dir_level = DEF_DIR_LEVEL;
> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> index df27afd71ef4..b4476adea776 100644
> --- a/fs/f2fs/sysfs.c
> +++ b/fs/f2fs/sysfs.c
> @@ -539,6 +539,14 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
>   		return count;
>   	}
>   
> +	if (!strcmp(a->attr.name, "gc_urgent_mid_remaining")) {
> +		spin_lock(&sbi->gc_urgent_mid_lock);
> +		sbi->gc_urgent_mid_remaining = t;
> +		spin_unlock(&sbi->gc_urgent_mid_lock);
> +
> +		return count;
> +	}
> +
>   #ifdef CONFIG_F2FS_IOSTAT
>   	if (!strcmp(a->attr.name, "iostat_enable")) {
>   		sbi->iostat_enable = !!t;
> @@ -826,6 +834,7 @@ F2FS_RW_ATTR(FAULT_INFO_TYPE, f2fs_fault_info, inject_type, inject_type);
>   F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, data_io_flag, data_io_flag);
>   F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, node_io_flag, node_io_flag);
>   F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_urgent_high_remaining, gc_urgent_high_remaining);
> +F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_urgent_mid_remaining, gc_urgent_mid_remaining);
>   F2FS_RW_ATTR(CPRC_INFO, ckpt_req_control, ckpt_thread_ioprio, ckpt_thread_ioprio);
>   F2FS_GENERAL_RO_ATTR(dirty_segments);
>   F2FS_GENERAL_RO_ATTR(free_segments);
> @@ -953,6 +962,7 @@ static struct attribute *f2fs_attrs[] = {
>   	ATTR_LIST(data_io_flag),
>   	ATTR_LIST(node_io_flag),
>   	ATTR_LIST(gc_urgent_high_remaining),
> +	ATTR_LIST(gc_urgent_mid_remaining),
>   	ATTR_LIST(ckpt_thread_ioprio),
>   	ATTR_LIST(dirty_segments),
>   	ATTR_LIST(free_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] 6+ messages in thread

* 答复: [PATCH] f2fs: introduce gc_urgent_mid_remaining sysfs node
  2022-10-20  7:54   ` [f2fs-dev] " Chao Yu
@ 2022-10-20  8:12     ` 李扬韬 via Linux-f2fs-devel
  -1 siblings, 0 replies; 6+ messages in thread
From: 李扬韬 @ 2022-10-20  8:12 UTC (permalink / raw)
  To: Chao Yu, jaegeuk; +Cc: linux-f2fs-devel, linux-kernel

Chao,

> Not sure, we will add gc_urgent_low_remaining later...

> Can we share the same interface for all gc_mode? since each mode is exclusive.

> Thoughts?

Both GC urgent mid mode and GC urgent high mode run using the urgent_sleep_time interval. If the user program does not switch back to normal mode in an abnormal state, it will cause the gc to run rapidly.

Therefore, there needs to be a mechanism to ensure that the GC urgent mid mode and GC urgent high mode can be switched back to the normal mode. Since there is currently a gc_urgent_high_remaining node, I added the gc_urgent_mid_remaining node.

If gc_urgent_high_remaining can act on three modes, it is not in line with the meaning of the name. Not sure if the existing sys node can still change the name, if it can be changed, obviously using gc_urgent_remaining is a better way. Can an existing node still be renamed?

If the name cannot be changed, it is necessary to increase gc_urgent_mid_remaining. Perhaps one more gc_urgent_low_remaining could be added?




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

* [f2fs-dev] 答复: [PATCH] f2fs: introduce gc_urgent_mid_remaining sysfs node
@ 2022-10-20  8:12     ` 李扬韬 via Linux-f2fs-devel
  0 siblings, 0 replies; 6+ messages in thread
From: 李扬韬 via Linux-f2fs-devel @ 2022-10-20  8:12 UTC (permalink / raw)
  To: Chao Yu, jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

Chao,

> Not sure, we will add gc_urgent_low_remaining later...

> Can we share the same interface for all gc_mode? since each mode is exclusive.

> Thoughts?

Both GC urgent mid mode and GC urgent high mode run using the urgent_sleep_time interval. If the user program does not switch back to normal mode in an abnormal state, it will cause the gc to run rapidly.

Therefore, there needs to be a mechanism to ensure that the GC urgent mid mode and GC urgent high mode can be switched back to the normal mode. Since there is currently a gc_urgent_high_remaining node, I added the gc_urgent_mid_remaining node.

If gc_urgent_high_remaining can act on three modes, it is not in line with the meaning of the name. Not sure if the existing sys node can still change the name, if it can be changed, obviously using gc_urgent_remaining is a better way. Can an existing node still be renamed?

If the name cannot be changed, it is necessary to increase gc_urgent_mid_remaining. Perhaps one more gc_urgent_low_remaining could be added?




_______________________________________________
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] 6+ messages in thread

end of thread, other threads:[~2022-10-20  8:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-18  7:46 [PATCH] f2fs: introduce gc_urgent_mid_remaining sysfs node Yangtao Li
2022-10-18  7:46 ` [f2fs-dev] " Yangtao Li via Linux-f2fs-devel
2022-10-20  7:54 ` Chao Yu
2022-10-20  7:54   ` [f2fs-dev] " Chao Yu
2022-10-20  8:12   ` 答复: " 李扬韬
2022-10-20  8:12     ` [f2fs-dev] " 李扬韬 via Linux-f2fs-devel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.