I have been trying to prevent Plasma display processes from entering swap, to test a theory that Kwin and Plasmashell’s swap usage is causing the occasional hiccups I am experiencing during high memory pressure (i.e. games that allocate unified VRAM). I’m fairly certain the hiccups are caused by swap, since I had disabled it for many months and never had a single issue. Only when I enabled Zswap that I started getting frequent Plasma hiccups.
I would normally disable swap in a circumstance like this, but being OOM at a random point in my game is much worse for performance than having some noticeable jitters on my desktop.
I am on OpenSUSE Tumbleweed using KDE Plasma. I have an Intel Core Ultra 7 256V with unified iGPU memory, and 16 GB RAM. Additionally, I installed 16GB of Swap (swappiness=10) with ~3GB frontswap (Zswap). My system is using the unified cgroupv2.
These are my GRUB boot parameters: splash=silent resume=/dev/disk/by-uuid/12abfd6c-9398-462d-81d3-5c4556a6809d quiet security=apparmor mitigations=auto zswap.enabled=1 zswap.compressor=zstd zswap.shrinker_enabled=0 zswap.max_pool_percent=20.
I wrote this override using systemctl edit --user for plasma-plasmashell and plasma-kwin_wayland:
# ~/.config/systemd/user/plasma-plasmashell.service.d/override.conf
[Service]
MemorySwapMax=0
MemoryZSwapMax=0
StartupMemorySwapMax=0
StartupMemoryZSwapMax=0
I know these two processes are using swap via /proc/NN/smaps_rollup. I attempted to fix this by applying this override, rebooting, and verifying with systemctl show --user. To test, I usually open up a bunch of processes like Firefox, Thunderbird, and Terraria. I re-run my script to check that /proc/NN/smaps_rollup file for all processes. Plasmashell and (most often) Kwin are still occupying swap (~1M) after a restart. I’ve noticed that things get really laggy whenever plasmashell is placed in swap, and only desktop effects are affected when Kwin is swapped.
Here is an example output of my script (columns: KB, PID, CMD)
./ps_swap.sh | grep -E 'way|kwin|plasma|kde'
860 249267 /usr/bin/kwin_wayland --wayla
2108 2915 /usr/bin/kwin_wayland_wrapper
4916 3169 /usr/libexec/org_kde_powerdev
5608 2842 /usr/bin/startplasma-wayland
6980 2931 /usr/bin/kded6
7824 3168 /usr/libexec/polkit-kde-authe
8796 3271 /usr/bin/kdeconnectd
I did a little digging into the cgroupv2 file structure, and checked kwin’s cgroup for a file called memory.swap.current, which didn’t exist:
# ls /sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/session.slice/plasma-kwin_wayland.service/memory*
/sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/session.slice/plasma-kwin_wayland.service/memory.pressure
# cat /sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/session.slice/plasma-kwin_wayland.service/cgroup.controllers
pids