From c9b601aad2cf0f5e7af7775184d1f596bfc19a54 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 29 Nov 2013 22:30:39 +0000 Subject: [PATCH 1/2] drm/i915: Include bound and active pages in the count of shrinkable objects Signed-off-by: Chris Wilson --- drivers/gpu/drm/i915/i915_gem.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index bd9353402f02..849554db9413 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -4943,6 +4943,19 @@ static bool mutex_is_locked_by(struct mutex *mutex, struct task_struct *task) #endif } +static int num_vma_bound(struct drm_i915_gem_object *obj) +{ + struct i915_vma *vma; + int count = 0; + + list_for_each_entry(vma, &obj->vma_list, vma_link) + if (drm_mm_node_allocated(&vma->node)) + count++; + + return count; + +} + static unsigned long i915_gem_inactive_count(struct shrinker *shrinker, struct shrink_control *sc) { @@ -4974,7 +4987,8 @@ i915_gem_inactive_count(struct shrinker *shrinker, struct shrink_control *sc) if (obj->active) continue; - if (!i915_gem_obj_is_pinned(obj) && obj->pages_pin_count == 0) + if (!i915_gem_obj_is_pinned(obj) && + obj->pages_pin_count == num_vma_bound(obj)) count += obj->base.size >> PAGE_SHIFT; } -- 1.8.5.2