From 8a158f676eed88bbe3ad52ae99ea6af281256858 Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Wed, 19 Dec 2012 14:52:55 +0100 Subject: [PATCH] drm/i915: make the shrinker less aggressive As soon as we run out of purgeable objects to reap, we do a full stall and kick out everthing. Might paper over the infamous ilk issue - all reports are in conjunction with memory load and very light cpu loads. If this is the case, we have a problem somewhere where we pull the rug from under the gpu a bit too early in the retire/unbind paths. Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/i915_gem.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 4d3605c..1479b58 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -1756,6 +1756,38 @@ i915_gem_shrink_all(struct drm_i915_private *dev_priv) list_for_each_entry_safe(obj, next, &dev_priv->mm.unbound_list, gtt_list) i915_gem_object_put_pages(obj); } +static long +i915_gem_shrink(struct drm_i915_private *dev_priv, long target) +{ + struct drm_i915_gem_object *obj, *next; + long count = 0; + + i915_gem_retire_requests(dev_priv->dev); + + list_for_each_entry_safe(obj, next, + &dev_priv->mm.unbound_list, + gtt_list) { + if (i915_gem_object_put_pages(obj) == 0) { + count += obj->base.size >> PAGE_SHIFT; + if (count >= target) + return count; + } + } + + list_for_each_entry_safe(obj, next, + &dev_priv->mm.inactive_list, + mm_list) { + if (i915_gem_object_unbind(obj) == 0 && + i915_gem_object_put_pages(obj) == 0) { + count += obj->base.size >> PAGE_SHIFT; + if (count >= target) + return count; + } + } + + return count; +} + static int i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj) @@ -4414,7 +4446,7 @@ i915_gem_inactive_shrink(struct shrinker *shrinker, struct shrink_control *sc) } if (nr_to_scan) { - nr_to_scan -= i915_gem_purge(dev_priv, nr_to_scan); + nr_to_scan -= i915_gem_shrink(dev_priv, nr_to_scan); if (nr_to_scan > 0) i915_gem_shrink_all(dev_priv); } -- 1.7.11.7