From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Subject: Re: [PATCH 06/13] writeback: bdi write bandwidth estimation Date: Wed, 24 Nov 2010 12:05:32 +0100 Message-ID: <1290596732.2072.450.camel@laptop> References: <20101117042720.033773013@intel.com> <20101117042850.002299964@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Cc: Andrew Morton , Jan Kara , Li Shaohua , Christoph Hellwig , Dave Chinner , Theodore Ts'o , Chris Mason , Mel Gorman , Rik van Riel , KOSAKI Motohiro , linux-mm , linux-fsdevel@vger.kernel.org, LKML To: Wu Fengguang Return-path: In-Reply-To: <20101117042850.002299964@intel.com> Sender: owner-linux-mm@kvack.org List-Id: linux-fsdevel.vger.kernel.org On Wed, 2010-11-17 at 12:27 +0800, Wu Fengguang wrote: > +void bdi_update_write_bandwidth(struct backing_dev_info *bdi, > + unsigned long *bw_time, > + s64 *bw_written) > +{ > + unsigned long written; > + unsigned long elapsed; > + unsigned long bw; > + unsigned long w; > + > + if (*bw_written =3D=3D 0) > + goto snapshot; > + > + elapsed =3D jiffies - *bw_time; > + if (elapsed < HZ/100) > + return; > + > + /* > + * When there lots of tasks throttled in balance_dirty_pages(), t= hey > + * will each try to update the bandwidth for the same period, mak= ing > + * the bandwidth drift much faster than the desired rate (as in t= he > + * single dirtier case). So do some rate limiting. > + */ > + if (jiffies - bdi->write_bandwidth_update_time < elapsed) > + goto snapshot; Why this goto snapshot and not simply return? This is the second call (bdi_update_bandwidth equivalent). If you were to leave the old bw_written/bw_time in place the next loop around in wb_writeback() would see a larger delta.. I guess this funny loop in wb_writeback() is also the reason you've got a single function and not the get/update like separation > + written =3D percpu_counter_read(&bdi->bdi_stat[BDI_WRITTEN]) - *b= w_written; > + bw =3D (HZ * PAGE_CACHE_SIZE * written + elapsed/2) / elapsed; > + w =3D min(elapsed / (HZ/100), 128UL); > + bdi->write_bandwidth =3D (bdi->write_bandwidth * (1024-w) + bw * = w) >> 10; > + bdi->write_bandwidth_update_time =3D jiffies; > +snapshot: > + *bw_written =3D percpu_counter_read(&bdi->bdi_stat[BDI_WRITTEN]); > + *bw_time =3D jiffies; > +}=20 -- 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