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 <[email protected]>
---
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
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 <[email protected]>
> ---
> 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
[email protected]
* On Mon, Apr 18, 2011 at 10:02:04AM +1000, Dave Chinner <[email protected]> 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 <[email protected]>
>> ---
>> 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.
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 <[email protected]>
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 (Артём Битюцкий)
* On Mon, Apr 18, 2011 at 10:19:12AM +0300, Artem Bityutskiy <[email protected]> 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 <[email protected]>
>
>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.
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 (Артём Битюцкий)
* On Mon, Apr 18, 2011 at 03:26:29PM +0300, Artem Bityutskiy <[email protected]> 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.