Re: [RFC PATCH 4/8] drm: start using drm_gem_trace_gpu_mem_total

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

 



On Wed, 20 Oct 2021 20:10:23 -0700
Gurchetan Singh <gurchetansingh@xxxxxxxxxxxx> wrote:

> - drm_gem_private_object_init(..) increases the total memory
>   counter.
> 
>   * All GEM objects (whether allocated or imported) seem to begin
>     there.
>   * If there's a better place/method, please do let
>     me know.
> 
> - drm_gem_object_free(..) decreases the total memory counter.
> 
> Signed-off-by: Gurchetan Singh <gurchetansingh@xxxxxxxxxxxx>
> ---
>  drivers/gpu/drm/drm_gem.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> index 24a719b79400..528d7b29dccf 100644
> --- a/drivers/gpu/drm/drm_gem.c
> +++ b/drivers/gpu/drm/drm_gem.c
> @@ -213,6 +213,7 @@ void drm_gem_private_object_init(struct drm_device *dev,
>  		obj->resv = &obj->_resv;
>  
>  	drm_vma_node_reset(&obj->vma_node);

To save yourself a function call when tracing is disabled, you can add:

	if (trace_gpu_mem_total_enabled())

here, which is a static_branch (meaning it's not a compare and branch,
but a nop when tracing is disabled, and a jmp (to the if block) when
the event is enabled).

> +	drm_gem_trace_gpu_mem_total(dev, obj->size, false);
>  }
>  EXPORT_SYMBOL(drm_gem_private_object_init);
>  
> @@ -1015,6 +1016,10 @@ drm_gem_object_free(struct kref *kref)
>  	struct drm_gem_object *obj =
>  		container_of(kref, struct drm_gem_object, refcount);
>  
> +	struct drm_device *dev = obj->dev;
> +

Same here.

-- Steve

> +	drm_gem_trace_gpu_mem_total(dev, -obj->size, false);
> +
>  	if (WARN_ON(!obj->funcs->free))
>  		return;
>  




[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