linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] f2fs: do decrease_sleep_time() if any of the victims have been selected
@ 2022-12-09 11:28 Yuwei Guan
  2022-12-11  2:52 ` Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Yuwei Guan @ 2022-12-09 11:28 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-f2fs-devel, linux-kernel, Yuwei.Guan

In non-foreground gc mode, if no victim is selected, the gc process
will wait for no_gc_sleep_time before waking up again. In this
subsequent time, even though a victim will be selected, the gc process
still waits for no_gc_sleep_time before waking up. The configuration
of wait_ms is not reasonable.

After any of the victims have been selected, we need to do
decrease_sleep_time() to reduce wait_ms.

If it is GC_URGENT_HIGH or GC_URGENT_MID gc mode,
wait_ms will keep urgent_sleep_time after executing decrease_sleep_time().

In decrease_sleep_time() wait_time will be reduced to max_sleep_time
from no_gc_sleep_time, if *wait is no_gc_sleep_time. And then it goes
down in the next step.

Signed-off-by: Yuwei Guan <Yuwei.Guan@zeekrlife.com>
---
 fs/f2fs/gc.c | 2 ++
 fs/f2fs/gc.h | 7 ++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index f0c6506d8975..c023ffeb9268 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -141,6 +141,8 @@ static int gc_thread_func(void *data)
 			/* don't bother wait_ms by foreground gc */
 			if (!foreground)
 				wait_ms = gc_th->no_gc_sleep_time;
+		} else {
+			decrease_sleep_time(gc_th, &wait_ms);
 		}
 
 		if (foreground)
diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h
index 19b956c2d697..6402584dcd72 100644
--- a/fs/f2fs/gc.h
+++ b/fs/f2fs/gc.h
@@ -150,8 +150,13 @@ static inline void decrease_sleep_time(struct f2fs_gc_kthread *gc_th,
 {
 	unsigned int min_time = gc_th->min_sleep_time;
 
-	if (*wait == gc_th->no_gc_sleep_time)
+	if (*wait == gc_th->urgent_sleep_time)
+		return;
+
+	if (*wait == gc_th->no_gc_sleep_time) {
 		*wait = gc_th->max_sleep_time;
+		return;
+	}
 
 	if ((long long)*wait - (long long)min_time < (long long)min_time)
 		*wait = min_time;
-- 
2.34.1


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

* Re: [PATCH] f2fs: do decrease_sleep_time() if any of the victims have been selected
  2022-12-09 11:28 [PATCH] f2fs: do decrease_sleep_time() if any of the victims have been selected Yuwei Guan
@ 2022-12-11  2:52 ` Chao Yu
  2022-12-11 12:30   ` Yuwei Guan
  0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2022-12-11  2:52 UTC (permalink / raw)
  To: Yuwei Guan, jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Yuwei.Guan

On 2022/12/9 19:28, Yuwei Guan wrote:
> In non-foreground gc mode, if no victim is selected, the gc process
> will wait for no_gc_sleep_time before waking up again. In this
> subsequent time, even though a victim will be selected, the gc process
> still waits for no_gc_sleep_time before waking up. The configuration
> of wait_ms is not reasonable.
> 
> After any of the victims have been selected, we need to do
> decrease_sleep_time() to reduce wait_ms.
> 
> If it is GC_URGENT_HIGH or GC_URGENT_MID gc mode,
> wait_ms will keep urgent_sleep_time after executing decrease_sleep_time().
> 
> In decrease_sleep_time() wait_time will be reduced to max_sleep_time
> from no_gc_sleep_time, if *wait is no_gc_sleep_time. And then it goes
> down in the next step.
> 
> Signed-off-by: Yuwei Guan <Yuwei.Guan@zeekrlife.com>
> ---
>   fs/f2fs/gc.c | 2 ++
>   fs/f2fs/gc.h | 7 ++++++-
>   2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
> index f0c6506d8975..c023ffeb9268 100644
> --- a/fs/f2fs/gc.c
> +++ b/fs/f2fs/gc.c
> @@ -141,6 +141,8 @@ static int gc_thread_func(void *data)
>   			/* don't bother wait_ms by foreground gc */
>   			if (!foreground)
>   				wait_ms = gc_th->no_gc_sleep_time;
> +		} else {
> +			decrease_sleep_time(gc_th, &wait_ms);

Once BGGC selects valid victim, it will go faster and fater?

How about:

	} else {
		/* reset wait_ms to default sleep time */
		if (wait_ms == gc_th->no_gc_sleep_time)
			wait_ms = gc_th->min_sleep_time;
	}

Thanks,

>   		}
>   
>   		if (foreground)
> diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h
> index 19b956c2d697..6402584dcd72 100644
> --- a/fs/f2fs/gc.h
> +++ b/fs/f2fs/gc.h
> @@ -150,8 +150,13 @@ static inline void decrease_sleep_time(struct f2fs_gc_kthread *gc_th,
>   {
>   	unsigned int min_time = gc_th->min_sleep_time;
>   
> -	if (*wait == gc_th->no_gc_sleep_time)
> +	if (*wait == gc_th->urgent_sleep_time)
> +		return;
> +
> +	if (*wait == gc_th->no_gc_sleep_time) {
>   		*wait = gc_th->max_sleep_time;
> +		return;
> +	}
>   
>   	if ((long long)*wait - (long long)min_time < (long long)min_time)
>   		*wait = min_time;

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

* Re: [PATCH] f2fs: do decrease_sleep_time() if any of the victims have been selected
  2022-12-11  2:52 ` Chao Yu
@ 2022-12-11 12:30   ` Yuwei Guan
  0 siblings, 0 replies; 3+ messages in thread
From: Yuwei Guan @ 2022-12-11 12:30 UTC (permalink / raw)
  To: Chao Yu, jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Yuwei.Guan



在 2022/12/11 10:52, Chao Yu 写道:
> On 2022/12/9 19:28, Yuwei Guan wrote:
>> In non-foreground gc mode, if no victim is selected, the gc process
>> will wait for no_gc_sleep_time before waking up again. In this
>> subsequent time, even though a victim will be selected, the gc process
>> still waits for no_gc_sleep_time before waking up. The configuration
>> of wait_ms is not reasonable.
>>
>> After any of the victims have been selected, we need to do
>> decrease_sleep_time() to reduce wait_ms.
>>
>> If it is GC_URGENT_HIGH or GC_URGENT_MID gc mode,
>> wait_ms will keep urgent_sleep_time after executing 
>> decrease_sleep_time().
>>
>> In decrease_sleep_time() wait_time will be reduced to max_sleep_time
>> from no_gc_sleep_time, if *wait is no_gc_sleep_time. And then it goes
>> down in the next step.
>>
>> Signed-off-by: Yuwei Guan <Yuwei.Guan@zeekrlife.com>
>> ---
>>   fs/f2fs/gc.c | 2 ++
>>   fs/f2fs/gc.h | 7 ++++++-
>>   2 files changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
>> index f0c6506d8975..c023ffeb9268 100644
>> --- a/fs/f2fs/gc.c
>> +++ b/fs/f2fs/gc.c
>> @@ -141,6 +141,8 @@ static int gc_thread_func(void *data)
>>               /* don't bother wait_ms by foreground gc */
>>               if (!foreground)
>>                   wait_ms = gc_th->no_gc_sleep_time;
>> +        } else {
>> +            decrease_sleep_time(gc_th, &wait_ms);
> 
> Once BGGC selects valid victim, it will go faster and fater?
> > How about:
> 
>      } else {
>          /* reset wait_ms to default sleep time */
>          if (wait_ms == gc_th->no_gc_sleep_time)
>              wait_ms = gc_th->min_sleep_time;
>      }
Indeed. it will go faster and fater, until wait_ms reduces to 
min_sleep_time. But your suggestion seems more reasonable, I will send 
it in v2 patch.
> 
> Thanks,
> 
>>           }
>>           if (foreground)
>> diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h
>> index 19b956c2d697..6402584dcd72 100644
>> --- a/fs/f2fs/gc.h
>> +++ b/fs/f2fs/gc.h
>> @@ -150,8 +150,13 @@ static inline void decrease_sleep_time(struct 
>> f2fs_gc_kthread *gc_th,
>>   {
>>       unsigned int min_time = gc_th->min_sleep_time;
>> -    if (*wait == gc_th->no_gc_sleep_time)
>> +    if (*wait == gc_th->urgent_sleep_time)
>> +        return;
>> +
>> +    if (*wait == gc_th->no_gc_sleep_time) {
>>           *wait = gc_th->max_sleep_time;
>> +        return;
>> +    }
>>       if ((long long)*wait - (long long)min_time < (long long)min_time)
>>           *wait = min_time;

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

end of thread, other threads:[~2022-12-11 12:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-09 11:28 [PATCH] f2fs: do decrease_sleep_time() if any of the victims have been selected Yuwei Guan
2022-12-11  2:52 ` Chao Yu
2022-12-11 12:30   ` Yuwei Guan

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).