From patchwork Thu Jan 3 12:23:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10747261 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 8C55C17D2 for ; Thu, 3 Jan 2019 12:23:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D803285A2 for ; Thu, 3 Jan 2019 12:23:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7206D2862D; Thu, 3 Jan 2019 12:23:39 +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 2AD49285A2 for ; Thu, 3 Jan 2019 12:23:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 35E0689C48; Thu, 3 Jan 2019 12:23:36 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 195AE88130 for ; Thu, 3 Jan 2019 12:23:35 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jan 2019 04:23:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,434,1539673200"; d="scan'208";a="308639866" Received: from unknown (HELO localhost.localdomain) ([10.252.3.166]) by fmsmga005.fm.intel.com with ESMTP; 03 Jan 2019 04:23:34 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Thu, 3 Jan 2019 12:23:27 +0000 Message-Id: <20190103122329.19948-3-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190103122329.19948-1-tvrtko.ursulin@linux.intel.com> References: <20190103122329.19948-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC 2/4] drm/i915: Fix timeout handling in i915_gem_shrinker_vmap 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 From: Tvrtko Ursulin The code tries to grab struct mutex for 5ms every time the unlocked GPU idle wait succeeds. But the GPU idle wait itself is practically unbound which means the 5ms timeout might not be honoured. Cap the GPU idle wait to 5ms as well to fix this. Signed-off-by: Tvrtko Ursulin --- drivers/gpu/drm/i915/i915_gem_shrinker.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_shrinker.c b/drivers/gpu/drm/i915/i915_gem_shrinker.c index d07ee5921e5e..586acf02727e 100644 --- a/drivers/gpu/drm/i915/i915_gem_shrinker.c +++ b/drivers/gpu/drm/i915/i915_gem_shrinker.c @@ -387,13 +387,12 @@ i915_gem_shrinker_scan(struct shrinker *shrinker, struct shrink_control *sc) static bool shrinker_lock_uninterruptible(struct drm_i915_private *i915, bool *unlock, - int timeout_ms) + unsigned long timeout) { - unsigned long timeout = jiffies + msecs_to_jiffies_timeout(timeout_ms); + const unsigned long timeout_end = jiffies + timeout; do { - if (i915_gem_wait_for_idle(i915, - 0, MAX_SCHEDULE_TIMEOUT) == 0 && + if (i915_gem_wait_for_idle(i915, 0, timeout) == 0 && shrinker_lock(i915, unlock)) break; @@ -401,7 +400,7 @@ shrinker_lock_uninterruptible(struct drm_i915_private *i915, bool *unlock, if (fatal_signal_pending(current)) return false; - if (time_after(jiffies, timeout)) { + if (time_after(jiffies, timeout_end)) { pr_err("Unable to lock GPU to purge memory.\n"); return false; } @@ -459,11 +458,12 @@ i915_gem_shrinker_vmap(struct notifier_block *nb, unsigned long event, void *ptr struct drm_i915_private *i915 = container_of(nb, struct drm_i915_private, mm.vmap_notifier); struct i915_vma *vma, *next; + const unsigned long timeout = msecs_to_jiffies_timeout(5000); unsigned long freed_pages = 0; bool unlock; int ret; - if (!shrinker_lock_uninterruptible(i915, &unlock, 5000)) + if (!shrinker_lock_uninterruptible(i915, &unlock, timeout)) return NOTIFY_DONE; /* Force everything onto the inactive lists */