LWN: Comments on "Compressed swap" https://lwn.net/Articles/591961/ This is a special feed containing comments posted to the individual LWN article titled "Compressed swap". en-us Sun, 12 Oct 2025 08:35:07 +0000 Sun, 12 Oct 2025 08:35:07 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net Compressed swap https://lwn.net/Articles/594786/ https://lwn.net/Articles/594786/ nybble41 <div class="FormattedComment"> <font class="QuotedText">&gt; ... this would require some additional complexity in zswap to track which backing pages are actually available and which need to be paged in.</font><br> <p> I agree that zswap would need to keep track of its pages. However, there shouldn't be any risk of accidentally triggering swapping. The compressed pages would only be read from swap at zswap's request.<br> <p> <font class="QuotedText">&gt; You might also have some terrible / recursive locking and code flow going on ...</font><br> <p> I don't think so. The requests should be unidirectional, not recursive. The zswap RAM would be reserved and managed by zswap, not the pager. This assumes that zswap can access the swap interface directly the same way the pager does; if the pager and swap are tightly integrated then some refactoring would be in order.<br> <p> Memory request -&gt; no clean pages -&gt; pager -&gt; zswap -&gt; write existing page directly to swap -&gt; compress new page -&gt; free source page -&gt; resume thread.<br> <p> Page fault -&gt; pager -&gt; zswap -&gt; read compressed page back from swap into preallocated buffer -&gt; decompress into target RAM -&gt; resume thread.<br> </div> Mon, 14 Apr 2014 22:36:15 +0000 Compressed swap https://lwn.net/Articles/594643/ https://lwn.net/Articles/594643/ kmeyer <div class="FormattedComment"> <font class="QuotedText">&gt; The idea was that when frontswap hands a page to zswap and there isn't enough room for it in zswap's RAM, zswap picks one of its less-recently-used compressed pages and hands it off to the normal swap code, storing whatever token it gets back to identify the page for later retrieval.</font><br> <p> Usually (I think) the page (a pointer in virtual memory) is unmapped from the page table and swapped out. Then when that pointer is accessed, a hardware fault occurs because the VMA is unmapped, and the kernel fault handler then brings back the page from swap.<br> <p> <font class="QuotedText">&gt; That frees up the page to store the new compressed data. Later, if and when frontswap asks for one of the old pages' data back, zswap can request the compressed page back from the normal swap subsystem and handle the request as it normally would.</font><br> <p> So, the way this would actually be implemented (I think) is allowing pages in zswap's backing store to be swapped, but only when requested by zswap's front-end.<br> <p> Because you don't want to accidentally access those backing pages and bring them back in and trigger more swapping elsewhere, this would require some additional complexity in zswap to track which backing pages are actually available and which need to be paged in.<br> <p> You might also have some terrible / recursive locking and code flow going on between the memory request -&gt; no clean pages -&gt; need to swap a page -&gt; pager &lt;-&gt; zswap &lt;-&gt; pager again(!); I'm unfamiliar with the area but it sounds like a nightmare (that zswap likely tries very hard to avoid right now with zbud).<br> <p> It may be possible, but it would probably be a pain in the ass to implement and would have room for latent bugs.<br> </div> Mon, 14 Apr 2014 02:30:17 +0000 Compressed swap https://lwn.net/Articles/592460/ https://lwn.net/Articles/592460/ nybble41 <div class="FormattedComment"> <font class="QuotedText">&gt; it would need changes on the code which retrieves the pages from swap...</font><br> <font class="QuotedText">&gt; you wouldn't be able to mix zswap and regular swap on the same system</font><br> <p> Why is that? What I had in mind seemed fairly simple to integrate, though I'm not a Linux kernel developer and may be missing something. The idea was that when frontswap hands a page to zswap and there isn't enough room for it in zswap's RAM, zswap picks one of its less-recently-used compressed pages and hands it off to the normal swap code, storing whatever token it gets back to identify the page for later retrieval. That frees up the page to store the new compressed data. Later, if and when frontswap asks for one of the old pages' data back, zswap can request the compressed page back from the normal swap subsystem and handle the request as it normally would.<br> </div> Fri, 28 Mar 2014 22:31:46 +0000 Compressed swap https://lwn.net/Articles/592447/ https://lwn.net/Articles/592447/ gfa <div class="FormattedComment"> &gt; Hm, why cannot zswap write compressed pages on the disk avoiding the need for decompression?<br> <p> while it would be **awesome** it would need changes on the code which retrieves the pages from swap, it would make zswap non-optional (at least runtime)<br> or at least you wouldn't be able to mix zswap and regular swap on the same system<br> unless you mark the compressed pages as compressed. <br> <p> a simple solution would be run 2 swap devices one for compressed and other for non-compressed pages<br> <p> </div> Fri, 28 Mar 2014 20:05:01 +0000 Compressed swap https://lwn.net/Articles/592295/ https://lwn.net/Articles/592295/ nybble41 <div class="FormattedComment"> <font class="QuotedText">&gt; Hm, why cannot zswap write compressed pages on the disk avoiding the need for decompression?</font><br> <p> That was my thought as well. Instead of evicting (possibly multiple) compressed pages into uncompressed swap, why not just evict one of the pages holding compressed data instead? Besides avoiding decompression, you'd save swap space and I/O bandwidth, and avoid the issue of needing to write out several pages of previously compressed data to make room for a one new page.<br> </div> Thu, 27 Mar 2014 18:07:10 +0000 Compressed swap https://lwn.net/Articles/592203/ https://lwn.net/Articles/592203/ ibukanov <div class="FormattedComment"> <font class="QuotedText">&gt; That involves decompressing the data, then writing the resulting pages to the swap device. That can slow things down significantly. </font><br> <p> Hm, why cannot zswap write compressed pages on the disk avoiding the need for decompression?<br> <p> <font class="QuotedText">&gt; The cost, of course, would be in the form of increased swap device I/O and space usage. </font><br> <p> This is unacceptable if one uses cheap flash device as it introduces too much wear. The current implementation prevents that nicely.<br> <p> <font class="QuotedText">&gt; What the compressed swapping subsystems really need, he said, is better demonstration workloads. </font><br> <p> From personal experience zram works very nicely on a chromebook allowing to run several Eclipse instances with multiple tabs opened in the browser on 2 GB machine with no swap. So I wonder why nobody at Google bothers to provide those workloads...<br> </div> Thu, 27 Mar 2014 12:31:24 +0000