From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wu Fengguang Subject: Re: [PATCH 12/35] writeback: scale down max throttle bandwidth on concurrent dirtiers Date: Tue, 14 Dec 2010 21:00:18 +0800 Message-ID: <20101214130018.GA19424@localhost> References: <20101213144646.341970461@intel.com> <20101213150327.809762057@intel.com> <20101214070005.GB6940@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Andrew Morton , Jan Kara , Christoph Hellwig , Trond Myklebust , Dave Chinner , Theodore Ts'o , Chris Mason , Peter Zijlstra , Mel Gorman , Rik van Riel , KOSAKI Motohiro , Greg Thelen , Minchan Kim , linux-mm , "linux-fsdevel@vger.kernel.org" , LKML To: "Yan, Zheng" Return-path: Content-Disposition: inline In-Reply-To: <20101214070005.GB6940@localhost> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Tue, Dec 14, 2010 at 03:00:05PM +0800, Wu Fengguang wrote: > On Tue, Dec 14, 2010 at 09:21:19AM +0800, Yan Zheng wrote: > > On Mon, Dec 13, 2010 at 10:46 PM, Wu Fengguang wrote: > > > This will noticeably reduce the fluctuaions of pause time when th= ere are > > > 100+ concurrent dirtiers. > > > > > > The more parallel dirtiers (1 dirtier =3D> 4 dirtiers), the small= er > > > bandwidth each dirtier will share (bdi_bandwidth =3D> bdi_bandwid= th/4), > > > the less gap to the dirty limit ((C-A) =3D> (C-B)), the less stab= le the > > > pause time will be (given the same fluctuation of bdi_dirty). > > > > > > For example, if A drifts to A', its pause time may drift from 5ms= to > > > 6ms, while B to B' may drift from 50ms to 90ms. =C2=A0It's much l= arger > > > fluctuations in relative ratio as well as absolute time. > > > > > > Fig.1 before patch, gap (C-B) is too low to get smooth pause time > > > > > > throttle_bandwidth_A =3D bdi_bandwidth .........o > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0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A0| =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | o <=3D B' > > > ----------------------------------------------+-----------+---o > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0A =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 B =C2=A0 C > > > > > > The solution is to lower the slope of the throttle line according= ly, > > > which makes B stabilize at some point more far away from C. > > > > > > Fig.2 after patch > > > > > > throttle_bandwidth_A =3D bdi_bandwidth .........o > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0| o <=3D A' > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0| =C2=A0 o > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0| =C2=A0 =C2=A0 o > > > =C2=A0 =C2=A0lowered max throttle bandwidth for B =3D=3D=3D> * =C2= =A0 =C2=A0 =C2=A0 o > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0| =C2=A0 * =C2=A0 =C2=A0 o > > > throttle_bandwidth_B =3D bdi_bandwidth / 4 .............* =C2=A0 = o > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0| =C2=A0 =C2=A0 =C2=A0 | =C2=A0 * o > > > ----------------------------------------------+-------+-------o > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0A =C2=A0 =C2=A0 =C2=A0 B =C2=A0 =C2=A0 =C2=A0 C > > > > > > Note that C is actually different points for 1-dirty and 4-dirtie= rs > > > cases, but for easy graphing, we move them together. > > > > > > Signed-off-by: Wu Fengguang > > > --- > > > =C2=A0mm/page-writeback.c | =C2=A0 16 +++++++++++++--- > > > =C2=A01 file changed, 13 insertions(+), 3 deletions(-) > > > > > > --- linux-next.orig/mm/page-writeback.c 2010-12-13 21:46:14.00000= 0000 +0800 > > > +++ linux-next/mm/page-writeback.c =C2=A0 =C2=A0 =C2=A02010-12-13= 21:46:15.000000000 +0800 > > > @@ -587,6 +587,7 @@ static void balance_dirty_pages(struct a > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned long background_thresh; > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned long dirty_thresh; > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned long bdi_thresh; > > > + =C2=A0 =C2=A0 =C2=A0 unsigned long task_thresh; > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned long long bw; > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned long period; > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned long pause =3D 0; > > > @@ -616,7 +617,7 @@ static void balance_dirty_pages(struct a > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0break; > > > > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0bdi_thresh= =3D bdi_dirty_limit(bdi, dirty_thresh, nr_dirty); > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 bdi_thresh =3D= task_dirty_limit(current, bdi_thresh); > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 task_thresh =3D= task_dirty_limit(current, bdi_thresh); > > > > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 * In orde= r to avoid the stacked BDI deadlock we need > > > @@ -638,14 +639,23 @@ static void balance_dirty_pages(struct a > > > > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0bdi_update= _bandwidth(bdi, start_time, bdi_dirty, bdi_thresh); > > > > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (bdi_dirty = >=3D bdi_thresh || nr_dirty > dirty_thresh) { > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (bdi_dirty = >=3D task_thresh || nr_dirty > dirty_thresh) { > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0pause =3D MAX_PAUSE; > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0goto pause; > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} > > > > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* When b= di_dirty grows closer to bdi_thresh, it indicates more > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* concur= rent dirtiers. Proportionally lower the max throttle > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* bandwi= dth. This will resist bdi_dirty from approaching to > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* close = to task_thresh, and help reduce fluctuations of pause > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* time w= hen there are lots of dirtiers. > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*/ > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0bw =3D bdi= ->write_bandwidth; > > > - > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0bw =3D bw = * (bdi_thresh - bdi_dirty); > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 do_div(bw, bdi= _thresh / BDI_SOFT_DIRTY_LIMIT + 1); > > > + > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 bw =3D bw * (t= ask_thresh - bdi_dirty); > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0do_div(bw,= bdi_thresh / TASK_SOFT_DIRTY_LIMIT + 1); > >=20 > > Maybe changing this line to "do_div(bw, task_thresh / > > TASK_SOFT_DIRTY_LIMIT + 1);" > > is more consistent. >=20 > I'll show you another consistency of "shape" :) >=20 > http://www.kernel.org/pub/linux/kernel/people/wfg/writeback/slides/li= ght-dirtier-control-line.svg > http://www.kernel.org/pub/linux/kernel/people/wfg/writeback/slides/he= avy-dirtier-control-line.svg >=20 > In the above two figures, the overall control lines for light/heavy > dirtier tasks have exactly the same shape -- it's merely shifted in > the X axis direction. So the current form is actually more simple. Sorry it's not the overall control lines that's simply shifted, but the task control line. bdi control line: > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0bw =3D bw = * (bdi_thresh - bdi_dirty); > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 do_div(bw, bdi= _thresh / BDI_SOFT_DIRTY_LIMIT + 1); task control line: > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 bw =3D bw * (t= ask_thresh - bdi_dirty); > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0do_div(bw,= bdi_thresh / TASK_SOFT_DIRTY_LIMIT + 1); The use of bdi_thresh in the last line makes sure all task control lines are of the same slope. Thanks, =46engguang