Re: [PATCH] drm/ttm: Fix TTM BO accounting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 04/12/2016 05:57 PM, Alex Deucher wrote:
> From: Felix Kuehling <Felix.Kuehling@xxxxxxx>
>
> TTM BO accounting is out of sync with how memory is really allocated
> in ttm[_dma]_tt_alloc_page_directory. This resulted in excessive
> estimated overhead with many small allocations.
>
> ttm_dma_tt_alloc_page_directory makes a single allocation for three
> arrays: pages, DMA and CPU addresses. It uses drm_calloc_large, which
> uses kmalloc internally for allocations smaller than PAGE_SIZE.
> ttm_round_pot should be a good approximation of its memory usage both
> above and below PAGE_SIZE.

I think for allocations larger than PAGE_SIZE,
ttm_round_pot() will overestimate. You should probably use the smaller
of the two.

/Thomas



>
> Signed-off-by: Felix Kuehling <Felix.Kuehling@xxxxxxx>
> Reviewed-by: Monk Liu <monk.liu@xxxxxxx>
> Reviewed-by: Christian König <christian.koenig@xxxxxxx>
> ---
>  drivers/gpu/drm/ttm/ttm_bo.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 4cbf265..870a87a 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1215,7 +1215,7 @@ size_t ttm_bo_acc_size(struct ttm_bo_device *bdev,
>  	size_t size = 0;
>  
>  	size += ttm_round_pot(struct_size);
> -	size += PAGE_ALIGN(npages * sizeof(void *));
> +	size += ttm_round_pot(npages * sizeof(void *));
>  	size += ttm_round_pot(sizeof(struct ttm_tt));
>  	return size;
>  }
> @@ -1229,8 +1229,7 @@ size_t ttm_bo_dma_acc_size(struct ttm_bo_device *bdev,
>  	size_t size = 0;
>  
>  	size += ttm_round_pot(struct_size);
> -	size += PAGE_ALIGN(npages * sizeof(void *));
> -	size += PAGE_ALIGN(npages * sizeof(dma_addr_t));
> +	size += ttm_round_pot(npages * (2*sizeof(void *) + sizeof(dma_addr_t)));
>  	size += ttm_round_pot(sizeof(struct ttm_dma_tt));
>  	return size;
>  }

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux