From patchwork Sat Sep 15 16:40:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10601557 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6A5D814DB for ; Sat, 15 Sep 2018 16:40:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EF7B2AC48 for ; Sat, 15 Sep 2018 16:40:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FDBA2AC68; Sat, 15 Sep 2018 16:40:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 21D0F2AC48 for ; Sat, 15 Sep 2018 16:40:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B9643890AA; Sat, 15 Sep 2018 16:40:36 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 89C7A890AA for ; Sat, 15 Sep 2018 16:40:35 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 13780847-1500050 for multiple; Sat, 15 Sep 2018 17:40:23 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Sat, 15 Sep 2018 17:40:27 +0100 Message-Id: <20180915164027.24852-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH] drm/i915: Recover batch pool caches from shrinker X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 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-Virus-Scanned: ClamAV using ClamSMTP Discard all of our batch pools under mempressure to make their pages available to the shrinker. We will quickly reacquire them when necessary for more GPU relocations or for the command parser. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107936 Signed-off-by: Chris Wilson --- drivers/gpu/drm/i915/i915_gem_batch_pool.c | 7 +++++-- drivers/gpu/drm/i915/i915_gem_shrinker.c | 11 +++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_batch_pool.c b/drivers/gpu/drm/i915/i915_gem_batch_pool.c index f3890b664e3f..b7727a404b46 100644 --- a/drivers/gpu/drm/i915/i915_gem_batch_pool.c +++ b/drivers/gpu/drm/i915/i915_gem_batch_pool.c @@ -131,10 +131,13 @@ i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool, return obj; found: + list_del(&obj->batch_pool_link); ret = i915_gem_object_pin_pages(obj); - if (ret) + if (ret) { + i915_gem_object_put(obj); return ERR_PTR(ret); + } - list_move_tail(&obj->batch_pool_link, list); + list_add_tail(&obj->batch_pool_link, list); return obj; } diff --git a/drivers/gpu/drm/i915/i915_gem_shrinker.c b/drivers/gpu/drm/i915/i915_gem_shrinker.c index ea90d3a0d511..610a78e2f0b1 100644 --- a/drivers/gpu/drm/i915/i915_gem_shrinker.c +++ b/drivers/gpu/drm/i915/i915_gem_shrinker.c @@ -117,6 +117,15 @@ static bool unsafe_drop_pages(struct drm_i915_gem_object *obj) return !i915_gem_object_has_pages(obj); } +static void shrink_caches(struct drm_i915_private *i915) +{ + struct intel_engine_cs *engine; + enum intel_engine_id id; + + for_each_engine(engine, i915, id) + i915_gem_batch_pool_fini(&engine->batch_pool); +} + /** * i915_gem_shrink - Shrink buffer object caches * @i915: i915 device @@ -180,6 +189,8 @@ i915_gem_shrink(struct drm_i915_private *i915, trace_i915_gem_shrink(i915, target, flags); i915_retire_requests(i915); + shrink_caches(i915); + /* * Unbinding of objects will require HW access; Let us not wake the * device just to recover a little memory. If absolutely necessary,