[Intel-gfx] [PATCH v2 1/5] drm/i915: Wait for struct_mutex inside shrinker

Chris Wilson chris at chris-wilson.co.uk
Wed May 24 14:39:37 UTC 2017


Having resolved whether or not we would deadlock upon a call to
mutex_lock(&dev->struct_mutex), we can then wait for the contended
struct_mutex if we are not the owner. This should significantly improve
the chance of running the shrinker for other processes whilst the GPU is
busy.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
---
 drivers/gpu/drm/i915/i915_gem_shrinker.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_shrinker.c b/drivers/gpu/drm/i915/i915_gem_shrinker.c
index b409e67c5c72..03e08e1853e6 100644
--- a/drivers/gpu/drm/i915/i915_gem_shrinker.c
+++ b/drivers/gpu/drm/i915/i915_gem_shrinker.c
@@ -39,8 +39,8 @@ static bool shrinker_lock(struct drm_i915_private *dev_priv, bool *unlock)
 {
 	switch (mutex_trylock_recursive(&dev_priv->drm.struct_mutex)) {
 	case MUTEX_TRYLOCK_FAILED:
-		return false;
-
+		if (mutex_lock_killable(&dev_priv->drm.struct_mutex))
+			return false;
 	case MUTEX_TRYLOCK_SUCCESS:
 		*unlock = true;
 		return true;
-- 
2.11.0



More information about the Intel-gfx mailing list