[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <48EF54EF.6040002@gmail.com>
Date: Fri, 10 Oct 2008 15:13:19 +0200
From: Andrea Righi <righi.andrea@...il.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
CC: balbir@...ux.vnet.ibm.com, Michael Rubin <mrubin@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>, menage@...gle.com,
dave@...ux.vnet.ibm.com, chlunde@...g.uio.no, dpshah@...gle.com,
eric.rannaud@...il.com, fernando@....ntt.co.jp, agk@...rceware.org,
m.innocenti@...eca.it, s-uchida@...jp.nec.com, ryov@...inux.co.jp,
matt@...ehost.com, dradford@...ehost.com,
KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
linux-mm@...ck.org, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [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@...il.com>
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...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;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists