|
|
Log in / Subscribe / Register

The [vx]swap showdown

By Jonathan Corbet
October 8, 2026
The kernel's swap layer has undergone some significant changes over the course of the last year and a number of longstanding problems have been addressed. One problem that has not yet been solved in the mainline is the direct tie between slots in the swap cache and space in persistent swap files, which can cause highly inefficient resource use. There are two competing solutions for this problem, neither of which has, as yet, reached readiness for merging; a lengthy discussion on possible paths forward shows ongoing disagreement over the best path forward.

The kernel's zswap layer highlights the difficulties with the current design of the swap subsystem. Zswap intercepts folios that are to be pushed out to a swap file and, instead of writing them to that file, compresses their contents and stores the result in RAM. It is, essentially, a way of trading some CPU time for more free memory while keeping data close to hand and minimizing disk I/O. Use of zswap has become increasingly popular with current workloads.

The problem is that every folio stored in zswap must still have a slot assigned in a persistent swap device. If the zswap area overflows, folios may be flushed out into their assigned (persistent) slots, but normally the intent is for that to not happen. So, most of the time, that storage space is entirely wasted. It must, however, be present for zswap to be used. This problem is, it seems, especially vexing in large data centers, where massive amounts of flash storage must be dedicated to storing nothing.

One proposed solution to this problem, vswap by Nhat Pham, was described in this article. Vswap adds a new virtualization layer on top of the existing swap devices; when a folio is added to the swap cache, it is assigned a slot in this virtual layer. That slot can then be mapped to a number of different locations, including a slot in any physical swap file, a slot in zswap, or, for pages containing only zeroes, no slot at all. Folios can move between backing devices while retaining their virtual slot, making it easy to flush folios out of zswap or to evacuate a swap file prior to its removal. An xarray data structure is used to track the slots. This work has been through numerous revisions as the swap layer has changed underneath it; vswap was last posted in mid-September.

The alternative is xswap, by Baoquan He and Chris Li. In its mid-September form (it has since been updated), xswap can be thought of as a virtual swap device that does not actually have any backing store. Attempts to write folios to an xswap device do not succeed, so the device cannot actually store any data. What it can do is to provide a "physical" swap slot for folios stored in zswap. On a system where xswap is the only configured swap device, folios can be stored in zswap with no physical storage needed. Xswap uses a sparsely mapped address range for its housekeeping data, minimizing its memory use when swap usage is light.

Toward the beginning of September, Pham, who has been working on vswap for over a year, posted a lengthy query, asking how work on a virtualized swap layer could move forward. He summarized both the vswap and xswap work, noting that both projects had their advantages. For example, he said, the sparsely mapped housekeeping used by xswap was perhaps more attractive than the xarray he used for vswap.

Pham suggested that parts of both projects could eventually be merged, leading to the question of which should go first. Perhaps unsurprisingly, he suggested that vswap should be applied ahead of xswap; the latter, he suggested, can be seen mostly as an optimization that could be adopted once the major design elements of vswap were in place.

Equally unsurprisingly, the xswap developers argued that it would make more sense to merge xswap first. "The VM_SPARSE array is not an optimization to bolt on later; it is a structural choice, and the code reflects it". If vswap were to be applied first, He said, its xarray-based data structures would eventually have to be replaced with the xswap implementation. Better to add the relatively simple "foundation" that is xswap than to add the extra complexity of vswap only to remove it shortly thereafter. Kairui Song, who has done much of the swap-modernization work to date, echoed some of these arguments.

While no decisions were made in the extensive ensuing discussion, it quickly became clear that there was not a groundswell of support for xswap. The fact that xswap lacked a way to write back folios from zswap to a physical swap device was seen as a severe shortcoming that did not exist in vswap. The most contentious issue, though, stemmed from the sparsely mapped housekeeping area that is the core "structural choice" underlying xswap.

Specifically, that area requires that its full address space be reserved at the outset; that, in turn, sets a maximum size for the xswap device and, consequently, the maximum number of folios that can be stored in zswap. The size of the swap area presented by vswap, instead, can grow or shrink dynamically as needed by the workload. Johannes Weiner argued that requiring administrators to set the size of the swap area is inherently mistaken; how much memory can be stored in zswap depends heavily on how effective its compression is, which will be dependent on the workload. There is no way for an administrator to know what the proper size is, and no reason for the kernel to apply limits beyond those that already control memory use, he said.

This part of the discussion went on for a while, and it became clear that the limits applied to swap space (both in device sizing and with control groups) were being used in different and somewhat contradictory ways. Some sites use the limits to regulate the maximum virtual size of processes, while others are interested specifically in controlling the use of physical swap space. In the former case, charging zswap pages against the limits makes sense; in the latter case, it does not. Once zswap is separated from physical swap slots, developers will have to decide which use case to support, and somebody seems sure to go away unhappy. This message from Gregory Price describes the disconnect (and a possible resolution) in some detail.

The conversation eventually slowed down without any clear conclusions. An ongoing effort to set up a conference call to discuss the issue has not yet found success. In the meantime, He has posted a new xswap implementation in three parts. Part 1 is the core swap-device implementation as described above, part 2 implements the physical writeback that was missing from previous revisions, and part 3 implements the accounting for use of physical swap space. So far, the only commentary is this message from Pham, who was unhappy about the perceived use of his ideas without attribution.

The evolution of the kernel's swap subsystem has been rapid over the last year, after many years of relative stasis. The virtualization of the swap space is a logical next step that will resolve a number of longstanding problems. But the memory-management developers will want to be sure that they are getting it right; they will have to live with the consequences of their decisions for years to come. Changes in this part of the kernel often take a long time to land even in the absence of disagreement over fundamental details; this one may take longer than usual.

Index entries for this article
KernelMemory management/Swapping


to post comments

Human communication

Posted Oct 9, 2026 10:42 UTC (Fri) by jrtc27 (subscriber, #107748) [Link] (17 responses)

> The VM_SPARSE array is not an optimization to bolt on later; it is a structural choice, and the code reflects it

We're just going to ignore the fact the whole message that quote comes from reeks of LLM-ese slop style? The content may well be true, but is that really the kind of communication approach the LKML community is happy with these days, along with the lack of respect it shows for fellow developers being asked to read said communication when the author couldn't be bothered to write it themselves (which likely be more succinct and less grating)?

Some more extracts from that same email to illustrate the point, if the above quote isn't enough to convince you:

> Thanks for laying this out, and for the honest push to converge

> no branch, no RCU discipline, no tear-down state machine, and no NULL return

> I'm not going to claim xswap wins on throughput. I measured it:

> But it is a consumer of the foundation, not a reason to pick a different one

> The base should be the one that doesn't need to be redone; by both our measurements, that is the flat-cluster substrate.

Human communication

Posted Oct 9, 2026 10:54 UTC (Fri) by intelfx (subscriber, #130118) [Link] (11 responses)

We're just going to ignore the fact the whole message that quote comes from reeks of LLM-ese slop style? The content may well be true

Yeeah... there's no excuse to let an LLM generate the prose in addition to the code. If you are in a position to vouch for the LLM output (or something that contains LLM output), as you should, there'd be no issue for you to write the accompanying prose, and it'd be a far more productive use of everyone's inbox space.

Human communication

Posted Oct 9, 2026 11:41 UTC (Fri) by corbet (editor, #1) [Link] (10 responses)

I am a person who is strongly opposed to machine-generated text, but I do still think we need to give a little slack to people whose native language is far removed from English. Carrying on a technical conversation in a language one is not strong in is challenging at best.

Human communication

Posted Oct 9, 2026 11:48 UTC (Fri) by ballombe (subscriber, #9523) [Link] (7 responses)

The problem is precisely than LLM transform technical conversation to marketing speech. It is difficult to believe this an actual translation from Chinese.

It would much better the author would first write the answer in Chinese, and then ask the LLM for a translation and then send _both versions_ in a single post.

Human communication

Posted Oct 9, 2026 12:59 UTC (Fri) by jrtc27 (subscriber, #107748) [Link] (1 responses)

I don’t know that I necessarily agree with the requirement of providing both, though can see the value in it and so surely it’s better to provide the original in case of any ambiguity or odd parts of the translation. But yes, I feel very differently about using LLMs for translation. I still have personal opinions about the industry’s ethics etc that make me hesitant to say I *like* the idea, but I don’t have a problem with it if someone chooses to do so. I’ve not had experience with using such tools, as I’m fortunate enough to have English as my native language, but my understanding from talking to others that have is that they’re pretty effective at giving natural yet faithful translations, and don’t slop-ify the output, and you know that what was translated was the author’s own words from their own understanding.

Human communication

Posted Oct 9, 2026 20:01 UTC (Fri) by ballombe (subscriber, #9523) [Link]

At this stage, there are dozen of kernel developers who can read Chinese, so if English is a language barrier, there is obvious value to send the Chinese version.

Human communication

Posted Oct 22, 2026 22:11 UTC (Thu) by mrugiero (guest, #153040) [Link] (4 responses)

Or better yet, don't use LLMs as translators when there already are very good translation models. Either DeepL or Google Translate can do a decent job without turning your ideas into corpospeak.

Human communication

Posted Oct 22, 2026 23:36 UTC (Thu) by mathstuf (subscriber, #69389) [Link] (1 responses)

How long until Google Translate becomes "Gemini with a splash of paint" though?

Human communication

Posted Oct 23, 2026 2:00 UTC (Fri) by mrugiero (guest, #153040) [Link]

We can only hope they don't enshitify DeepL too, then. Or that at least whatever prompt is given is better tuned towards faithful reproduction rather than making every word into a grandiose claim that takes a paragraph.

Human communication

Posted Oct 23, 2026 8:24 UTC (Fri) by farnz (subscriber, #17727) [Link]

Note that your "translation models" of choice there are LLM-based - they're not generative models, but they are LLMs.

Human communication

Posted Nov 5, 2026 8:45 UTC (Thu) by sammythesnake (guest, #17693) [Link]

In terms of the underlying technology, LLMs really are a relatively incremental evolution of the same technology that Google Translate etc. have been using for quite some time. The main reason the effect is strikingly different ("better" for certain meanings of the word) is the sheer scale of the systems (- billions of weights, oodles of compute power...

Human communication

Posted Oct 9, 2026 12:12 UTC (Fri) by intelfx (subscriber, #130118) [Link]

I am a person who is strongly opposed to machine-generated text, but I do still think we need to give a little slack to people whose native language is far removed from English.

Yes, you're right, I neglected to consider this case in my reply, but I agree. It is obvious that if a translation must take place, it is far better and more productive for it to happen at the sender, than at (multiple) receivers. I even argued for this on lobsters, here.

This situation doesn't even fit the same pattern of negative effects — when a language model is tasked with a translation, it will (IME) follow the original tone and pacing fairly truthfully.

The communities which introduce blanket bans on LLM usage without carving out an exclusion for natural language translation (especially introducing nonsensical rules such as "every reader must translate for themselves, if they wish"), in my opinion, open themselves to chaos and mayhem as soon as these rules get exercised to any significant degree.

Human communication

Posted Oct 9, 2026 12:18 UTC (Fri) by tux3 (subscriber, #101245) [Link]

I don't want to pile on, but I'd make a distinction between machine-generated and machine-translated.
This particular LLM style is not typical when they're used as a translation tool.

When the LLM composed the answer in its own style, it's hard not to wonder how much of the thinking was also done by the LLM. Humans who coordinate the delicate process of pressing ^C and ^V are being "affectionately" called "meat proxy".

I am not saying it's the case here, as you can probably get the same result by thinking on your own and giving the LLM some high-level idea of the answer you want it to compose... but it's going to trigger antibodies in the reader just the same.

Human communication

Posted Oct 9, 2026 21:24 UTC (Fri) by goffrie (subscriber, #91599) [Link]

that quote comes from reeks of LLM-ese slop style

I immediately felt that too. Gross.

Human communication

Posted Oct 24, 2026 14:52 UTC (Sat) by Hi-Angel (guest, #110915) [Link] (3 responses)

What's the problem with that text?

FWIW, I am not a native english speaker, but I know english well enough not to use machine translation and I could've written text like this. 🤷 I see nothing unusual in it.

Human communication

Posted Oct 24, 2026 16:56 UTC (Sat) by zdzichu (subscriber, #17118) [Link] (2 responses)

Some people are just allergic to anything coming from LLMs, no matter of actual value of it. Meritocracy is dying because people are self-righteous.

Human communication

Posted Oct 24, 2026 17:48 UTC (Sat) by pizza (subscriber, #46) [Link]

> Meritocracy is dying because people are self-righteous.

No, meritocracy is dying because "merit" has been massively (and quite intentionally) devalued.

Human communication

Posted Oct 25, 2026 0:54 UTC (Sun) by Hi-Angel (guest, #110915) [Link]

Well, I mean, how do you tell it's LLM-generated, it looks like a typical human engineering talk to me.

zram?

Posted Oct 10, 2026 23:12 UTC (Sat) by fraetor (subscriber, #161147) [Link] (7 responses)

Is zram not the solution if you want compressed memory without needing a backing device? Or does zswap offer some needed features that zram does not?

zram?

Posted Oct 10, 2026 23:43 UTC (Sat) by tux3 (subscriber, #101245) [Link] (6 responses)

Some good background on zram vs zswap: https://chrisdown.name/2026/03/24/zswap-vs-zram-when-to-u...
So there's still a narrow use case for zram, but there's issues with the design, and things aren't looking up as far as I understand..

zram?

Posted Oct 11, 2026 7:58 UTC (Sun) by fraetor (subscriber, #161147) [Link] (5 responses)

So the xswap approach described in the article is for getting the diskless behaviour of zram out of zswap, without all the associated baggage of treating it as a block device?

zram?

Posted Oct 11, 2026 12:19 UTC (Sun) by intelfx (subscriber, #130118) [Link] (4 responses)

So the xswap approach described in the article is for getting the diskless behaviour of zram out of zswap, without all the associated baggage of treating it as a block device?

Yes, that’s about it. Using zram for swap is really in many ways an unacceptable abuse of mm, but people insist on doing it because they do not want, for whatever reasons, to allocate real disk space to back zswap.

zram?

Posted Oct 12, 2026 0:05 UTC (Mon) by gmprice (subscriber, #167884) [Link]

It's not they don't want to allocate disk to back zswap - it's that they don't want to have *dead* space allocated to support zswap.

If there's a page actively compressed in zswap, it allocated a writeback slot in disk - even though it's unused. It's not really feasible to know ahead of time how much disk you'll need to support zswapped entries (you might have highly compressible memory, and not have provisioned enough disk).

It makes fully utilizing the system very difficult, and wastes exabytes of storage space for scaled deployments.

zram?

Posted Oct 22, 2026 22:15 UTC (Thu) by mrugiero (guest, #153040) [Link] (2 responses)

There are environments where allocating disk space is simply not an option, for example diskless embedded devices. If all you have is a ROM and RAM, zswap is currently unusable. Which is also why it is actually being handled. If it were just a whim, I believe the maintainers would just kill zram without a viable replacement.

zram?

Posted Oct 25, 2026 15:37 UTC (Sun) by JanC_ (subscriber, #34940) [Link] (1 responses)

Killing zram would also kill zram use cases that are not related to swapping, so I don’t think the plan is to remove it entirely, just to replace one current use case for it.

zram?

Posted Oct 26, 2026 13:28 UTC (Mon) by mrugiero (guest, #153040) [Link]

What are those non-swap use cases for zram?


Copyright © 2026, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds