lkml.org 
[lkml]   [2008]   [Oct]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH -mm] page-writeback: fine-grained dirty_ratio and dirty_background_ratio
Andrea Righi wrote:
> KAMEZAWA Hiroyuki wrote:
>> <snip>
>>
>>> -int dirty_background_ratio = 5;
>>> +int dirty_background_ratio = 5 * PERCENT_PCM;
>>>
>>> /*
>>> * free highmem will not be subtracted from the total free memory
>>> @@ -77,7 +77,7 @@ int vm_highmem_is_dirtyable;
>>> /*
>>> * The generator of dirty data starts writeback at this percentage
>>> */
>>> -int vm_dirty_ratio = 10;
>>> +int vm_dirty_ratio = 10 * PERCENT_PCM;
>>>
>>> /*
>>> * The interval between `kupdate'-style writebacks, in jiffies
>>> @@ -135,7 +135,8 @@ static int calc_period_shift(void)
>>> {
>>> unsigned long dirty_total;
>>>
>>> - dirty_total = (vm_dirty_ratio * determine_dirtyable_memory()) / 100;
>>> + dirty_total = (vm_dirty_ratio * determine_dirtyable_memory())
>>> + / ONE_HUNDRED_PCM;
>>> return 2 + ilog2(dirty_total - 1);
>>> }
>>>
>> I wonder...isn't this overflow in 32bit system ?
>
> Correct! the worst case is (in pages):
>
> 4GB = 100,000 * determine_dirtyable_memory()
>
> that means 42950 pages (~168MB) of dirtyable memory is enough to overflow :(.
> Using an u64 for dirty_total should resolve.
>
> Delta patch is below.
>
> Unfortunately I have all 64-bit machines right now. Maybe tomorrow I'll
> be able to get a 32-bit box, if someone doesn't test this before.
>
> Thanks!
> -Andrea

I've been able to quickly resolve creating a 1GB mem i386 VM with kvm. :)

Everything seems to work fine and with the following fix it doesn't overflow.

-Andrea


>
> ---
> Subject: fix overflow in 32-bit systems using fine-grained dirty_ratio
>
> Signed-off-by: Andrea Righi <righi.andrea@gmail.com>
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> ---
> mm/page-writeback.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> index 6bc8c9b..29913e5 100644
> --- a/mm/page-writeback.c
> +++ b/mm/page-writeback.c
> @@ -133,7 +133,7 @@ static struct prop_descriptor vm_dirties;
> */
> static int calc_period_shift(void)
> {
> - unsigned long dirty_total;
> + u64 dirty_total;
>
> dirty_total = (vm_dirty_ratio * determine_dirtyable_memory())
> / ONE_HUNDRED_PCM;


\
 
 \ /
  Last update: 2008-10-10 15:17    [W:1.346 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site