https://bugs.kde.org/show_bug.cgi?id=529126
Bug ID: 529126
Summary: kwin_wayland gets slower over days of uptime:
amdgpu_vamgr_find_va hot in dmabuf import, cursor lags
until re-login
Classification: Plasma
Product: kwin
Version First unspecified
Reported In:
Platform: Other
OS: Linux
Status: REPORTED
Severity: normal
Priority: NOR
Component: wayland-generic
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
Created attachment 198664
--> https://bugs.kde.org/attachment.cgi?id=198664&action=edit
perf-kwin-6.7.5.txt
SUMMARY
After several days in the same Plasma Wayland session, kwin_wayland uses more
and more CPU on its main thread. The mouse cursor becomes laggy on the desktop,
and games stutter even when nothing else is busy. Logging out and back in fixes
it immediately. perf shows that most of the extra time is spent in
libdrm_amdgpu's amdgpu_vamgr_find_va(), called from
KWin::EglDisplay::importDmaBufAsImage().
Firefox (native Wayland) is the main client driving this. Restarting Firefox
lowers kwin's load but does not reset it. On the second try the symptoms came
back after only one day, while the KWin process was 9 days old. So the slow
part seems to be state that builds up inside the long-running KWin process,
possibly in the GPU virtual-address allocator.
STEPS TO REPRODUCE
1. Log into a Plasma Wayland session on an AMD GPU (RDNA3 here).
2. Use the desktop normally for several days: Firefox with many tabs, Steam, a
Proton game, nightly suspend to RAM.
3. After about 4 to 8 days, move the mouse and watch kwin_wayland's CPU usage.
OBSERVED RESULT
- The cursor is visibly laggy. Games running through Xwayland/DXVK stutter. In
one measurement, 56 to 68 ms frame gaps lined up with 50 to 60 ms CPU bursts of
kwin_wayland; the game's own threads were idle in futex waits during those
gaps.
- The journal fills up with "Key repeat discarded, Wayland compositor doesn't
seem to be processing events fast enough" (about 10 per day early in the
session, 271 on day 8).
- kwin_wayland's CPU usage (averaged over 2-10 s while the desktop was in use):
fresh session, no Firefox: about 2 %
session 8 days old, Firefox 8 days old: about 33 %
after closing Firefox: 5-8 %
after also closing Steam, TeamSpeak 3, the game: 1-2 %
Firefox restarted, same tabs restored: about 9 %
one day later (KWin 9 days old, Firefox 1 day old): 5-60 %, spiky,
about 25 % mean, cursor laggy again
after restarting Firefox again: 11-13 %
- Re-login resets everything. Suspend alone is not the trigger: 12
suspend/resume cycles in a fresh session did not reproduce it.
perf (sudo perf record -g -p $(pgrep -x kwin_wayland) -- sleep 20, mouse
moving; full text output attached):
KWin 6.7.5, session 9 days old:
56.74 % amdgpu_vamgr_find_va (libdrm_amdgpu.so.1.134.0)
<- amdgpu_va_range_alloc2 <- amdgpu_bo_from_handle (54.50 %) <-
si_texture_from_handle
<- dri2_from_dma_bufs <- dri2_create_image_dma_buf <- _eglCreateImageCommon
<- KWin::EglDisplay::importDmaBufAsImage <-
KWin::EglDisplay::importBufferAsImage
42.93 % <- KWin::BufferTextureOpenGL::attach <-
ItemRendererOpenGL::createTexture <- SurfaceItem::preprocess <- ...
Compositor::composite
6.41 % <- KWin::EglBackend::testImportBuffer <-
LinuxDmaBufParamsV1::zwp_linux_buffer_params_v1_create_immed
5.16 % <- KWin::BufferTextureOpenGL::attach (Region overload) <-
SurfaceItem::preprocess
KWin 6.8.2, session 8 days old (after updating; the update did not help):
23.16 % amdgpu_vamgr_find_va
<- amdgpu_bo_from_handle (19.97 %) <- ... <-
KWin::EglDisplay::importDmaBufAsImage
13.51 % <- importBufferAsImage <- ItemRendererOpenGL::createTexture <-
SurfaceItem::preprocess <- renderLayer
EXPECTED RESULT
kwin_wayland's cost per frame or per buffer import stays the same no matter how
long the session has been running.
HYPOTHESIS (unverified)
Each dmabuf import allocates a GPU VA range through libdrm's amdgpu_vamgr,
which searches a list of free holes linearly. If the VA space of the long-lived
KWin process fragments over days, every import gets slower. Clients that keep
sending new dmabufs (Firefox here) would then hit KWin's main thread on every
import. Two questions for the KWin side:
- Should imported EGLImages be cached or reused more aggressively, so that a
client sending new buffers does not cause an import on every frame?
- If the cost really is in libdrm/Mesa, should this be moved to Mesa?
SOFTWARE/OS VERSIONS
Operating System: Fedora Linux 44
KDE Plasma Version: 6.8.2 (also seen on 6.7.5)
KWin: 6.8.2-3.fc44 (also 6.7.5-1.fc44)
Qt Version: 6.11.2
Kernel Version: 7.2.15-200.fc44.x86_64 (also 7.2.11)
Graphics Platform: Wayland
Mesa: 26.2.6 (also 26.2.5), radeonsi/RADV
libdrm: 2.4.134
Xwayland: 24.1.14
Firefox: 159.0.1 (Fedora RPM, native Wayland, VA-API in use)
HARDWARE
CPU: AMD Ryzen 7 9800X3D (integrated Radeon 610M is enabled but drives no
outputs)
GPU: AMD Radeon RX 7800 XT (Navi 32)
Displays: 2x 1920x1080 @ 120 Hz over DisplayPort, both on the RX 7800 XT, no
VRR
RAM: 64 GB
ADDITIONAL INFORMATION
- Attached: perf-kwin-6.7.5.txt and perf-kwin-6.8.2.txt (top 100 lines of perf
report --stdio --no-children).
- The machine suspends to RAM every night. Uptime between reboots is 1-2 weeks.
- Workaround: log out and back in. Restarting Firefox helps only partly and
only for a short time.
--
You are receiving this mail because:
You are watching all bug changes.