From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Rob Clark <robdclark@gmail.com>
Cc: "Daniel Vetter" <daniel.vetter@ffwll.ch>,
Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
"Alex Deucher" <alexdeucher@gmail.com>,
"Christian König" <christian.koenig@amd.com>
Subject: Re: [Intel-gfx] [RFC 4/6] drm: Add simple fdinfo memory helpers
Date: Wed, 19 Apr 2023 14:16:48 +0100 [thread overview]
Message-ID: <3c9d4aed-5c26-6a20-071c-8a3d24f3c9ce@linux.intel.com> (raw)
In-Reply-To: <CAF6AEGuobv8+fU-WU9D9vffNJC5zCqrHDtkppf__ieMJDHsWnw@mail.gmail.com>
On 18/04/2023 18:18, Rob Clark wrote:
> On Mon, Apr 17, 2023 at 8:56 AM Tvrtko Ursulin
> <tvrtko.ursulin@linux.intel.com> wrote:
>>
>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>
>> For drivers who only wish to show one memory region called 'system,
>> and only account the GEM buffer object handles under it.
>>
>> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>> ---
>> drivers/gpu/drm/drm_file.c | 45 ++++++++++++++++++++++++++++++++++++++
>> include/drm/drm_file.h | 6 +++++
>> 2 files changed, 51 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
>> index e202f79e816d..1e70669dddf7 100644
>> --- a/drivers/gpu/drm/drm_file.c
>> +++ b/drivers/gpu/drm/drm_file.c
>> @@ -872,6 +872,51 @@ void drm_send_event(struct drm_device *dev, struct drm_pending_event *e)
>> }
>> EXPORT_SYMBOL(drm_send_event);
>>
>> +static void
>> +add_obj(struct drm_gem_object *obj, struct drm_fdinfo_memory_stat *stats)
>> +{
>> + u64 sz = obj->size;
>> +
>> + stats[0].size += sz;
>> +
>> + if (obj->handle_count > 1)
>> + stats[0].shared += sz;
>> +
>> + if (!dma_resv_test_signaled(obj->resv, dma_resv_usage_rw(true)))
>> + stats[0].active += sz;
>> +
>> + /* Not supported. */
>> + stats[0].resident = ~0ull;
>> + stats[0].purgeable = ~0ull;
>
> Hmm, this kinda makes the simple helper not very useful. In my
> version, you get something that is useful for all UMA drivers (which
> all, IIRC, have some form of madv ioctl). I was kinda imagining that
> for ttm drivers, my print_memory_stats() would just become a helper
> and that TTM (or "multi-region") drivers would have their own thing.
Hm how? Your version also needed a driver specific vfunc:
+static enum drm_gem_object_status msm_gem_status(struct drm_gem_object *obj)
+{
+ struct msm_gem_object *msm_obj = to_msm_bo(obj);
+ enum drm_gem_object_status status = 0;
+
+ if (msm_obj->pages)
+ status |= DRM_GEM_OBJECT_RESIDENT;
+
+ if (msm_obj->madv == MSM_MADV_DONTNEED)
+ status |= DRM_GEM_OBJECT_PURGEABLE;
+
+ return status;
+}
Regards,
Tvrtko
>
> BR,
> -R
>
>> +}
>> +
>> +char **
>> +drm_query_fdinfo_system_region(struct drm_device *dev, unsigned int *num)
>> +{
>> + static char *region[] = {
>> + "system",
>> + };
>> +
>> + *num = 1;
>> +
>> + return region;
>> +}
>> +EXPORT_SYMBOL(drm_query_fdinfo_system_region);
>> +
>> +void
>> +drm_query_fdinfo_system_memory(struct drm_file *file,
>> + struct drm_fdinfo_memory_stat *stats)
>> +{
>> + struct drm_gem_object *obj;
>> + int id;
>> +
>> + spin_lock(&file->table_lock);
>> + idr_for_each_entry(&file->object_idr, obj, id)
>> + add_obj(obj, stats);
>> + spin_unlock(&file->table_lock);
>> +}
>> +EXPORT_SYMBOL(drm_query_fdinfo_system_memory);
>> +
>> static void
>> print_stat(struct drm_printer *p, const char *stat, const char *region, u64 sz)
>> {
>> diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
>> index 00d48beeac5c..dd7c6fb2c975 100644
>> --- a/include/drm/drm_file.h
>> +++ b/include/drm/drm_file.h
>> @@ -383,6 +383,12 @@ struct drm_fdinfo_memory_stat {
>> u64 active;
>> };
>>
>> +char **drm_query_fdinfo_system_region(struct drm_device *dev,
>> + unsigned int *num);
>> +void drm_query_fdinfo_system_memory(struct drm_file *file,
>> + struct drm_fdinfo_memory_stat *stats);
>> +
>> +
>> /**
>> * drm_is_primary_client - is this an open file of the primary node
>> * @file_priv: DRM file
>> --
>> 2.37.2
>>
next prev parent reply other threads:[~2023-04-19 13:16 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-17 15:56 [Intel-gfx] [RFC 0/6] fdinfo alternative memory stats proposal Tvrtko Ursulin
2023-04-17 15:56 ` [Intel-gfx] [RFC 1/6] drm: Add common fdinfo helper Tvrtko Ursulin
2023-04-17 15:56 ` [Intel-gfx] [RFC 2/6] drm/i915: Use the " Tvrtko Ursulin
2023-04-17 15:56 ` [Intel-gfx] [RFC 3/6] drm: Add fdinfo memory stats Tvrtko Ursulin
2023-04-17 16:20 ` Christian König
2023-04-18 10:47 ` Tvrtko Ursulin
2023-04-18 14:16 ` Rob Clark
2023-04-17 19:39 ` Rob Clark
2023-04-18 8:59 ` Tvrtko Ursulin
2023-04-18 13:49 ` Rob Clark
2023-04-18 14:18 ` Tvrtko Ursulin
2023-04-18 14:36 ` Rob Clark
2023-04-18 14:45 ` Tvrtko Ursulin
2023-04-18 16:13 ` Rob Clark
2023-04-18 16:44 ` Tvrtko Ursulin
2023-04-18 17:10 ` Rob Clark
2023-04-17 15:56 ` [Intel-gfx] [RFC 4/6] drm: Add simple fdinfo memory helpers Tvrtko Ursulin
2023-04-18 17:18 ` Rob Clark
2023-04-19 13:16 ` Tvrtko Ursulin [this message]
2023-04-19 14:32 ` Rob Clark
2023-04-20 13:14 ` Tvrtko Ursulin
2023-04-21 1:24 ` Rob Clark
2023-04-17 15:56 ` [Intel-gfx] [RFC 5/6] drm/msm: Add basic memory stats Tvrtko Ursulin
2023-04-17 15:56 ` [Intel-gfx] [RFC 6/6] drm/i915: Implement fdinfo memory stats printing Tvrtko Ursulin
2023-04-18 14:39 ` Rob Clark
2023-04-18 14:58 ` Tvrtko Ursulin
2023-04-18 16:08 ` Rob Clark
2023-04-19 14:06 ` Tvrtko Ursulin
2023-04-19 14:38 ` Rob Clark
2023-04-20 13:11 ` Tvrtko Ursulin
2023-04-21 1:26 ` Rob Clark
2023-04-17 19:54 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for fdinfo alternative memory stats proposal Patchwork
2023-04-17 19:54 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2023-04-17 20:05 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-04-18 7:21 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
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=3c9d4aed-5c26-6a20-071c-8a3d24f3c9ce@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=Intel-gfx@lists.freedesktop.org \
--cc=alexdeucher@gmail.com \
--cc=christian.koenig@amd.com \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=robdclark@gmail.com \
/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