linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] Add check for dirty_writeback_interval in bdi_wakeup_thread_delayed
@ 2011-04-17 16:23 Raghavendra D Prabhu
  2011-04-18  0:02 ` Dave Chinner
  2011-04-18  7:19 ` Artem Bityutskiy
  0 siblings, 2 replies; 7+ messages in thread
From: Raghavendra D Prabhu @ 2011-04-17 16:23 UTC (permalink / raw)
  To: linux-mm
  Cc: Artem Bityutskiy, Jens Axboe, Christoph Hellwig, Andrew Morton,
	linux-kernel

In the function bdi_wakeup_thread_delayed, no checks are performed on
dirty_writeback_interval unlike other places and timeout is being set to
zero as result, thus defeating the purpose. So, I have changed it to be
passed default value of interval which is 500 centiseconds, when it is
set to zero.
I have also verified this and tested it.

Signed-off-by: Raghavendra D Prabhu <rprabhu@wnohang.net>
---
  mm/backing-dev.c |    5 ++++-
  1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index befc875..d06533c 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -336,7 +336,10 @@ void bdi_wakeup_thread_delayed(struct backing_dev_info *bdi)
  {
  	unsigned long timeout;
  
-	timeout = msecs_to_jiffies(dirty_writeback_interval * 10);
+	if (dirty_writeback_interval)
+		timeout = msecs_to_jiffies(dirty_writeback_interval * 10);
+	else
+		timeout = msecs_to_jiffies(5000);
  	mod_timer(&bdi->wb.wakeup_timer, jiffies + timeout);
  }
  
-- 
1.7.4.4

--------------------------
Raghavendra Prabhu
GPG Id : D72BE977

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH 1/1] Add check for dirty_writeback_interval in bdi_wakeup_thread_delayed
  2011-04-17 16:23 [PATCH 1/1] Add check for dirty_writeback_interval in bdi_wakeup_thread_delayed Raghavendra D Prabhu
@ 2011-04-18  0:02 ` Dave Chinner
  2011-04-18  7:08   ` [TOME] " Raghavendra D Prabhu
  2011-04-18  7:19 ` Artem Bityutskiy
  1 sibling, 1 reply; 7+ messages in thread
From: Dave Chinner @ 2011-04-18  0:02 UTC (permalink / raw)
  To: Raghavendra D Prabhu
  Cc: linux-mm, Artem Bityutskiy, Jens Axboe, Christoph Hellwig,
	Andrew Morton, linux-kernel

On Sun, Apr 17, 2011 at 09:53:08PM +0530, Raghavendra D Prabhu wrote:
> In the function bdi_wakeup_thread_delayed, no checks are performed on
> dirty_writeback_interval unlike other places and timeout is being set to
> zero as result, thus defeating the purpose. So, I have changed it to be
> passed default value of interval which is 500 centiseconds, when it is
> set to zero.
> I have also verified this and tested it.
> 
> Signed-off-by: Raghavendra D Prabhu <rprabhu@wnohang.net>
> ---
>  mm/backing-dev.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/mm/backing-dev.c b/mm/backing-dev.c
> index befc875..d06533c 100644
> --- a/mm/backing-dev.c
> +++ b/mm/backing-dev.c
> @@ -336,7 +336,10 @@ void bdi_wakeup_thread_delayed(struct backing_dev_info *bdi)
>  {
>  	unsigned long timeout;
> -	timeout = msecs_to_jiffies(dirty_writeback_interval * 10);
> +	if (dirty_writeback_interval)
> +		timeout = msecs_to_jiffies(dirty_writeback_interval * 10);
> +	else
> +		timeout = msecs_to_jiffies(5000);
>  	mod_timer(&bdi->wb.wakeup_timer, jiffies + timeout);
>  }

Isn't the problem that the sysctl handler does not have a min/max
valid value set? I.e. to prevent invalid values from being set in
the first place?

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [TOME] Re: [PATCH 1/1] Add check for dirty_writeback_interval in bdi_wakeup_thread_delayed
  2011-04-18  0:02 ` Dave Chinner
@ 2011-04-18  7:08   ` Raghavendra D Prabhu
  0 siblings, 0 replies; 7+ messages in thread
From: Raghavendra D Prabhu @ 2011-04-18  7:08 UTC (permalink / raw)
  To: Dave Chinner
  Cc: linux-mm, Artem Bityutskiy, Jens Axboe, Christoph Hellwig,
	Andrew Morton, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1574 bytes --]

* On Mon, Apr 18, 2011 at 10:02:04AM +1000, Dave Chinner <david@fromorbit.com> wrote:
>On Sun, Apr 17, 2011 at 09:53:08PM +0530, Raghavendra D Prabhu wrote:
>> In the function bdi_wakeup_thread_delayed, no checks are performed on
>> dirty_writeback_interval unlike other places and timeout is being set to
>> zero as result, thus defeating the purpose. So, I have changed it to be
>> passed default value of interval which is 500 centiseconds, when it is
>> set to zero.
>> I have also verified this and tested it.

>> Signed-off-by: Raghavendra D Prabhu <rprabhu@wnohang.net>
>> ---
>>  mm/backing-dev.c |    5 ++++-
>>  1 files changed, 4 insertions(+), 1 deletions(-)

>> diff --git a/mm/backing-dev.c b/mm/backing-dev.c
>> index befc875..d06533c 100644
>> --- a/mm/backing-dev.c
>> +++ b/mm/backing-dev.c
>> @@ -336,7 +336,10 @@ void bdi_wakeup_thread_delayed(struct backing_dev_info *bdi)
>>  {
>>  	unsigned long timeout;
>> -	timeout = msecs_to_jiffies(dirty_writeback_interval * 10);
>> +	if (dirty_writeback_interval)
>> +		timeout = msecs_to_jiffies(dirty_writeback_interval * 10);
>> +	else
>> +		timeout = msecs_to_jiffies(5000);
>>  	mod_timer(&bdi->wb.wakeup_timer, jiffies + timeout);
>>  }
>
>Isn't the problem that the sysctl handler does not have a min/max
>valid value set? I.e. to prevent invalid values from being set in
>the first place?
>
>Cheers,
>
>Dave.
0 is a valid value for dirty_writeback_interval which according to the
definition/documentation is disabled when set to 0. In other places, a constraint
check is done on that value except here.

[-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --]

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

* Re: [PATCH 1/1] Add check for dirty_writeback_interval in bdi_wakeup_thread_delayed
  2011-04-17 16:23 [PATCH 1/1] Add check for dirty_writeback_interval in bdi_wakeup_thread_delayed Raghavendra D Prabhu
  2011-04-18  0:02 ` Dave Chinner
@ 2011-04-18  7:19 ` Artem Bityutskiy
  2011-04-18  9:16   ` Raghavendra D Prabhu
  1 sibling, 1 reply; 7+ messages in thread
From: Artem Bityutskiy @ 2011-04-18  7:19 UTC (permalink / raw)
  To: Raghavendra D Prabhu
  Cc: linux-mm, Jens Axboe, Christoph Hellwig, Andrew Morton,
	linux-kernel

On Sun, 2011-04-17 at 21:53 +0530, Raghavendra D Prabhu wrote:
> In the function bdi_wakeup_thread_delayed, no checks are performed on
> dirty_writeback_interval unlike other places and timeout is being set to
> zero as result, thus defeating the purpose. So, I have changed it to be
> passed default value of interval which is 500 centiseconds, when it is
> set to zero.
> I have also verified this and tested it.
> 
> Signed-off-by: Raghavendra D Prabhu <rprabhu@wnohang.net>

If  dirty_writeback_interval then the periodic write-back has to be
disabled. Which means we should rather do something like this:

diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 0d9a036..f38722c 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -334,10 +334,12 @@ static void wakeup_timer_fn(unsigned long data)
  */
 void bdi_wakeup_thread_delayed(struct backing_dev_info *bdi)
 {
-       unsigned long timeout;
+       if (dirty_writeback_interval) {
+               unsigned long timeout;
 
-       timeout = msecs_to_jiffies(dirty_writeback_interval * 10);
-       mod_timer(&bdi->wb.wakeup_timer, jiffies + timeout);
+               timeout = msecs_to_jiffies(dirty_writeback_interval * 10);
+               mod_timer(&bdi->wb.wakeup_timer, jiffies + timeout);
+       }
 }

I do not see why you use 500 centisecs instead - I think this is wrong.

> ---
>   mm/backing-dev.c |    5 ++++-
>   1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/mm/backing-dev.c b/mm/backing-dev.c
> index befc875..d06533c 100644
> --- a/mm/backing-dev.c
> +++ b/mm/backing-dev.c
> @@ -336,7 +336,10 @@ void bdi_wakeup_thread_delayed(struct backing_dev_info *bdi)
>   {
>   	unsigned long timeout;
>   
> -	timeout = msecs_to_jiffies(dirty_writeback_interval * 10);
> +	if (dirty_writeback_interval)
> +		timeout = msecs_to_jiffies(dirty_writeback_interval * 10);
> +	else
> +		timeout = msecs_to_jiffies(5000);
>   	mod_timer(&bdi->wb.wakeup_timer, jiffies + timeout);
>   }
>   


-- 
Best Regards,
Artem Bityutskiy (D?N?N?N?D 1/4  D?D,N?N?N?DoD,D1)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH 1/1] Add check for dirty_writeback_interval in bdi_wakeup_thread_delayed
  2011-04-18  7:19 ` Artem Bityutskiy
@ 2011-04-18  9:16   ` Raghavendra D Prabhu
  2011-04-18 12:26     ` Artem Bityutskiy
  0 siblings, 1 reply; 7+ messages in thread
From: Raghavendra D Prabhu @ 2011-04-18  9:16 UTC (permalink / raw)
  To: Artem Bityutskiy
  Cc: linux-mm, Jens Axboe, Christoph Hellwig, Andrew Morton,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2776 bytes --]

* On Mon, Apr 18, 2011 at 10:19:12AM +0300, Artem Bityutskiy <Artem.Bityutskiy@nokia.com> wrote:
>On Sun, 2011-04-17 at 21:53 +0530, Raghavendra D Prabhu wrote:
>> In the function bdi_wakeup_thread_delayed, no checks are performed on
>> dirty_writeback_interval unlike other places and timeout is being set to
>> zero as result, thus defeating the purpose. So, I have changed it to be
>> passed default value of interval which is 500 centiseconds, when it is
>> set to zero.
>> I have also verified this and tested it.

>> Signed-off-by: Raghavendra D Prabhu <rprabhu@wnohang.net>
>
>If  dirty_writeback_interval then the periodic write-back has to be
>disabled. Which means we should rather do something like this:
>
>diff --git a/mm/backing-dev.c b/mm/backing-dev.c
>index 0d9a036..f38722c 100644
>--- a/mm/backing-dev.c
>+++ b/mm/backing-dev.c
>@@ -334,10 +334,12 @@ static void wakeup_timer_fn(unsigned long data)
>  */
> void bdi_wakeup_thread_delayed(struct backing_dev_info *bdi)
> {
>-       unsigned long timeout;
>+       if (dirty_writeback_interval) {
>+               unsigned long timeout;
>
>-       timeout = msecs_to_jiffies(dirty_writeback_interval * 10);
>-       mod_timer(&bdi->wb.wakeup_timer, jiffies + timeout);
>+               timeout = msecs_to_jiffies(dirty_writeback_interval * 10);
>+               mod_timer(&bdi->wb.wakeup_timer, jiffies + timeout);
>+       }
> }
>
>I do not see why you use 500 centisecs instead - I think this is wrong.
>
>> ---
>>   mm/backing-dev.c |    5 ++++-
>>   1 files changed, 4 insertions(+), 1 deletions(-)

>> diff --git a/mm/backing-dev.c b/mm/backing-dev.c
>> index befc875..d06533c 100644
>> --- a/mm/backing-dev.c
>> +++ b/mm/backing-dev.c
>> @@ -336,7 +336,10 @@ void bdi_wakeup_thread_delayed(struct backing_dev_info *bdi)
>>   {
>>   	unsigned long timeout;

>> -	timeout = msecs_to_jiffies(dirty_writeback_interval * 10);
>> +	if (dirty_writeback_interval)
>> +		timeout = msecs_to_jiffies(dirty_writeback_interval * 10);
>> +	else
>> +		timeout = msecs_to_jiffies(5000);
>>   	mod_timer(&bdi->wb.wakeup_timer, jiffies + timeout);
>>   }
Hi,

I have set it to 500 centisecs as that is the default value of
dirty_writeback_interval. I used this logic for following reason: the
purpose for which dirty_writeback_interval is set to 0 is to disable
periodic writeback
(http://tomoyo.sourceforge.jp/cgi-bin/lxr/source/fs/fs-writeback.c#L818)
, whereas here (in bdi_wakeup_thread_delayed) it is being used for a
different purpose -- to delay the bdi wakeup in order to reduce context
switches for  dirty inode writeback.
Regarding the change you made: in
that case won't it end up disabling the timer altogether ? which
shouldn't happen given the original purpose of defining
dirty_writeback_interval to zero.

[-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --]

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

* Re: [PATCH 1/1] Add check for dirty_writeback_interval in bdi_wakeup_thread_delayed
  2011-04-18  9:16   ` Raghavendra D Prabhu
@ 2011-04-18 12:26     ` Artem Bityutskiy
  2011-04-20 19:17       ` Raghavendra D Prabhu
  0 siblings, 1 reply; 7+ messages in thread
From: Artem Bityutskiy @ 2011-04-18 12:26 UTC (permalink / raw)
  To: Raghavendra D Prabhu
  Cc: linux-mm, Jens Axboe, Christoph Hellwig, Andrew Morton,
	linux-kernel

On Mon, 2011-04-18 at 14:46 +0530, Raghavendra D Prabhu wrote:
> I have set it to 500 centisecs as that is the default value of
> dirty_writeback_interval. I used this logic for following reason: the
> purpose for which dirty_writeback_interval is set to 0 is to disable
> periodic writeback
> (http://tomoyo.sourceforge.jp/cgi-bin/lxr/source/fs/fs-writeback.c#L818)
> , whereas here (in bdi_wakeup_thread_delayed) it is being used for a
> different purpose -- to delay the bdi wakeup in order to reduce context
> switches for  dirty inode writeback.

But why it wakes up the bdi thread? Exactly to make sure the periodic
write-back happen.

-- 
Best Regards,
Artem Bityutskiy (D?N?N?N?D 1/4  D?D,N?N?N?DoD,D1)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH 1/1] Add check for dirty_writeback_interval in bdi_wakeup_thread_delayed
  2011-04-18 12:26     ` Artem Bityutskiy
@ 2011-04-20 19:17       ` Raghavendra D Prabhu
  0 siblings, 0 replies; 7+ messages in thread
From: Raghavendra D Prabhu @ 2011-04-20 19:17 UTC (permalink / raw)
  To: Artem Bityutskiy
  Cc: linux-mm, Jens Axboe, Christoph Hellwig, Andrew Morton,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1277 bytes --]

* On Mon, Apr 18, 2011 at 03:26:29PM +0300, Artem Bityutskiy <Artem.Bityutskiy@nokia.com> wrote:
>On Mon, 2011-04-18 at 14:46 +0530, Raghavendra D Prabhu wrote:
>> I have set it to 500 centisecs as that is the default value of
>> dirty_writeback_interval. I used this logic for following reason: the
>> purpose for which dirty_writeback_interval is set to 0 is to disable
>> periodic writeback
>> (http://tomoyo.sourceforge.jp/cgi-bin/lxr/source/fs/fs-writeback.c#L818)
>> , whereas here (in bdi_wakeup_thread_delayed) it is being used for a
>> different purpose -- to delay the bdi wakeup in order to reduce context
>> switches for  dirty inode writeback.
>
>But why it wakes up the bdi thread? Exactly to make sure the periodic
>write-back happen.
I checked the callgraph of bdi_wakeup_thread_delayed and found out that
even though it may be called in the aftermath of wb_do_writeback(), it
is certainly called in the call-chain of sync. So effectively making
that function do nothing when dirty_writeback_interval is unset will
also make sync do nothing. On the other hand, not applying the original
change at all will make it run instantly (jiffies + 0, 0 being the
writeback interval in this case ) thus reversing the benefits of
d7dd01adc098eadc5d5fb07a7d2bf942d09b15df.

[-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --]

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

end of thread, other threads:[~2011-04-20 19:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-17 16:23 [PATCH 1/1] Add check for dirty_writeback_interval in bdi_wakeup_thread_delayed Raghavendra D Prabhu
2011-04-18  0:02 ` Dave Chinner
2011-04-18  7:08   ` [TOME] " Raghavendra D Prabhu
2011-04-18  7:19 ` Artem Bityutskiy
2011-04-18  9:16   ` Raghavendra D Prabhu
2011-04-18 12:26     ` Artem Bityutskiy
2011-04-20 19:17       ` Raghavendra D Prabhu

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