All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 08/19] drm/i915/shrinker: Wait before acquiring struct_mutex under oom
Date: Thu,  4 Aug 2016 20:52:21 +0100	[thread overview]
Message-ID: <1470340352-16118-9-git-send-email-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <1470340352-16118-1-git-send-email-chris@chris-wilson.co.uk>

We can now wait for the GPU (all engines) to become idle without
requiring the struct_mutex. Inside the shrinker, we need to currently
take the struct_mutex in order to purge objects and to purge the objects
we need the GPU to be idle - causing a stall whilst we hold the
struct_mutex. We can hide most of that stall by performing the wait
before taking the struct_mutex and only doing essential waits for
new rendering on objects to be freed.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem_shrinker.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_shrinker.c b/drivers/gpu/drm/i915/i915_gem_shrinker.c
index 23d70376b104..9b92b6470ccc 100644
--- a/drivers/gpu/drm/i915/i915_gem_shrinker.c
+++ b/drivers/gpu/drm/i915/i915_gem_shrinker.c
@@ -323,17 +323,22 @@ i915_gem_shrinker_lock_uninterruptible(struct drm_i915_private *dev_priv,
 				       struct shrinker_lock_uninterruptible *slu,
 				       int timeout_ms)
 {
-	unsigned long timeout = msecs_to_jiffies(timeout_ms) + 1;
+	unsigned long timeout = jiffies + msecs_to_jiffies_timeout(timeout_ms);
+
+	do {
+		if (i915_gem_wait_for_idle(dev_priv, false) == 0 &&
+		    i915_gem_shrinker_lock(&dev_priv->drm, &slu->unlock))
+			break;
 
-	while (!i915_gem_shrinker_lock(&dev_priv->drm, &slu->unlock)) {
 		schedule_timeout_killable(1);
 		if (fatal_signal_pending(current))
 			return false;
-		if (--timeout == 0) {
+
+		if (time_after(jiffies, timeout)) {
 			pr_err("Unable to lock GPU to purge memory.\n");
 			return false;
 		}
-	}
+	} while (1);
 
 	slu->was_interruptible = dev_priv->mm.interruptible;
 	dev_priv->mm.interruptible = false;
-- 
2.8.1

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

  parent reply	other threads:[~2016-08-04 19:52 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-04 19:52 Using RCU requests, take 2 Chris Wilson
2016-08-04 19:52 ` [PATCH 01/19] drm/i915: Introduce i915_gem_active_wait_unlocked() Chris Wilson
2016-08-04 19:52 ` [PATCH 02/19] drm/i915: Convert non-blocking waits for requests over to using RCU Chris Wilson
2016-08-05  5:38   ` Joonas Lahtinen
2016-08-04 19:52 ` [PATCH 03/19] drm/i915: Convert non-blocking userptr " Chris Wilson
2016-08-04 19:52 ` [PATCH 04/19] drm/i915/userptr: Remove superfluous interruptible=false on waiting Chris Wilson
2016-08-04 19:52 ` [PATCH 05/19] drm/i915: Remove forced stop ring on suspend/unload Chris Wilson
2016-08-05  5:46   ` Joonas Lahtinen
2016-08-04 19:52 ` [PATCH 06/19] drm/i915: Enable i915_gem_wait_for_idle() without holding struct_mutex Chris Wilson
2016-08-05  6:16   ` Joonas Lahtinen
2016-08-05  6:51     ` Chris Wilson
2016-08-05  7:31       ` Joonas Lahtinen
2016-08-05  8:23     ` Chris Wilson
2016-08-04 19:52 ` [PATCH 07/19] drm/i915: Simplify do_idling() (Ironlake vt-d w/a) Chris Wilson
2016-08-05  6:19   ` Joonas Lahtinen
2016-08-04 19:52 ` Chris Wilson [this message]
2016-08-05  6:24   ` [PATCH 08/19] drm/i915/shrinker: Wait before acquiring struct_mutex under oom Joonas Lahtinen
2016-08-04 19:52 ` [PATCH 09/19] drm/i915: Tidy generation of the GTT mmap offset Chris Wilson
2016-08-04 19:52 ` [PATCH 10/19] drm/i915: Remove unused no-shrinker-steal Chris Wilson
2016-08-04 19:52 ` [PATCH 11/19] drm/i915: Do a nonblocking wait first in pread/pwrite Chris Wilson
2016-08-05  7:08   ` Joonas Lahtinen
2016-08-05  7:59     ` Chris Wilson
2016-08-04 19:52 ` [PATCH 12/19] drm/i915: Remove (struct_mutex) locking for wait-ioctl Chris Wilson
2016-08-04 19:52 ` [PATCH 13/19] drm/i915: Remove (struct_mutex) locking for busy-ioctl Chris Wilson
2016-08-04 19:52 ` [PATCH 14/19] drm/i915: Reduce locking inside swfinish ioctl Chris Wilson
2016-08-05  6:55   ` Joonas Lahtinen
2016-08-04 19:52 ` [PATCH 15/19] drm/i915: Remove pinned check from madvise ioctl Chris Wilson
2016-08-04 19:52 ` [PATCH 16/19] drm/i915: Remove locking for get_tiling Chris Wilson
2016-08-04 19:52 ` [PATCH 17/19] drm/i915: Document and reject invalid tiling modes Chris Wilson
2016-08-05  6:44   ` Joonas Lahtinen
2016-08-04 19:52 ` [PATCH 18/19] drm/i915: Repack fence tiling mode and stride into a single integer Chris Wilson
2016-08-04 19:52 ` [PATCH 19/19] drm/i915: Assert that the request hasn't been retired Chris Wilson
2016-08-05  5:49 ` ✗ Ro.CI.BAT: failure for series starting with [01/19] drm/i915: Introduce i915_gem_active_wait_unlocked() Patchwork

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=1470340352-16118-9-git-send-email-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --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.