KWin 6.7.x causes massive kmalloc-128 kernel slab leak on NVIDIA driver (Wayland)

Starting with KDE Plasma 6.7.0, a large kmalloc-128 kernel slab leak appears immediately after logging into a Wayland session with the NVIDIA proprietary driver. Plasma 6.6.5 is completely clean on identical hardware and drivers.

NVIDIA GTX 1060 6GB Driver: 580.173.02 (also reproduced on 580.159.04)
Arch Linux 7.0.14-arch1-1
Plasma 6.7.2 Wayland

Reproduction steps:
Boot Arch Linux with Plasma 6.7.x and NVIDIA proprietary driver on Wayland
Log in to the desktop
Run cat /proc/meminfo | grep SUnreclaim and sudo slabtop -o -s c | grep kmalloc-128

Stats with Plasma 6.7.2 + NVIDIA driver (580.173.02), immediately after login:

slabtop -o -s c | head -n 10
 Active / Total Objects (% used)    : 12240844 / 12257229 (99.9%)
 Active / Total Slabs (% used)      : 382327 / 382327 (100.0%)
 Active / Total Caches (% used)     : 148 / 230 (64.3%)
 Active / Total Size (% used)       : 1649654 / 1652428 (99.8%)
 Minimum / Average / Maximum Object : 0.01K / 0.13K / 17.41K

    OBJS   ACTIVE  USE OBJ SIZE  SLABS OBJ/SLAB CACHE SIZE NAME                 
11537792 11537792 100%    0.12K 360556       32    1442224 kmalloc-128            
   85848    85824  99%    1.11K   3066       28      98112 ext4_inode_cache       
  113463   113459  99%    0.19K   5403       21      21612 dentry                 


cat /proc/meminfo | grep -iE 'slab|sreclaimable|sunreclaim'
Slab:            1688844 kB
SReclaimable:     147136 kB
SUnreclaim:      1541708 kB

KDE bug report: bugs.kde.org/show_bug.cgi?id=522300
KDE triaged it as a regression and suggested reporting here.

nvidia-bug-report.log.gz (1.1 MB)

I’ve encountered the same issue with RTX 3090 on driver nvidia-open 610.43.02, but it persisted even without starting a graphical session. Resolved by installing a proprietary driver version 580.173.02.

The perf utility report was full of lines like this:

kworker/11:1+ev     146 \[011\]   351.787045: kmem:kmalloc: call_site=drm_mode_duplicate+0x23 ptr=0xffff8e1b40ba2180 bytes_req=120 bytes_alloc=128 gfp_flags=GFP_KERNEL|\__GFP_ZERO node=-1 accounted=false

On my end SUnreclaim is 80MB before login, spikes to 1.5-6GB after KWin launches. perf capture shows kwin_wayland spamming

kwin_wayland     618 [002]   135.627903: kmem:kmalloc: call_site=drm_mode_duplicate+0x23 ptr=0xffff8cda4a2bca80 bytes_req=120 bytes_alloc=128 gfp_flags=GFP_KERNEL|__GFP_ZERO node=-1 accounted=false

Leak originates entirely from KWin session startup.

Actually not resolved, just didn’t manifest right away for some reason

The leak is triggered specifically by a custom EDID override (via /sys/kernel/debug/dri/1/HDMI-A-1/edid_override) containing a non-standard refresh rate 74hz (the monitor only exposes 60hz max). The custom EDID only differs from the stock one by replacing an interlaced 1920x540i@60hz mode with a progressive 1920x1080@74hz mode (DTD3). While the custom EDID is loaded, setting the refresh rate in plasma to anything other than 60hz causes the leak. I tested this by setting it with to a built in 50hz mode and it still leaks as long as the custom EDID is active