All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Intel-gfx@lists.freedesktop.org
Subject: [PATCH 2/2] drm/i915: Fix timeout handling in i915_gem_shrinker_vmap
Date: Fri,  4 Jan 2019 14:02:17 +0000	[thread overview]
Message-ID: <20190104140217.17822-2-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <20190104140217.17822-1-tvrtko.ursulin@linux.intel.com>

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

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 <tvrtko.ursulin@intel.com>
---
 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 1ee5b08dab1b..e848f38223d6 100644
--- a/drivers/gpu/drm/i915/i915_gem_shrinker.c
+++ b/drivers/gpu/drm/i915/i915_gem_shrinker.c
@@ -404,13 +404,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;
 
@@ -418,7 +417,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;
 		}
@@ -476,11 +475,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 */
-- 
2.19.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-01-04 14:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-04 14:02 [PATCH 1/2] drm/i915: Reduce recursive mutex locking from the shrinker Tvrtko Ursulin
2019-01-04 14:02 ` Tvrtko Ursulin [this message]
2019-01-04 14:10 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/2] " Patchwork
2019-01-04 14:10 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-01-04 14:27 ` ✓ Fi.CI.BAT: success " Patchwork
2019-01-04 14:54 ` [PATCH v3 1/2] " Tvrtko Ursulin
2019-01-04 15:30 ` ✓ Fi.CI.BAT: success for series starting with [v3,1/2] drm/i915: Reduce recursive mutex locking from the shrinker (rev2) Patchwork
2019-01-04 15:35 ` ✓ Fi.CI.IGT: success for series starting with [1/2] drm/i915: Reduce recursive mutex locking from the shrinker Patchwork
2019-01-04 16:33 ` ✓ Fi.CI.IGT: success for series starting with [v3,1/2] drm/i915: Reduce recursive mutex locking from the shrinker (rev2) Patchwork
2019-01-09 14:12 [PATCH 1/2] drm/i915: Reduce recursive mutex locking from the shrinker Tvrtko Ursulin
2019-01-09 14:12 ` [PATCH 2/2] drm/i915: Fix timeout handling in i915_gem_shrinker_vmap Tvrtko Ursulin
2019-01-09 14:23   ` Chris Wilson
2019-01-09 15:07     ` Tvrtko Ursulin
2019-01-09 15:13       ` Chris Wilson
2019-01-09 14:31   ` Chris Wilson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190104140217.17822-2-tvrtko.ursulin@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=Intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.