From: Andrea Righi <righi.andrea@gmail.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: balbir@linux.vnet.ibm.com, Michael Rubin <mrubin@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
menage@google.com, dave@linux.vnet.ibm.com, chlunde@ping.uio.no,
dpshah@google.com, eric.rannaud@gmail.com,
fernando@oss.ntt.co.jp, agk@sourceware.org,
m.innocenti@cineca.it, s-uchida@ap.jp.nec.com,
ryov@valinux.co.jp, matt@bluehost.com, dradford@bluehost.com,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
linux-mm@kvack.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -mm] page-writeback: fine-grained dirty_ratio and dirty_background_ratio
Date: Fri, 10 Oct 2008 15:13:19 +0200 [thread overview]
Message-ID: <48EF54EF.6040002@gmail.com> (raw)
In-Reply-To: <48EF2138.9050307@gmail.com>
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;
WARNING: multiple messages have this Message-ID (diff)
From: Andrea Righi <righi.andrea@gmail.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: balbir@linux.vnet.ibm.com, Michael Rubin <mrubin@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
menage@google.com, dave@linux.vnet.ibm.com, chlunde@ping.uio.no,
dpshah@google.com, eric.rannaud@gmail.com,
fernando@oss.ntt.co.jp, agk@sourceware.org,
m.innocenti@cineca.it, s-uchida@ap.jp.nec.com,
ryov@valinux.co.jp, matt@bluehost.com, dradford@bluehost.com,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
linux-mm@kvack.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -mm] page-writeback: fine-grained dirty_ratio and dirty_background_ratio
Date: Fri, 10 Oct 2008 15:13:19 +0200 [thread overview]
Message-ID: <48EF54EF.6040002@gmail.com> (raw)
In-Reply-To: <48EF2138.9050307@gmail.com>
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;
--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2008-10-10 13:13 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-12 15:09 [RFC] [PATCH -mm 0/2] memcg: per cgroup dirty_ratio Andrea Righi
[not found] ` <1221232192-13553-1-git-send-email-righi.andrea-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2008-09-12 20:18 ` Andrew Morton
2008-09-12 20:18 ` Andrew Morton
2008-09-12 23:04 ` Andrea Righi
[not found] ` <48CAF583.8060406-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2008-09-12 23:10 ` Andrew Morton
2008-09-12 23:10 ` Andrew Morton
[not found] ` <20080912161050.5b6b4065.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
2008-09-22 22:26 ` Michael Rubin
2008-09-22 22:26 ` Michael Rubin
2008-09-22 23:41 ` Michael Rubin
[not found] ` <532480950809221641y3471267esff82a14be8056586-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-09-23 12:50 ` Andrea Righi
2008-09-23 17:48 ` KOSAKI Motohiro
2008-10-07 11:04 ` Balbir Singh
2008-09-23 12:50 ` Andrea Righi
2008-09-23 17:48 ` KOSAKI Motohiro
2008-09-23 20:21 ` Michael Rubin
[not found] ` <532480950809231321g7be0dd09pe6a32426b361e676-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-09-24 6:59 ` KOSAKI Motohiro
2008-09-24 6:59 ` KOSAKI Motohiro
[not found] ` <20080924024437.DC21.KOSAKI.MOTOHIRO-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2008-09-23 20:21 ` Michael Rubin
2008-10-07 10:35 ` Andrea Righi
2008-10-07 10:35 ` Andrea Righi
2008-10-07 11:04 ` Balbir Singh
2008-10-07 15:49 ` Andrea Righi
[not found] ` <48EB851D.2030300-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2008-10-08 1:16 ` KAMEZAWA Hiroyuki
2008-10-08 1:16 ` KAMEZAWA Hiroyuki
[not found] ` <20081008101642.fcfb9186.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2008-10-08 13:13 ` Balbir Singh
2008-10-08 13:13 ` Balbir Singh
2008-10-09 15:29 ` [PATCH -mm] page-writeback: fine-grained dirty_ratio and dirty_background_ratio Andrea Righi
2008-10-09 15:29 ` Andrea Righi
2008-10-10 0:41 ` KAMEZAWA Hiroyuki
2008-10-10 0:41 ` KAMEZAWA Hiroyuki
2008-10-10 9:32 ` Andrea Righi
2008-10-10 9:32 ` Andrea Righi
2008-10-10 13:13 ` Andrea Righi [this message]
2008-10-10 13:13 ` Andrea Righi
2008-11-10 20:58 ` [PATCH -mm] mm: fine-grained dirty_ratio_pcm and dirty_background_ratio_pcm (v2) Andrea Righi
2008-11-10 20:58 ` Andrea Righi
[not found] ` <4918A074.1050003-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2008-11-10 21:12 ` Andrew Morton
2008-11-10 21:12 ` Andrew Morton
2008-11-10 21:12 ` Andrew Morton
2008-11-10 22:03 ` Andrea Righi
2008-11-10 22:03 ` Andrea Righi
[not found] ` <4918AFA1.4000102-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2008-11-10 22:12 ` Andrew Morton
2008-11-10 22:12 ` Andrew Morton
2008-11-10 22:12 ` Andrew Morton
2008-11-10 22:15 ` David Rientjes
2008-11-10 22:15 ` David Rientjes
2008-11-10 22:15 ` David Rientjes
[not found] ` <48EB4236.1060100-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2008-10-07 15:49 ` [RFC] [PATCH -mm 0/2] memcg: per cgroup dirty_ratio Andrea Righi
[not found] ` <20080912131816.e0cfac7a.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
2008-09-12 23:04 ` Andrea Righi
2008-09-22 23:41 ` Michael Rubin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48EF54EF.6040002@gmail.com \
--to=righi.andrea@gmail.com \
--cc=agk@sourceware.org \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=chlunde@ping.uio.no \
--cc=dave@linux.vnet.ibm.com \
--cc=dpshah@google.com \
--cc=dradford@bluehost.com \
--cc=eric.rannaud@gmail.com \
--cc=fernando@oss.ntt.co.jp \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=m.innocenti@cineca.it \
--cc=matt@bluehost.com \
--cc=menage@google.com \
--cc=mrubin@google.com \
--cc=ryov@valinux.co.jp \
--cc=s-uchida@ap.jp.nec.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.