mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
To: David Airlie <airlied@redhat.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	 Dmitry Osipenko <dmitry.osipenko@collabora.com>,
	 Gurchetan Singh <gurchetansingh@chromium.org>,
	 Chia-I Wu <olvaffe@gmail.com>,
	 Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	 Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	 Simona Vetter <simona@ffwll.ch>
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
	"Viresh Kumar" <viresh.kumar@linaro.org>,
	dri-devel@lists.freedesktop.org, virtualization@lists.linux.dev,
	linux-kernel@vger.kernel.org,
	"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>
Subject: [PATCH 0/3] virtgpu: fix memory leak on device removal
Date: Mon, 05 May 2025 11:59:13 +0300	[thread overview]
Message-ID: <20250505-virtgpu-queue-cleanup-v1-v1-0-810923da2b1e@linaro.org> (raw)

When a VIRTIO GPU device is removed, it cleans up any command buffers
that the VIRTIO frontend has responded to. It however ignores commands
that have yet to be replied to, which still reside in the avail rings of
the virt queues. This leaks two type of objects:

- VIRTIO command buffers
- Fences

Furthermore, if the virtio config has num_capsets > 0, the capsets field
of the device is also leaked.

These memory leaks are reported by:

- /sys/kernel/debug/kmemleak
- slab debug options "BUG virtio-gpu-vbufs: Objects remaining in
  virtio-gpu-vbufs on __kmem_cache_shutdown()"
- drm:drm_mm_takedown "Memory manager not clean during takedown."

This patch series adds cleanup logic in virtio_gpu_deinit(), after
calling virtio_reset_device(), to free any such allocations.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
---
Manos Pitsidianakis (3):
      virtgpu: add virtio_gpu_queue_cleanup()
      virtgpu: add virtio_gpu_fence_cleanup()
      virtgpu: deallocate capsets on device deinit

 drivers/gpu/drm/virtio/virtgpu_drv.h   |  2 ++
 drivers/gpu/drm/virtio/virtgpu_fence.c | 12 ++++++++
 drivers/gpu/drm/virtio/virtgpu_kms.c   |  6 ++++
 drivers/gpu/drm/virtio/virtgpu_vq.c    | 55 ++++++++++++++++++++++++++++++++++
 4 files changed, 75 insertions(+)
---
base-commit: ad10b82c2bcac7f87ac6eaecfca33378b43425ee
change-id: 20250505-virtgpu-queue-cleanup-v1-3392995cab5f

--
γαῖα πυρί μιχθήτω


             reply	other threads:[~2025-05-05  8:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-05  8:59 Manos Pitsidianakis [this message]
2025-05-05  8:59 ` [PATCH 1/3] virtgpu: add virtio_gpu_queue_cleanup() Manos Pitsidianakis
2025-06-10 13:27   ` Stefano Garzarella
2025-05-05  8:59 ` [PATCH 2/3] virtgpu: add virtio_gpu_fence_cleanup() Manos Pitsidianakis
2025-06-10 13:33   ` Stefano Garzarella
2025-05-05  8:59 ` [PATCH 3/3] virtgpu: deallocate capsets on device deinit Manos Pitsidianakis
2025-05-05 15:58   ` Dmitry Osipenko
2025-05-05 16:22     ` Dmitry Osipenko
2025-06-10 13:34       ` Stefano Garzarella

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=20250505-virtgpu-queue-cleanup-v1-v1-0-810923da2b1e@linaro.org \
    --to=manos.pitsidianakis@linaro.org \
    --cc=airlied@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=dmitry.osipenko@collabora.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=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    --cc=viresh.kumar@linaro.org \
    --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

all inboxes | Powered by JetHome®