systemd / zram-generator

Systemd unit generator for zram devices
MIT License
575 stars 48 forks source link

Will tmpfs use the swap space created by zram-generator? #173

Closed daiaji closed 1 year ago

daiaji commented 1 year ago

https://github.com/systemd/systemd/issues/12342

I don't get it.

So there are two approaches:

  1. Mount file system X as ramfs
  2. Mount file system X as tmpfs, but enable zswap?

It appears to me that option 2 is always the better approach, since tmpfs is backed by swappable memory anyway, and thus by enabing zswap you allow to the kernel freedom to choose what precisely to swap out or not, regardless if that's file system X or anything else. i.e. why make the link between compressed RAM backing and specific file systems explicit if you might as well make it implicit, and let the kernel choose what to swap out and what not?

https://wiki.archlinux.org/title/tmpfs

tmpfs is a temporary filesystem that resides in memory and/or swap partition(s). Mounting directories as tmpfs can be an effective way of speeding up accesses to their files, or to ensure that their contents are automatically cleared upon reboot.

It looks like the zram swap space generated by zram-generator should be usable by tmpfs. Moreover, zram supports write-back devices, but zswap does not.

nabijaczleweli commented 1 year ago

tmpfs allocates from virtual memory, and every source agrees. Not sure what the question is.