From 7799bee7a27eeff586bc88cb3aa7fe18cfc5bda9 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 29 Nov 2013 22:30:39 +0000 Subject: [PATCH] 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 6786c8d..ffad111 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -5066,6 +5066,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) { @@ -5097,7 +5110,8 @@ i915_gem_inactive_count(struct shrinker *shrinker, struct shrink_control *sc) if (obj->active) continue; - if (obj->pin_count == 0 && obj->pages_pin_count == 0) + if (obj->pin_count == 0 && + obj->pages_pin_count == num_vma_bound(obj)) count += obj->base.size >> PAGE_SHIFT; } -- 1.8.4.4