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 15:00:05 +0800 Message-ID: <20101214070005.GB6940@localhost> References: <20101213144646.341970461@intel.com> <20101213150327.809762057@intel.com> 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: Sender: owner-linux-mm@kvack.org List-Id: linux-fsdevel.vger.kernel.org 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 there = are > > 100+ concurrent dirtiers. > > > > The more parallel dirtiers (1 dirtier =3D> 4 dirtiers), the smaller > > bandwidth each dirtier will share (bdi_bandwidth =3D> bdi_bandwidth/4= ), > > the less gap to the dirty limit ((C-A) =3D> (C-B)), the less stable t= he > > 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 large= r > > 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 =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=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=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 .....|...........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 =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 accordingly, > > 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-dirtiers > > 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.000000000= +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 tas= k_dirty_limit(current, bdi_thresh); > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 task_thresh =3D ta= sk_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 order 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_ban= dwidth(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 bdi_d= irty grows closer to bdi_thresh, it indicates more > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* concurrent= dirtiers. Proportionally lower the max throttle > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* bandwidth.= 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 t= ask_thresh, and help reduce fluctuations of pause > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* time when = 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->wr= ite_bandwidth; > > - > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0bw =3D bw * (b= di_thresh - bdi_dirty); > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 do_div(bw, bdi_thr= esh / BDI_SOFT_DIRTY_LIMIT + 1); > > + > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 bw =3D bw * (task_= 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. I'll show you another consistency of "shape" :) http://www.kernel.org/pub/linux/kernel/people/wfg/writeback/slides/light-= dirtier-control-line.svg http://www.kernel.org/pub/linux/kernel/people/wfg/writeback/slides/heavy-= dirtier-control-line.svg 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. Thanks, Fengguang -- 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/ . Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/ Don't email: email@kvack.org