From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Subject: Re: [PATCH 3/5] mm: Implement IO-less balance_dirty_pages() Date: Fri, 04 Feb 2011 14:09:16 +0100 Message-ID: <1296824956.26581.650.camel@laptop> References: <1296783534-11585-1-git-send-email-jack@suse.cz> <1296783534-11585-4-git-send-email-jack@suse.cz> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Christoph Hellwig , Dave Chinner , Wu Fengguang To: Jan Kara Return-path: Received: from bombadil.infradead.org ([18.85.46.34]:60140 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752701Ab1BDNP6 (ORCPT ); Fri, 4 Feb 2011 08:15:58 -0500 Received: from canuck.infradead.org ([2001:4978:20e::1]) by bombadil.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1PlLW1-0005Cq-UO for linux-fsdevel@vger.kernel.org; Fri, 04 Feb 2011 13:15:58 +0000 Received: from j77219.upc-j.chello.nl ([24.132.77.219] helo=dyad.programming.kicks-ass.net) by canuck.infradead.org with esmtpsa (Exim 4.72 #1 (Red Hat Linux)) id 1PlLW1-0001mk-0r for linux-fsdevel@vger.kernel.org; Fri, 04 Feb 2011 13:15:57 +0000 In-Reply-To: <1296783534-11585-4-git-send-email-jack@suse.cz> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri, 2011-02-04 at 02:38 +0100, Jan Kara wrote: > +static int check_dirty_limits(struct backing_dev_info *bdi, > + struct dirty_limit_state *pst) > +{ > + struct dirty_limit_state st; > + unsigned long bdi_thresh; > + unsigned long min_bdi_thresh; > + int ret = DIRTY_OK; > > + get_global_dirty_limit_state(&st); > + /* > + * Throttle it only when the background writeback cannot catch-up. This > + * avoids (excessively) small writeouts when the bdi limits are ramping > + * up. > + */ > + if (st.nr_reclaimable + st.nr_writeback <= > + (st.background_thresh + st.dirty_thresh) / 2) > + goto out; > > + get_bdi_dirty_limit_state(bdi, &st); > + min_bdi_thresh = task_min_dirty_limit(st.bdi_thresh); > + bdi_thresh = task_dirty_limit(current, st.bdi_thresh); > + > + /* > + * The bdi thresh is somehow "soft" limit derived from the global > + * "hard" limit. The former helps to prevent heavy IO bdi or process > + * from holding back light ones; The latter is the last resort > + * safeguard. > + */ > + if ((st.bdi_nr_reclaimable + st.bdi_nr_writeback > bdi_thresh) > + || (st.nr_reclaimable + st.nr_writeback > st.dirty_thresh)) { > + ret = DIRTY_EXCEED_LIMIT; > + goto out; > + } > + if (st.bdi_nr_reclaimable + st.bdi_nr_writeback > min_bdi_thresh) { > + ret = DIRTY_MAY_EXCEED_LIMIT; > + goto out; > + } > + if (st.nr_reclaimable > st.background_thresh) > + ret = DIRTY_EXCEED_BACKGROUND; > +out: > + if (pst) > + *pst = st; By mandating pst is always provided you can reduce the total stack footprint, avoid the memcopy and clean up the control flow ;-) > + return ret; > +}