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 <[email protected]>
Cc: Joonas Lahtinen <[email protected]>
---
 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

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to