drm/i915/shrinker: Restrict vmap purge to objects with vmaps
authorChris Wilson <chris@chris-wilson.co.uk>
Fri, 8 Apr 2016 11:11:12 +0000 (12:11 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Mon, 11 Apr 2016 16:12:16 +0000 (17:12 +0100)
When called because we have run out of vmap address space, we only need
to recover objects that have vmappings and not all.

v2: Start using is_vmalloc_addr()

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1460113874-17366-5-git-send-email-chris@chris-wilson.co.uk
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem_shrinker.c

index c262d5184e12814f185c83ac765aa79864f47623..7bda246e630b27051d283e4c9ca0fbd579f49fd1 100644 (file)
@@ -3342,6 +3342,7 @@ unsigned long i915_gem_shrink(struct drm_i915_private *dev_priv,
 #define I915_SHRINK_UNBOUND 0x2
 #define I915_SHRINK_BOUND 0x4
 #define I915_SHRINK_ACTIVE 0x8
+#define I915_SHRINK_VMAPS 0x10
 unsigned long i915_gem_shrink_all(struct drm_i915_private *dev_priv);
 void i915_gem_shrinker_init(struct drm_i915_private *dev_priv);
 void i915_gem_shrinker_cleanup(struct drm_i915_private *dev_priv);
index 39943793edcce643e34d530fef7f1628458b546b..d46388f25e04e1df880c545c76cc41974d620419 100644 (file)
@@ -167,6 +167,10 @@ i915_gem_shrink(struct drm_i915_private *dev_priv,
                            obj->madv != I915_MADV_DONTNEED)
                                continue;
 
+                       if (flags & I915_SHRINK_VMAPS &&
+                           !is_vmalloc_addr(obj->mapping))
+                               continue;
+
                        if ((flags & I915_SHRINK_ACTIVE) == 0 && obj->active)
                                continue;
 
@@ -388,7 +392,11 @@ i915_gem_shrinker_vmap(struct notifier_block *nb, unsigned long event, void *ptr
        if (!i915_gem_shrinker_lock_uninterruptible(dev_priv, &slu, 5000))
                return NOTIFY_DONE;
 
-       freed_pages = i915_gem_shrink_all(dev_priv);
+       freed_pages = i915_gem_shrink(dev_priv, -1UL,
+                                     I915_SHRINK_BOUND |
+                                     I915_SHRINK_UNBOUND |
+                                     I915_SHRINK_ACTIVE |
+                                     I915_SHRINK_VMAPS);
 
        i915_gem_shrinker_unlock_uninterruptible(dev_priv, &slu);