edit: I decreased swappiness and increased vfs cache pressure to reduce the amount of swapping in general.

I'm noticing that a very intended behavior of Zswap is to write pages to disk when they don't cleanly compress (or for some other reason). How can I configure it to act kind of like Zram but only writeback when the system is actually out of RAM?

grep -R . /sys/kernel/debug/zswap/
/sys/kernel/debug/zswap/stored_incompressible_pages:8224
/sys/kernel/debug/zswap/stored_pages:218538
/sys/kernel/debug/zswap/pool_total_size:229318656
/sys/kernel/debug/zswap/written_back_pages:251371
/sys/kernel/debug/zswap/decompress_fail: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

My parameters: zswap.enabled=1 zswap.compressor=zstd zswap.shrinker_enabled=0 zswap.max_pool_percent=20. Swappiness is at default value.

you are viewing a single comment's thread
view the rest of the comments
[–] 8 points 2 days ago*

I don't think Zswap can be tuned like that.

The idea is that the Linux kernel wants to get rid of this page of memory only because it has something better to use that memory for. So if it's uncompressible then it should go to swapfile for optimal performance. Otherwise it means something else is getting kicked to swapfile, and it wasn't the kernel's first choice to be moved to swap so that's even worse, and what happens if that is also uncompressible? Now you've got a cascading failure.

  • source