4

I currently have most of my swap on Zram, since I don't want to wear my SSD excessively.

BUT, I do have a swap partition left over from when the system was installed, and I just lowered the priority of this, and enabled it as well...

My question is this:-

  1. Can I enable Zswap, to provide it's writeback cache function for my SSD based swap, without it trying to cache the Zram based swap?...

  2. What exactly does the priority do, I assume it's just a matter of "fill X before Y", but is it possible to have long term stuff stored in one swap area and more transient stuff stored in another... say Zram for transient, with longer term stuff stored on SSD.

  3. Is there any way to see which swaps have Zswap active?

I understand the implications (and apparent illogic) of swapping to RAM, this is a question regarding what criteria zswap uses to determine if it should cache a device, or not... and how it plays with swap on zram.

Note: I have enough ram to run without swap 99% of the time, but it's normal for initialisation code and perhaps the odd memory leak accumulate and this would be swapped out if it could be.... so zram swap will half the usage of this compared to having no swap and it has almost no overhead otherwise. Also, I support a large number of Linux systems, many of which cannot have disk based swap... so I want to know if zswap and zram play nice together, so that I know if this is something I /can/ do if the situation warrants it, or not.

By "Play Nice", I mean... zswap should cache "disk/ssd" based swap, but no zram based swap!

1 Answers1

0

This is "a little" late, but maybe this is still helpful for someone... I don't have an Ubuntu machine but I guess the kernel will behave similar. If you enable zram on NixOS, zswap is not disabled so exactly your described behaviour. I wondered if this would be a problem, this is how I found this question.

I used my system to let it swap out stuff and looked into the kernel statistics (/sys/kernel/debug/zswap) if zswap is used.

The answer is: the kernel is smart enough to not use zswap for a zram device.

Argeman
  • 101