lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Mon, 22 Nov 2010 10:54:13 +0100
From:	Michal Hocko <mhocko@...e.cz>
To:	Wu Fengguang <fengguang.wu@...el.com>
Cc:	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Rik van Riel <riel@...hat.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Jan Kara <jack@...e.cz>, "Li, Shaohua" <shaohua.li@...el.com>,
	Christoph Hellwig <hch@....de>,
	Dave Chinner <david@...morbit.com>,
	Theodore Ts'o <tytso@....edu>,
	Chris Mason <chris.mason@...cle.com>,
	Mel Gorman <mel@....ul.ie>,
	KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
	linux-mm <linux-mm@...ck.org>,
	"linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] writeback: prevent bandwidth calculation overflow

On Sat 20-11-10 02:44:08, Wu Fengguang wrote:
> On Sat, Nov 20, 2010 at 12:06:53AM +0800, Michal Hocko wrote:
> > On Fri 19-11-10 00:13:56, Wu Fengguang wrote:
> > > On Fri, Nov 19, 2010 at 12:02:01AM +0800, Peter Zijlstra wrote:
> > > > On Thu, 2010-11-18 at 23:44 +0800, Wu Fengguang wrote:
> > > > > +               pause = HZ * pages_dirtied / (bw + 1);
> > > > 
> > > > Shouldn't that be using something like div64_u64 ?
> > > 
> > > Thanks for review. Here is the updated patch using div64_u64().
> > > 
> > > ---
> > > Subject: writeback: prevent bandwidth calculation overflow
> > > Date: Thu Nov 18 12:55:42 CST 2010
> > > 
> > > On 32bit kernel, bdi->write_bandwidth can express at most 4GB/s.
> > > 
> > > However the current calculation code can overflow when disk bandwidth
> > > reaches 800MB/s.  Fix it by using "long long" and div64_u64() in the
> > > calculations.
> > > 
> > > And further change its unit from bytes/second to pages/second.
> > > That allows up to 16TB/s bandwidth in 32bit kernel.
> > > 
> > > CC: Peter Zijlstra <a.p.zijlstra@...llo.nl>
> > > Acked-by: Rik van Riel <riel@...hat.com>
> > > Signed-off-by: Wu Fengguang <fengguang.wu@...el.com>
> > > ---
> > >  mm/backing-dev.c    |    4 ++--
> > >  mm/page-writeback.c |   11 +++++------
> > >  2 files changed, 7 insertions(+), 8 deletions(-)
> > > 
> > > --- linux-next.orig/mm/page-writeback.c	2010-11-18 12:42:58.000000000 +0800
> > > +++ linux-next/mm/page-writeback.c	2010-11-19 00:08:23.000000000 +0800
> > > @@ -494,7 +494,7 @@ void bdi_update_write_bandwidth(struct b
> > >  	unsigned long written;
> > >  	unsigned long elapsed;
> > >  	unsigned long bw;
> > > -	unsigned long w;
> > > +	unsigned long long w;
> > >  
> > >  	if (*bw_written == 0)
> > >  		goto snapshot;
> > > @@ -513,7 +513,7 @@ void bdi_update_write_bandwidth(struct b
> > >  		goto snapshot;
> > >  
> > >  	written = percpu_counter_read(&bdi->bdi_stat[BDI_WRITTEN]) - *bw_written;
> > > -	bw = (HZ * PAGE_CACHE_SIZE * written + elapsed/2) / elapsed;
> > > +	bw = (HZ * written + elapsed/2) / elapsed;
> > 
> > Sorry for a dumb question, but where did PAGE_CACHE_SIZE part go?
> 
> Because write_bandwidth's unit is bumped from bytes/s to pages/s,
> so that it can express much higher bandwidth.

Ahh, I can see it now.
Thanks
-- 
Michal Hocko
L3 team 
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ