From: Tvrtko Ursulin <tursulin@ursulin.net>
To: "Adrián Larumbe" <adrian.larumbe@collabora.com>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"Jonathan Corbet" <corbet@lwn.net>
Cc: kernel@collabora.com, Tvrtko Ursulin <tvrtko.ursulin@igalia.com>,
dri-devel@lists.freedesktop.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v8 2/4] drm/file: Add fdinfo helper for printing regions with prefix
Date: Wed, 15 Jan 2025 08:08:31 +0000 [thread overview]
Message-ID: <2c62137a-70d5-421e-ae8d-e3bb7c86d0b2@ursulin.net> (raw)
In-Reply-To: <20250114173406.3060248-3-adrian.larumbe@collabora.com>
On 14/01/2025 17:34, Adrián Larumbe wrote:
> This is motivated by the desire of some drivers (eg. Panthor) to print the
> size of internal memory regions with a prefix that reflects the driver
> name, as suggested in the previous documentation commit.
>
> That means adding a new argument to print_size and making it available for
> DRM users.
>
> Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
> Cc: Tvrtko Ursulin <tursulin@ursulin.net>
> ---
> drivers/gpu/drm/drm_file.c | 27 +++++++++++++++++++--------
> include/drm/drm_file.h | 5 +++++
> 2 files changed, 24 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
> index cb5f22f5bbb6..f584abcd13cb 100644
> --- a/drivers/gpu/drm/drm_file.c
> +++ b/drivers/gpu/drm/drm_file.c
> @@ -830,8 +830,12 @@ void drm_send_event(struct drm_device *dev, struct drm_pending_event *e)
> }
> EXPORT_SYMBOL(drm_send_event);
>
> -static void print_size(struct drm_printer *p, const char *stat,
> - const char *region, u64 sz)
> +
> +void drm_fdinfo_print_size(struct drm_printer *p,
> + const char *prefix,
> + const char *stat,
> + const char *region,
> + u64 sz)
> {
> const char *units[] = {"", " KiB", " MiB"};
> unsigned u;
> @@ -842,8 +846,10 @@ static void print_size(struct drm_printer *p, const char *stat,
> sz = div_u64(sz, SZ_1K);
> }
>
> - drm_printf(p, "drm-%s-%s:\t%llu%s\n", stat, region, sz, units[u]);
> + drm_printf(p, "%s-%s-%s:\t%llu%s\n",
> + prefix, stat, region, sz, units[u]);
> }
> +EXPORT_SYMBOL(drm_fdinfo_print_size);
>
> /**
> * drm_print_memory_stats - A helper to print memory stats
> @@ -858,15 +864,20 @@ void drm_print_memory_stats(struct drm_printer *p,
> enum drm_gem_object_status supported_status,
> const char *region)
> {
> - print_size(p, "total", region, stats->private + stats->shared);
> - print_size(p, "shared", region, stats->shared);
> - print_size(p, "active", region, stats->active);
> + const char *prefix = "drm";
> +
> + drm_fdinfo_print_size(p, prefix, "total", region,
> + stats->private + stats->shared);
> + drm_fdinfo_print_size(p, prefix, "shared", region, stats->shared);
> + drm_fdinfo_print_size(p, prefix, "active", region, stats->active);
>
> if (supported_status & DRM_GEM_OBJECT_RESIDENT)
> - print_size(p, "resident", region, stats->resident);
> + drm_fdinfo_print_size(p, prefix, "resident", region,
> + stats->resident);
>
> if (supported_status & DRM_GEM_OBJECT_PURGEABLE)
> - print_size(p, "purgeable", region, stats->purgeable);
> + drm_fdinfo_print_size(p, prefix, "purgeable", region,
> + stats->purgeable);
> }
> EXPORT_SYMBOL(drm_print_memory_stats);
>
> diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
> index f0ef32e9fa5e..001ae553e8c3 100644
> --- a/include/drm/drm_file.h
> +++ b/include/drm/drm_file.h
> @@ -494,6 +494,11 @@ struct drm_memory_stats {
>
> enum drm_gem_object_status;
>
> +void drm_fdinfo_print_size(struct drm_printer *p,
> + const char *prefix,
> + const char *stat,
> + const char *region,
> + u64 sz);
> void drm_print_memory_stats(struct drm_printer *p,
> const struct drm_memory_stats *stats,
> enum drm_gem_object_status supported_status,
If I can get away with a sneaky:
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Regards,
Tvrtko
next prev parent reply other threads:[~2025-01-15 8:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-14 17:33 [PATCH v8 0/4] drm/panthor: Display size of internal kernel BOs through fdinfo Adrián Larumbe
2025-01-14 17:34 ` [PATCH v8 1/4] Documentation/gpu: Clarify format of driver-specific fidnfo keys Adrián Larumbe
2025-01-14 17:34 ` [PATCH v8 2/4] drm/file: Add fdinfo helper for printing regions with prefix Adrián Larumbe
2025-01-15 8:08 ` Tvrtko Ursulin [this message]
2025-01-14 17:34 ` [PATCH v8 3/4] drm/panthor: Expose size of driver internal BO's over fdinfo Adrián Larumbe
2025-01-15 12:37 ` Boris Brezillon
2025-01-14 17:34 ` [PATCH v8 4/4] Documentation/gpu: Add fdinfo meanings of panthor-*-memory tags Adrián Larumbe
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=2c62137a-70d5-421e-ae8d-e3bb7c86d0b2@ursulin.net \
--to=tursulin@ursulin.net \
--cc=adrian.larumbe@collabora.com \
--cc=airlied@gmail.com \
--cc=corbet@lwn.net \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel@collabora.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=tvrtko.ursulin@igalia.com \
--cc=tzimmermann@suse.de \
/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
all inboxes | Powered by JetHome®