[Intel-gfx] [PATCH 34/70] drm/i915: Use a separate slab for vmas

Daniel Vetter daniel at ffwll.ch
Fri Apr 10 01:32:14 PDT 2015


On Tue, Apr 07, 2015 at 04:20:58PM +0100, Chris Wilson wrote:
> vma are more frequently allocated than objects and so should equally
> benefit from having a dedicated slab.
> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

Merged these two moar-slab patches, thanks.
-Daniel

> ---
>  drivers/gpu/drm/i915/i915_dma.c     | 4 ++++
>  drivers/gpu/drm/i915/i915_drv.h     | 1 +
>  drivers/gpu/drm/i915/i915_gem.c     | 7 ++++++-
>  drivers/gpu/drm/i915/i915_gem_gtt.c | 3 ++-
>  4 files changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> index 135fbcad367f..9cbc04df94fb 100644
> --- a/drivers/gpu/drm/i915/i915_dma.c
> +++ b/drivers/gpu/drm/i915/i915_dma.c
> @@ -1012,6 +1012,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);
> @@ -1098,6 +1100,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);
>  
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index ad08aa532456..2ca11208983e 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -1579,6 +1579,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;
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index a4a62592f0f8..05d7431db4ab 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -4832,7 +4832,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
> @@ -5211,6 +5211,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,
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index f48d8454f0ef..a9f24236efd9 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -2542,7 +2542,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);
>  
> -- 
> 2.1.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the Intel-gfx mailing list