All of lore.kernel.org
 help / color / mirror / Atom feed
* drm/vmwgfx: graphics memory not returned after all GEM objects are released
@ 2026-08-05 20:41 Jellis Onsea | AccessWeb
  2026-08-05 20:48 ` Zack Rusin
  2026-08-06 21:24 ` Maaz Mombasawala
  0 siblings, 2 replies; 9+ messages in thread
From: Jellis Onsea | AccessWeb @ 2026-08-05 20:41 UTC (permalink / raw)
  To: zack.rusin; +Cc: dri-devel, bcm-kernel-feedback-list

Hi Zack,

I'm reporting a memory issue in vmwgfx where graphics memory is not 
returned to the system even after every DRM client has released its GEM 
objects. Only a reboot frees it. This comes out of KDE bug 523812, which 
was closed as RESOLVED UPSTREAM with the assessment that this looks like 
a driver-side leak rather than a compositor one.

- Environment:

     Guest:      CachyOS (Arch-based), kernel 7.1.5 and 7.1.6
     Host:       VMware Workstation on Windows, AMD Ryzen 9 7950X
     Driver:     vmwgfx 2.21.0.0, VMware SVGA II
     Renderer:   llvmpipe (LIBGL_ALWAYS_SOFTWARE=1, see note below)
     Compositor: KWin 6.7.3, Plasma Wayland, 3 x 1920x1080 @ 60 Hz
     RAM:        31 GiB, zram swap
     3D accel:   disabled in the VM settings

- What happens:

During normal desktop use, buffers of exactly 8355840 bytes accumulate. 
That is 1920 x 1088 x 4 — one screen-sized 32-bit framebuffer with the 
height padded to a multiple of 64. Growth is tied to rendering activity, 
not to uptime: an unattended session leaked exactly zero bytes over 7.3 
hours, while active use adds roughly 1.4 GB/hour.

At 9 hours of uptime, kwin_wayland held 1846 GEM objects, 1553 of them 
that exact size. All of them had pin_count = 0. At 34.5 hours it was 
8057 objects.

- The measurement that points at the driver:

I logged out of the Plasma session and logged back in, without 
rebooting. That restarts the compositor (pid 2612 -> 3156650) and closes 
its DRM fd, so the kernel drops all its GEM references.

                                   before logout      after re-login
     GEM objects, all clients      8139               19
     system_ttm usage              49.47 GB           45.80 GB
     GPUActive (/proc/meminfo)     10.86 GB           11.06 GB
     MemAvailable                  11.06 GB           13.32 GB

So: no DRM client held more than 19 GEM objects in total, yet roughly 11 
GB remained accounted as GPUActive and was not returned. The ~2.3 GB 
gained in MemAvailable is very likely just the browsers and editors from 
the old session exiting, not graphics memory.

A reboot immediately afterwards did return it:

     GPUActive     0.11 GB
     RAM in use    4.5 GB of 31 GB   (was 18 GB before the reboot)

- Caveats I want to be upfront avout:

- system_ttm reporting 46-49 GB on a machine with 31 GiB of RAM is 
something I cannot explain. My assumption is that TTM accounts pages it 
has evicted to shmem, while GPUActive counts only resident ones. If that 
assumption is wrong, the volume figures need reinterpreting. The object 
counts and the fact that a reboot is required stand either way.
- Summing the reported sizes of the GEM objects gives ~46 GB, which also 
exceeds physical RAM, so that sum over-counts — presumably shared or 
multiply-mapped objects. I would trust the counts, not that total.
- This is a CachyOS kernel, not vanilla. I have not yet reproduced on 
mainline. I am happy to test a vanilla or drm-tip kernel if that would 
help; the machine reproduces this within a working day.
- LIBGL_ALWAYS_SOFTWARE=1 is set here to work around an older, separate 
vmwgfx surface-handle problem that crashed Chromium/Electron compositor 
threads with SIGILL. The behaviour described above occurs with that 
workaround in place.

- Possibly related earlier work:

I am aware of the dumb-buffer leak fixes in vmwgfx from the 6.10 era 
("drm/vmwgfx: Fix handling of dumb buffers", "drm/vmwgfx: Fix dumb 
buffer leak") and the rework that made GEM handles own the dumb buffer. 
The buffers accumulating here are exactly screen-sized dumb buffers, so 
this may well be in the same area, but on a much newer kernel, so either 
something remains or it is a regression. I did not find an open report 
matching this.

- How to reproduce the measurements:

     # object count and per-client totals (root)
     grep -c bytes /sys/kernel/debug/dri/0/vmwgfx_gem_info
     awk '/^ *pid/{p=$2" "$4} /bytes/{n[p]++; s[p]+=$2} \
          END{for(k in n) printf "%-26s %6d objects %9.1f MB\n", k, 
n[k], s[k]/1048576}' \
         /sys/kernel/debug/dri/0/vmwgfx_gem_info | sort -k3 -rn

     # pool usage (root)
     awk '/usage:/{print $2}' /sys/kernel/debug/dri/0/system_ttm

     # resident graphics memory
     grep -E 'GPUActive|GPUReclaim' /proc/meminfo

Use the desktop normally for a few hours; a browser window with a 
looping CSS animation makes it measurable within minutes. Opening and 
closing 32 windows produced no growth at all, so it is the continuous 
rendering that drives it.

Happy to run anything specific, apply a debug patch, or test a different 
kernel.


Regards,

Jellis Onsea
AccessWeb

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: drm/vmwgfx: graphics memory not returned,after all GEM objects are released
@ 2026-08-08 10:58 Jellis Onsea | AccessWeb
  2026-08-13 21:12 ` Maaz Mombasawala
  0 siblings, 1 reply; 9+ messages in thread
From: Jellis Onsea | AccessWeb @ 2026-08-08 10:58 UTC (permalink / raw)
  To: maaz.mombasawala, zack.rusin; +Cc: dri-devel, bcm-kernel-feedback-list

Hi Maaz, Zack,

I have a test result, but not the one you asked for.. the bug stopped
reproducing before I could test the patch, and the reason may be useful 
to you.

Short version: enabling 3D acceleration on the VMware host made the leak 
go away, with the stock distribution mesa. No patch involved.

-- What I changed:

Until 7 August this guest ran with 3D acceleration disabled in the VM 
settings, and additionally forced llvmpipe via LIBGL_ALWAYS_SOFTWARE=1. 
That was the configuration in my original report.

I enabled 3D on the host and removed the LIBGL_ALWAYS_SOFTWARE override, 
so the whole session -- kwin_wayland, plasmashell, clients -- now runs 
on svga:

     OpenGL renderer string: SVGA3D; build: RELEASE;  LLVM;
     Driver: VMware (SVGA3D)
     mesa 26.1.6-arch3.1   (distribution build, NOT patched)

-- Measurements:

Sampled every 15 minutes. system_ttm and mob_ttm are the two TTM pools 
from /sys/kernel/debug/dri/0/, "total" is their combined growth:

session start        hours   system_ttm        mob_ttm         total objects
  
------------------------------------------------------------------------------
     2026-08-02 20:37       7.8    4.73 -> 15.09   0.023 -> 0.023 
+1355 MB/h   753 -> 2184
     2026-08-03 04:36      34.8    0.11 -> 46.57   0.023 -> 0.023 
+1367 MB/h    23 -> 8211
     2026-08-04 15:37      33.1    0.10 -> 32.07   0.023 -> 0.023 
+989 MB/h    31 -> 5586
     2026-08-06 00:59      25.7    0.32 -> 17.07   0.023 -> 0.023 
+667 MB/h    49 -> 2680
     --- 3D enabled, svga in use from here ---
     2026-08-07 02:48      15.6    0.06 ->  0.05   0.131 -> 0.216 
+5 MB/h    85 ->  244
     2026-08-07 18:35      18.2    0.08 ->  0.19   0.266 -> 0.555 
+22 MB/h  1357 -> 3272

Same machine, same kernel (7.1.6), same mesa package, comparable desktop 
use. The last row is a full working day plus a night.

Two details that may matter more than the totals:

- --mob_ttm never moved in any of the four pre-3D sessions-- 409 samples 
over four days, constant at 0.023 GB. With svga it moves. The memory is 
coming out of a different pool.

- --The dominant buffer changed size-- Without 3D it was 8355840 bytes = 
1920 x 1088 x 4, height padded to a multiple of 64 -- the signature of a 
dumb buffer. With svga it is 8294400 = 1920 x 1080 x 4, exactly the 
screen, no padding.

So the configuration I reported was not exercising the svga driver at 
all, which was the question in my previous mail: the leak I measured was 
on the dumb-buffer/kms_swrast path, not through gallium svga.

-- About the patch:

I did build it, to be able to test properly: staging/26.1 at 2ed36c6 
("svga: Pass buffer handle for fd handles for resource_from_handle()", 
the backport of b460cff2 from your MR 43386). Verified it was actually 
loaded.. the version string reads "Mesa 26.1.6 (git-2ed36c6b5d)" and the 
vmw_winsys_to_dma_buffer symbol is present.

I have not been able to give it a meaningful before/after, because in 
the configuration where svga is in use the leak is already absent with 
the unpatched driver. I am not claiming the patch is unnecessary -- I am 
saying my machine no longer reproduces the problem it fixes.

If it helps, I can put the guest back on 3D-disabled and measure there 
with and without the patched build. Given the above I suspect it would 
show nothing, since svga is not loaded in that configuration, but say 
the word and I will run it.

-- One correction to something I nearly reported:

While switching, plasmashell started segfaulting on "dmabuf import 
failed to mmap". I was close to reporting that as a second driver bug. 
It was not: I had left LIBGL_ALWAYS_SOFTWARE=1 in place, which 
plasmashell honours but kwin does not (it goes through EGL). That left 
the compositor on svga and a client on llvmpipe trying to CPU-map a 
guest-backed buffer. With both on the same driver it is gone: 18 hours, 
zero occurrences.

The one thing that does look like a real bug is on the KDE side, not 
yours: the failed mmap leads to SIGSEGV (si_code = SEGV_MAPERR) rather 
than a blank thumbnail. I will report that to them separately.

-- Environment:

     Guest:      CachyOS (Arch-based), kernel 7.1.6-1-cachyos
     Host:       VMware Workstation on Windows, AMD Ryzen 9 7950X
     Driver:     vmwgfx, VMware SVGA II, 3D acceleration now ENABLED
     Compositor: KWin 6.7.4, Plasma Wayland, 3 x 1920x1080 @ 60 Hz
     mesa:       26.1.6-arch3.1
     max mob size: 1048576 KiB   (was 262144 KiB with 3D disabled)


Happy to run anything specific, on either configuration.


Regards,

Jellis Onsea
AccessWeb

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

end of thread, other threads:[~2026-08-21  2:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-05 20:41 drm/vmwgfx: graphics memory not returned after all GEM objects are released Jellis Onsea | AccessWeb
2026-08-05 20:48 ` Zack Rusin
2026-08-06 21:24 ` Maaz Mombasawala
  -- strict thread matches above, loose matches on Subject: below --
2026-08-08 10:58 drm/vmwgfx: graphics memory not returned,after " Jellis Onsea | AccessWeb
2026-08-13 21:12 ` Maaz Mombasawala
2026-08-16 16:57   ` Jellis Onsea | AccessWeb
2026-08-17 22:02     ` Maaz Mombasawala
2026-08-18  1:08       ` Jellis Onsea | AccessWeb
2026-08-21  2:09         ` Maaz Mombasawala

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.