Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Alex Deucher <alexander.deucher@amd.com>,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
	daniel@ffwll.ch
Subject: Re: [PATCH 2/6] drm: add drm_gem_object_is_shared_for_memory_stats() helper
Date: Tue, 30 Jan 2024 16:25:05 +0000	[thread overview]
Message-ID: <cc82911b-7caf-4f7a-8ce9-8b716fed8782@linux.intel.com> (raw)
In-Reply-To: <20240130161235.3237122-3-alexander.deucher@amd.com>


On 30/01/2024 16:12, Alex Deucher wrote:
> Add a helper so that drm drivers can consistently report
> shared status via the fdinfo shared memory stats interface.
> 
> In addition to handle count, show buffers as shared if they
> are shared via dma-buf as well (e.g., shared with v4l or some
> other subsystem).
> 
> Link: https://lore.kernel.org/all/20231207180225.439482-1-alexander.deucher@amd.com/
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
>   drivers/gpu/drm/drm_gem.c | 16 ++++++++++++++++
>   include/drm/drm_gem.h     |  1 +
>   2 files changed, 17 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> index 44a948b80ee1..71b5f628d828 100644
> --- a/drivers/gpu/drm/drm_gem.c
> +++ b/drivers/gpu/drm/drm_gem.c
> @@ -1506,3 +1506,19 @@ int drm_gem_evict(struct drm_gem_object *obj)
>   	return 0;
>   }
>   EXPORT_SYMBOL(drm_gem_evict);
> +
> +/**
> + * drm_gem_object_is_shared_for_memory_stats - helper for shared memory stats
> + *
> + * This helper should only be used for fdinfo shared memory stats to determine
> + * if a GEM object is shared.
> + *
> + * @obj: obj in question
> + */
> +bool drm_gem_object_is_shared_for_memory_stats(struct drm_gem_object *obj)
> +{
> +	if ((obj->handle_count > 1) || obj->dma_buf)
> +		return true;
> +	return false;
> +}
> +EXPORT_SYMBOL(drm_gem_object_is_shared_for_memory_stats);
> diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
> index 369505447acd..86a9c696f038 100644
> --- a/include/drm/drm_gem.h
> +++ b/include/drm/drm_gem.h
> @@ -552,6 +552,7 @@ unsigned long drm_gem_lru_scan(struct drm_gem_lru *lru,
>   			       bool (*shrink)(struct drm_gem_object *obj));
>   
>   int drm_gem_evict(struct drm_gem_object *obj);
> +bool drm_gem_object_is_shared_for_memory_stats(struct drm_gem_object *obj);
>   
>   #ifdef CONFIG_LOCKDEP
>   /**

Not sure what the local view on static inlines, but fine nevertheless.

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

Tvrtko

  reply	other threads:[~2024-01-30 17:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-30 16:12 [PATCH 0/6 V3] fdinfo shared stats Alex Deucher
2024-01-30 16:12 ` [PATCH 1/6] Documentation/gpu: Update documentation on drm-shared-* Alex Deucher
2024-01-30 16:22   ` Tvrtko Ursulin
2024-01-30 16:12 ` [PATCH 2/6] drm: add drm_gem_object_is_shared_for_memory_stats() helper Alex Deucher
2024-01-30 16:25   ` Tvrtko Ursulin [this message]
2024-01-30 17:11   ` Hamza Mahfooz
2024-01-30 16:12 ` [PATCH 3/6] drm: update drm_show_memory_stats() for dma-bufs Alex Deucher
2024-01-30 16:25   ` Tvrtko Ursulin
2024-01-30 16:12 ` [PATCH 4/6] drm/amdgpu: add shared fdinfo stats Alex Deucher
2024-01-30 16:12 ` [PATCH 5/6] drm/i915: Update shared stats to use the new gem helper Alex Deucher
2024-01-30 16:26   ` Tvrtko Ursulin
2024-01-30 16:12 ` [PATCH 6/6] drm/xe: " Alex Deucher
2024-01-30 19:49 ` ✓ CI.Patch_applied: success for fdinfo shared stats Patchwork
2024-01-30 19:49 ` ✗ CI.checkpatch: warning " Patchwork
2024-01-30 19:50 ` ✓ CI.KUnit: success " Patchwork
2024-01-30 19:57 ` ✓ CI.Build: " Patchwork
2024-01-30 19:58 ` ✓ CI.Hooks: " Patchwork
2024-01-30 19:59 ` ✗ CI.checksparse: warning " Patchwork
2024-01-30 20:44 ` ✓ CI.BAT: success " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2024-02-12 21:04 [PATCH 0/6 V4] " Alex Deucher
2024-02-12 21:04 ` [PATCH 2/6] drm: add drm_gem_object_is_shared_for_memory_stats() helper Alex Deucher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cc82911b-7caf-4f7a-8ce9-8b716fed8782@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox