From: Dmitry Osipenko <dmitry.osipenko@collabora.com>
To: shechenglong <shechenglong@xfusion.com>,
David Airlie <airlied@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Thomas Zimmermann <tzimmermann@suse.de>
Cc: Gurchetan Singh <gurchetansingh@chromium.org>,
Chia-I Wu <olvaffe@gmail.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Simona Vetter <simona@ffwll.ch>,
dri-devel@lists.freedesktop.org, virtualization@lists.linux.dev,
linux-kernel@vger.kernel.org, stone.xulei@xfusion.com,
chenjialong@xfusion.com
Subject: Re: [PATCH RESEND] drm/virtio: expose GEM memory statistics through fdinfo
Date: Thu, 8 Oct 2026 00:44:34 +0300 [thread overview]
Message-ID: <ce72b2f5-1343-44e9-89fe-e2de4efb7e9c@collabora.com> (raw)
In-Reply-To: <20260928133635.1835-1-shechenglong@xfusion.com>
On 9/28/26 16:36, shechenglong wrote:
> virtio-gpu does not expose per-client GEM memory usage through DRM
> fdinfo, leaving monitoring tools unable to account for buffers owned by a
> client.
>
> Wire up the DRM fdinfo helpers and use drm_show_memory_stats() to report
> the standard drm-total-memory, drm-shared-memory and drm-active-memory
> fields for GEM objects referenced by each DRM file.
>
> Tested on a QEMU/KVM guest with virtio-gpu. After running:
>
> modetest -M virtio_gpu -s 40:1024x768
>
> the DRM file descriptor of the modetest process shows the following in
> /proc/<pid>/fdinfo/<fd>:
>
> drm-driver: virtio_gpu
> drm-client-id: 8
> drm-pdev: 0000:00:02.0
> drm-total-memory: 3 MiB
> drm-shared-memory: 3 MiB
>
> Signed-off-by: shechenglong <shechenglong@xfusion.com>
> Signed-off-by: chenjialong <chenjialong@xfusion.com>
> ---
> drivers/gpu/drm/virtio/virtgpu_drv.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c
> index 2aaa7cb0808..d43d7ddac60 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_drv.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c
> @@ -323,7 +323,17 @@ MODULE_AUTHOR("Dave Airlie <airlied@redhat.com>");
> MODULE_AUTHOR("Gerd Hoffmann <kraxel@redhat.com>");
> MODULE_AUTHOR("Alon Levy");
>
> -DEFINE_DRM_GEM_FOPS(virtio_gpu_driver_fops);
> +static void virtio_gpu_show_fdinfo(struct drm_printer *p,
> + struct drm_file *file)
> +{
> + drm_show_memory_stats(p, file);
> +}
> +
> +static const struct file_operations virtio_gpu_driver_fops = {
> + .owner = THIS_MODULE,
> + DRM_GEM_FOPS,
> + .show_fdinfo = drm_show_fdinfo,
> +};
>
> static const struct drm_driver driver = {
> /*
> @@ -347,6 +357,7 @@ static const struct drm_driver driver = {
>
> .gem_create_object = virtio_gpu_create_object,
> .fops = &virtio_gpu_driver_fops,
> + .show_fdinfo = virtio_gpu_show_fdinfo,
>
> .ioctls = virtio_gpu_ioctls,
> .num_ioctls = DRM_VIRTIO_NUM_IOCTLS,
> --
> 2.43.0
Usefulness of this change is dubious. VirtIO-GPU has different types of
RAM, I'd expect them all represented properly instead of only shmem.
--
Best regards,
Dmitry
next prev parent reply other threads:[~2026-10-07 21:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 9:44 [PATCH] drm/virtio: expose GEM memory statistics through fdinfo shechenglong
2026-09-28 13:36 ` [PATCH RESEND] " shechenglong
2026-10-07 21:44 ` Dmitry Osipenko [this message]
2026-10-08 16:41 ` shechenglong
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=ce72b2f5-1343-44e9-89fe-e2de4efb7e9c@collabora.com \
--to=dmitry.osipenko@collabora.com \
--cc=airlied@redhat.com \
--cc=chenjialong@xfusion.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gurchetansingh@chromium.org \
--cc=kraxel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=olvaffe@gmail.com \
--cc=shechenglong@xfusion.com \
--cc=simona@ffwll.ch \
--cc=stone.xulei@xfusion.com \
--cc=tzimmermann@suse.de \
--cc=virtualization@lists.linux.dev \
/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