diff mbox series

[RFC,2/4] drm/i915: Fix timeout handling in i915_gem_shrinker_vmap

Message ID 20190103122329.19948-3-tvrtko.ursulin@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series Shrinker tweaks/fixes? | expand

Commit Message

Tvrtko Ursulin Jan. 3, 2019, 12:23 p.m. UTC
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 mbox series

Patch

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 */