From patchwork Thu Nov 26 11:25:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 7705961 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2DC709F2E9 for ; Thu, 26 Nov 2015 11:25:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5CEDE205F2 for ; Thu, 26 Nov 2015 11:25:26 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 80D20207B8 for ; Thu, 26 Nov 2015 11:25:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 028886EB60; Thu, 26 Nov 2015 03:25:25 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [87.106.93.118]) by gabe.freedesktop.org (Postfix) with ESMTP id 620196EB60 for ; Thu, 26 Nov 2015 03:25:23 -0800 (PST) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from nuc-i3427.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 48849032-1500048 for multiple; Thu, 26 Nov 2015 11:25:32 +0000 Received: by nuc-i3427.alporthouse.com (sSMTP sendmail emulation); Thu, 26 Nov 2015 11:25:14 +0000 Date: Thu, 26 Nov 2015 11:25:14 +0000 From: Chris Wilson To: Johannes Weiner Message-ID: <20151126112514.GG23362@nuc-i3427.alporthouse.com> Mail-Followup-To: Chris Wilson , Johannes Weiner , intel-gfx@lists.freedesktop.org, linux-mm@kvack.org, Akash Goel , sourab.gupta@intel.com References: <20151124231738.GA15770@nuc-i3427.alporthouse.com> <1448476616-5257-1-git-send-email-chris@chris-wilson.co.uk> <20151125190610.GA12238@cmpxchg.org> <20151125203102.GJ22980@nuc-i3427.alporthouse.com> <20151125204635.GA14536@cmpxchg.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20151125204635.GA14536@cmpxchg.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: linux-mm@kvack.org, intel-gfx@lists.freedesktop.org, sourab.gupta@intel.com, Akash Goel Subject: Re: [Intel-gfx] [PATCH v2] drm/i915: Disable shrinker for non-swapped backed objects X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, Nov 25, 2015 at 03:46:35PM -0500, Johannes Weiner wrote: > On Wed, Nov 25, 2015 at 08:31:02PM +0000, Chris Wilson wrote: > > On Wed, Nov 25, 2015 at 02:06:10PM -0500, Johannes Weiner wrote: > > > On Wed, Nov 25, 2015 at 06:36:56PM +0000, Chris Wilson wrote: > > > > +static bool swap_available(void) > > > > +{ > > > > + return total_swap_pages || frontswap_enabled; > > > > +} > > > > > > If you use get_nr_swap_pages() instead of total_swap_pages, this will > > > also stop scanning objects once the swap space is full. We do that in > > > the VM to stop scanning anonymous pages. > > > > Thanks. Would EXPORT_SYMBOL_GPL(nr_swap_pages) (or equivalent) be > > acceptable? > > No opposition from me. Just please add a small comment that this is > for shrinkers with swappable objects. diff --git a/mm/swapfile.c b/mm/swapfile.c index 58877312cf6b..1c7861f4c43c 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -48,6 +48,14 @@ static sector_t map_swap_entry(swp_entry_t, struct block_device**); DEFINE_SPINLOCK(swap_lock); static unsigned int nr_swapfiles; atomic_long_t nr_swap_pages; +/* + * Some modules use swappable objects and may try to swap them out under + * memory pressure (via the shrinker). Before doing so, they may wish to + * check to see if any swap space is available. The shrinker also directly + * uses the available swap space to determine whether it can swapout + * anon pages in the same manner. + */ +EXPORT_SYMBOL_GPL(nr_swap_pages); Something like that, after a couple more edits? -Chris