Skip to content

Commit

Permalink
drm/i915: Use a separate slab for vmas
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Chris Wilson authored and Daniel Vetter committed Apr 10, 2015
1 parent efab6d8 commit e20d2ab
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions drivers/gpu/drm/i915/i915_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
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);
Expand Down Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/i915/i915_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion drivers/gpu/drm/i915/i915_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion drivers/gpu/drm/i915/i915_gem_gtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit e20d2ab

Please sign in to comment.