mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] virtgpu: fix memory leak on device removal
@ 2025-05-05  8:59 Manos Pitsidianakis
  2025-05-05  8:59 ` [PATCH 1/3] virtgpu: add virtio_gpu_queue_cleanup() Manos Pitsidianakis
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Manos Pitsidianakis @ 2025-05-05  8:59 UTC (permalink / raw)
  To: David Airlie, Gerd Hoffmann, Dmitry Osipenko, Gurchetan Singh,
	Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Simona Vetter
  Cc: Alex Bennée, Viresh Kumar, dri-devel, virtualization,
	linux-kernel, Manos Pitsidianakis

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

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-06-10 13:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-05  8:59 [PATCH 0/3] virtgpu: fix memory leak on device removal Manos Pitsidianakis
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

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®