linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] f2fs: fix unnecessary periodic wakeup of discard thread when dev is busy
@ 2018-08-31  9:39 Sahitya Tummala
  2018-09-02  8:52 ` [f2fs-dev] " Chao Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Sahitya Tummala @ 2018-08-31  9:39 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu, linux-f2fs-devel; +Cc: linux-kernel, Sahitya Tummala

When dev is busy, discard thread wake up timeout can be aligned with the
exact time that it needs to wait for dev to come out of busy. This helps
to avoid unnecessary periodic wakeups and thus save some power.

Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
---
 fs/f2fs/segment.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 8bcbb50..df14030 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1379,6 +1379,8 @@ static int issue_discard_thread(void *data)
 	struct discard_policy dpolicy;
 	unsigned int wait_ms = DEF_MIN_DISCARD_ISSUE_TIME;
 	int issued;
+	unsigned long interval = sbi->interval_time[REQ_TIME] * HZ;
+	long delta;
 
 	set_freezable();
 
@@ -1410,7 +1412,11 @@ static int issue_discard_thread(void *data)
 			__wait_all_discard_cmd(sbi, &dpolicy);
 			wait_ms = dpolicy.min_interval;
 		} else if (issued == -1){
-			wait_ms = dpolicy.mid_interval;
+			delta = (sbi->last_time[REQ_TIME] + interval) - jiffies;
+			if (delta > 0)
+				wait_ms = jiffies_to_msecs(delta);
+			else
+				wait_ms = dpolicy.mid_interval;
 		} else {
 			wait_ms = dpolicy.max_interval;
 		}
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.


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

* Re: [f2fs-dev] [PATCH] f2fs: fix unnecessary periodic wakeup of discard thread when dev is busy
  2018-08-31  9:39 [PATCH] f2fs: fix unnecessary periodic wakeup of discard thread when dev is busy Sahitya Tummala
@ 2018-09-02  8:52 ` Chao Yu
  2018-09-02 10:34   ` Sahitya Tummala
  0 siblings, 1 reply; 4+ messages in thread
From: Chao Yu @ 2018-09-02  8:52 UTC (permalink / raw)
  To: Sahitya Tummala, Jaegeuk Kim, Chao Yu, linux-f2fs-devel; +Cc: linux-kernel

On 2018/8/31 17:39, Sahitya Tummala wrote:
> When dev is busy, discard thread wake up timeout can be aligned with the
> exact time that it needs to wait for dev to come out of busy. This helps
> to avoid unnecessary periodic wakeups and thus save some power.
> 
> Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
> ---
>  fs/f2fs/segment.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 8bcbb50..df14030 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -1379,6 +1379,8 @@ static int issue_discard_thread(void *data)
>  	struct discard_policy dpolicy;
>  	unsigned int wait_ms = DEF_MIN_DISCARD_ISSUE_TIME;
>  	int issued;
> +	unsigned long interval = sbi->interval_time[REQ_TIME] * HZ;
> +	long delta;
>  
>  	set_freezable();
>  
> @@ -1410,7 +1412,11 @@ static int issue_discard_thread(void *data)
>  			__wait_all_discard_cmd(sbi, &dpolicy);
>  			wait_ms = dpolicy.min_interval;
>  		} else if (issued == -1){
> -			wait_ms = dpolicy.mid_interval;
> +			delta = (sbi->last_time[REQ_TIME] + interval) - jiffies;

I agree that we need to consider power consumption. One more consideration is
that discard thread may need different submission frequency comparing to garbage
collection thread, maybe a little fast, would it be better to split
sbi->interval_time[REQ_TIME] according to gc/discard type.

How do you think?

Thanks,

> +			if (delta > 0)
> +				wait_ms = jiffies_to_msecs(delta);
> +			else
> +				wait_ms = dpolicy.mid_interval;
>  		} else {
>  			wait_ms = dpolicy.max_interval;
>  		}
> 

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

* Re: [f2fs-dev] [PATCH] f2fs: fix unnecessary periodic wakeup of discard thread when dev is busy
  2018-09-02  8:52 ` [f2fs-dev] " Chao Yu
@ 2018-09-02 10:34   ` Sahitya Tummala
  2018-09-02 12:56     ` Chao Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Sahitya Tummala @ 2018-09-02 10:34 UTC (permalink / raw)
  To: Chao Yu; +Cc: Jaegeuk Kim, Chao Yu, linux-f2fs-devel, linux-kernel

On Sun, Sep 02, 2018 at 04:52:40PM +0800, Chao Yu wrote:
> On 2018/8/31 17:39, Sahitya Tummala wrote:
> > When dev is busy, discard thread wake up timeout can be aligned with the
> > exact time that it needs to wait for dev to come out of busy. This helps
> > to avoid unnecessary periodic wakeups and thus save some power.
> > 
> > Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
> > ---
> >  fs/f2fs/segment.c | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> > 
> > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> > index 8bcbb50..df14030 100644
> > --- a/fs/f2fs/segment.c
> > +++ b/fs/f2fs/segment.c
> > @@ -1379,6 +1379,8 @@ static int issue_discard_thread(void *data)
> >  	struct discard_policy dpolicy;
> >  	unsigned int wait_ms = DEF_MIN_DISCARD_ISSUE_TIME;
> >  	int issued;
> > +	unsigned long interval = sbi->interval_time[REQ_TIME] * HZ;
> > +	long delta;
> >  
> >  	set_freezable();
> >  
> > @@ -1410,7 +1412,11 @@ static int issue_discard_thread(void *data)
> >  			__wait_all_discard_cmd(sbi, &dpolicy);
> >  			wait_ms = dpolicy.min_interval;
> >  		} else if (issued == -1){
> > -			wait_ms = dpolicy.mid_interval;
> > +			delta = (sbi->last_time[REQ_TIME] + interval) - jiffies;
> 
> I agree that we need to consider power consumption. One more consideration is
> that discard thread may need different submission frequency comparing to garbage
> collection thread, maybe a little fast, would it be better to split
> sbi->interval_time[REQ_TIME] according to gc/discard type.
> 
> How do you think?
> 
> Thanks,
> 

Thanks for the review.

You mean when GC type is urgent? I see that for that case, the discard policy is
changed to DPOLICY_FORCE, which sets dpolicy->io_aware as false and hence,
cannot fall into this (issued == -1) case at all.

> > +			if (delta > 0)
> > +				wait_ms = jiffies_to_msecs(delta);
> > +			else
> > +				wait_ms = dpolicy.mid_interval;
> >  		} else {
> >  			wait_ms = dpolicy.max_interval;
> >  		}
> > 

-- 
--
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

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

* Re: [f2fs-dev] [PATCH] f2fs: fix unnecessary periodic wakeup of discard thread when dev is busy
  2018-09-02 10:34   ` Sahitya Tummala
@ 2018-09-02 12:56     ` Chao Yu
  0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2018-09-02 12:56 UTC (permalink / raw)
  To: Sahitya Tummala; +Cc: Jaegeuk Kim, Chao Yu, linux-f2fs-devel, linux-kernel

On 2018/9/2 18:34, Sahitya Tummala wrote:
> On Sun, Sep 02, 2018 at 04:52:40PM +0800, Chao Yu wrote:
>> On 2018/8/31 17:39, Sahitya Tummala wrote:
>>> When dev is busy, discard thread wake up timeout can be aligned with the
>>> exact time that it needs to wait for dev to come out of busy. This helps
>>> to avoid unnecessary periodic wakeups and thus save some power.
>>>
>>> Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
>>> ---
>>>  fs/f2fs/segment.c | 8 +++++++-
>>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
>>> index 8bcbb50..df14030 100644
>>> --- a/fs/f2fs/segment.c
>>> +++ b/fs/f2fs/segment.c
>>> @@ -1379,6 +1379,8 @@ static int issue_discard_thread(void *data)
>>>  	struct discard_policy dpolicy;
>>>  	unsigned int wait_ms = DEF_MIN_DISCARD_ISSUE_TIME;
>>>  	int issued;
>>> +	unsigned long interval = sbi->interval_time[REQ_TIME] * HZ;
>>> +	long delta;
>>>  
>>>  	set_freezable();
>>>  
>>> @@ -1410,7 +1412,11 @@ static int issue_discard_thread(void *data)
>>>  			__wait_all_discard_cmd(sbi, &dpolicy);
>>>  			wait_ms = dpolicy.min_interval;
>>>  		} else if (issued == -1){
>>> -			wait_ms = dpolicy.mid_interval;
>>> +			delta = (sbi->last_time[REQ_TIME] + interval) - jiffies;
>>
>> I agree that we need to consider power consumption. One more consideration is
>> that discard thread may need different submission frequency comparing to garbage
>> collection thread, maybe a little fast, would it be better to split
>> sbi->interval_time[REQ_TIME] according to gc/discard type.
>>
>> How do you think?
>>
>> Thanks,
>>
> 
> Thanks for the review.
> 
> You mean when GC type is urgent? I see that for that case, the discard policy is

Actually, I mean splitting sbi->interval_time[REQ_TIME] into:
- sbi->interval_time[GC_TIM] which can be used for GC thread.
- sbi->interval_time[DISCARD_TIME] which can be used for Discard thread.

Then we can configure sbi->interval_time[DISCARD_TIME] independently, and set
more suitable interval value for discard thread, since discard thread may need
to wake to submit discards more frequently.

I guess if we can accept above idea, it can be sent as another patch, so anyway,
I'm okay with your change. :)

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

> changed to DPOLICY_FORCE, which sets dpolicy->io_aware as false and hence,
> cannot fall into this (issued == -1) case at all.
> 
>>> +			if (delta > 0)
>>> +				wait_ms = jiffies_to_msecs(delta);
>>> +			else
>>> +				wait_ms = dpolicy.mid_interval;
>>>  		} else {
>>>  			wait_ms = dpolicy.max_interval;
>>>  		}
>>>
> 

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

end of thread, other threads:[~2018-09-02 12:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-31  9:39 [PATCH] f2fs: fix unnecessary periodic wakeup of discard thread when dev is busy Sahitya Tummala
2018-09-02  8:52 ` [f2fs-dev] " Chao Yu
2018-09-02 10:34   ` Sahitya Tummala
2018-09-02 12:56     ` Chao Yu

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