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!

7
  • 1
    SSD wear due to swap is a non-issue on late model SSDs. zram/zswap only takes away resources from what you probably already don't have enough of... RAM. Edit your question and show me free -h and swapon -s and sysctl vm.swappiness and cat /etc/fstab and sudo fdisk -l and I'll take a look for you.
    – heynnema
    Commented Jun 5, 2021 at 16:38
  • The issue with swapping on SSD's has seriously impacted Apple M1 users due to relatively small RAM, and swapping on soldered SSD wearing them out.... I would argue that more recent domestic SSD's are using DLC and QLC cells, that still have under 1000 rewrite cycles.... so zswap and zram do have value. Commented Jun 6, 2021 at 15:08
  • Are you using a M1? 8G RAM? Is the SSD soldered in?
    – heynnema
    Commented Jun 6, 2021 at 15:16
  • 1
    I appreciate the fact that you are trying to help, but please understand that I am looking for information on how zswap interacts with swap on zram... rather than commentary on any specific situation. They both appear to have desirable, and potentially complimentary functionality, but I'm concerned about negative interaction between the two. Commented Jun 7, 2021 at 13:38
  • 1
    I appreciate that swappiness can be tuned to adjust how much memory pressure is required to trigger things being swapped out, but in this, and many other cases swapping things out that aren't used for long periods is desirable.... as these systems have large datasets so increasing the disk cache by 8-10GB will reduce the load on the SAN storage considerably, and swap has about a 9:1 radio write to read, which means that about 90% of what is swapped out is never read back in (pages freed)... Commented Jun 7, 2021 at 13:52

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .