drm/i915: Use a separate slab for vmas
authorChris Wilson <chris@chris-wilson.co.uk>
Tue, 7 Apr 2015 15:20:58 +0000 (16:20 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 10 Apr 2015 08:17:13 +0000 (10:17 +0200)
vma are more frequently allocated than objects and so should equally
benefit from having a dedicated slab.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_dma.c
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/i915_gem_gtt.c

index 180b5d92b279c058a466447144cbc5c1aea08ff1..d67cd9e0ef145ce372ee6d3b7d26eeabd029f932 100644 (file)
@@ -1008,6 +1008,8 @@ put_bridge:
 free_priv:
        if (dev_priv->requests)
                kmem_cache_destroy(dev_priv->requests);
+       if (dev_priv->vmas)
+               kmem_cache_destroy(dev_priv->vmas);
        if (dev_priv->objects)
                kmem_cache_destroy(dev_priv->objects);
        kfree(dev_priv);
@@ -1094,6 +1096,8 @@ int i915_driver_unload(struct drm_device *dev)
 
        if (dev_priv->requests)
                kmem_cache_destroy(dev_priv->requests);
+       if (dev_priv->vmas)
+               kmem_cache_destroy(dev_priv->vmas);
        if (dev_priv->objects)
                kmem_cache_destroy(dev_priv->objects);
 
index 855eaac9ddd1aa0f606c7d42850530208e56dc2d..b6750751bb933a326db72fd76bd2607cc9a4c0d0 100644 (file)
@@ -1559,6 +1559,7 @@ struct i915_virtual_gpu {
 struct drm_i915_private {
        struct drm_device *dev;
        struct kmem_cache *objects;
+       struct kmem_cache *vmas;
        struct kmem_cache *requests;
 
        const struct intel_device_info info;
index 20a61764a4a3c6153323d9d47b4f31df63b679f3..a57fdd98b4fec009104e8fc19a4c83bf13cb7ee4 100644 (file)
@@ -4612,7 +4612,7 @@ void i915_gem_vma_destroy(struct i915_vma *vma)
 
        list_del(&vma->vma_link);
 
-       kfree(vma);
+       kmem_cache_free(to_i915(vma->obj->base.dev)->vmas, vma);
 }
 
 static void
@@ -4991,6 +4991,11 @@ i915_gem_load(struct drm_device *dev)
                                  sizeof(struct drm_i915_gem_object), 0,
                                  SLAB_HWCACHE_ALIGN,
                                  NULL);
+       dev_priv->vmas =
+               kmem_cache_create("i915_gem_vma",
+                                 sizeof(struct i915_vma), 0,
+                                 SLAB_HWCACHE_ALIGN,
+                                 NULL);
        dev_priv->requests =
                kmem_cache_create("i915_gem_request",
                                  sizeof(struct drm_i915_gem_request), 0,
index 2a01d5620a192e72d74441c3c93514569502d94e..559cecaccf7ff27e3871408522661502abef6975 100644 (file)
@@ -2712,7 +2712,8 @@ __i915_gem_vma_create(struct drm_i915_gem_object *obj,
 
        if (WARN_ON(i915_is_ggtt(vm) != !!ggtt_view))
                return ERR_PTR(-EINVAL);
-       vma = kzalloc(sizeof(*vma), GFP_KERNEL);
+
+       vma = kmem_cache_zalloc(to_i915(obj->base.dev)->vmas, GFP_KERNEL);
        if (vma == NULL)
                return ERR_PTR(-ENOMEM);