From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759870AbYJJNNj (ORCPT ); Fri, 10 Oct 2008 09:13:39 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1759435AbYJJNN1 (ORCPT ); Fri, 10 Oct 2008 09:13:27 -0400 Received: from ey-out-2122.google.com ([74.125.78.27]:19730 "EHLO ey-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756043AbYJJNN0 (ORCPT ); Fri, 10 Oct 2008 09:13:26 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; b=TMtbioDDOLM02rX+FL9JqYg4MFR/ud2cSkg0fkyn2yXl+rPHxc6xtO66OXeQDicofN Znps7ICrmdIqoSoqpOzfQ9/J/o2CjjX8wSyImLXUjN8NIkb2n0MgXND+uT+qhMnqc9Lv 7vlO4oDscaTJIeVOI1S4QmTxeSYSKpcJiMG5o= Message-ID: <48EF54EF.6040002@gmail.com> Date: Fri, 10 Oct 2008 15:13:19 +0200 From: Andrea Righi Reply-To: righi.andrea@gmail.com User-Agent: Thunderbird 2.0.0.17 (X11/20080925) MIME-Version: 1.0 To: KAMEZAWA Hiroyuki CC: balbir@linux.vnet.ibm.com, Michael Rubin , Andrew Morton , 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 , linux-mm@kvack.org, LKML Subject: Re: [PATCH -mm] page-writeback: fine-grained dirty_ratio and dirty_background_ratio References: <1221232192-13553-1-git-send-email-righi.andrea@gmail.com> <20080912131816.e0cfac7a.akpm@linux-foundation.org> <532480950809221641y3471267esff82a14be8056586@mail.gmail.com> <48EB4236.1060100@linux.vnet.ibm.com> <48EB851D.2030300@gmail.com> <20081008101642.fcfb9186.kamezawa.hiroyu@jp.fujitsu.com> <48ECB215.4040409@linux.vnet.ibm.com> <48EE236A.90007@gmail.com> <20081010094139.e7f8653d.kamezawa.hiroyu@jp.fujitsu.com> <48EF2138.9050307@gmail.com> In-Reply-To: <48EF2138.9050307@gmail.com> X-Enigmail-Version: 0.95.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Andrea Righi wrote: > KAMEZAWA Hiroyuki wrote: >> >> >>> -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 > Signed-off-by: KAMEZAWA Hiroyuki > --- > 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; From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by gv-out-0910.google.com with SMTP id l14so152377gvf.19 for ; Fri, 10 Oct 2008 06:13:24 -0700 (PDT) Message-ID: <48EF54EF.6040002@gmail.com> Date: Fri, 10 Oct 2008 15:13:19 +0200 From: Andrea Righi Reply-To: righi.andrea@gmail.com MIME-Version: 1.0 Subject: Re: [PATCH -mm] page-writeback: fine-grained dirty_ratio and dirty_background_ratio References: <1221232192-13553-1-git-send-email-righi.andrea@gmail.com> <20080912131816.e0cfac7a.akpm@linux-foundation.org> <532480950809221641y3471267esff82a14be8056586@mail.gmail.com> <48EB4236.1060100@linux.vnet.ibm.com> <48EB851D.2030300@gmail.com> <20081008101642.fcfb9186.kamezawa.hiroyu@jp.fujitsu.com> <48ECB215.4040409@linux.vnet.ibm.com> <48EE236A.90007@gmail.com> <20081010094139.e7f8653d.kamezawa.hiroyu@jp.fujitsu.com> <48EF2138.9050307@gmail.com> In-Reply-To: <48EF2138.9050307@gmail.com> Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org Return-Path: To: KAMEZAWA Hiroyuki Cc: balbir@linux.vnet.ibm.com, Michael Rubin , Andrew Morton , 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 , linux-mm@kvack.org, LKML List-ID: Andrea Righi wrote: > KAMEZAWA Hiroyuki wrote: >> >> >>> -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 > Signed-off-by: KAMEZAWA Hiroyuki > --- > 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: email@kvack.org