Hi all, I’ve switched from zram
to using a swap partition, mainly so I can enable hibernation. I also want to use zswap
, and so added the zswap.enabled=1
flag to my kernel paramaters, along with systemd.zram=0
.
So far, so good:
❯ sudo dmesg | grep zswap
[ 0.000000] Command line: initrd=\initramfs-linux-cachyos.img root=UUID=08e8ef86-7a72-4501-9d08-61dd1499106b rw cryptdevice=UUID=160f000f-ff4b-44fa-b8b2-bdf5262e1dd3:luks-160f000f-ff4b-44fa-b8b2-bdf5262e1dd3 zswap.enabled=1 systemd.zram=0 nowatchdog splash module_blacklist=intel_hid
[ 0.062544] Kernel command line: initrd=\initramfs-linux-cachyos.img root=UUID=08e8ef86-7a72-4501-9d08-61dd1499106b rw cryptdevice=UUID=160f000f-ff4b-44fa-b8b2-bdf5262e1dd3:luks-160f000f-ff4b-44fa-b8b2-bdf5262e1dd3 zswap.enabled=1 systemd.zram=0 nowatchdog splash module_blacklist=intel_hid
[ 0.681594] zswap: loaded using pool zstd/zsmalloc
To test, I ran stress-ng --memthrash 60
, and yes, the swap was being written to (heavily), but zswap was not being hit:
[root@grayarea matt]# grep -r . /sys/kernel/debug/zswap/
/sys/kernel/debug/zswap/stored_pages:0
/sys/kernel/debug/zswap/pool_total_size:0
/sys/kernel/debug/zswap/written_back_pages:0
/sys/kernel/debug/zswap/reject_compress_poor:0
/sys/kernel/debug/zswap/reject_compress_fail:0
/sys/kernel/debug/zswap/reject_kmemcache_fail:0
/sys/kernel/debug/zswap/reject_alloc_fail:0
/sys/kernel/debug/zswap/reject_reclaim_fail:0
/sys/kernel/debug/zswap/pool_limit_hit:0
So, following the instructions from the Arch Wiki (“all praise be”) I ran:
echo 1 > /sys/modules/zswap/parameters/enabled
and lo! In Kernel debug I could now see that zram was being hit. Hoorary!
The problem is, after a reboot, /sys/modules/zswap/parameters/enabled
is once again set to 0, despite having zswap.enabled=1
.
Any ideas why it defaults to off? I guess I could make a systemd unit to set it every boot, but according to the wiki just setting the kernel parameter is enough, and I’d rather know why it’s not working if possible.
Cheers,
Matt.