Re: Virtual Swap Sync
From: Johannes Weiner
Date: Fri Dec 04 2026 - 14:44:30 EST
On Fri, Dec 04, 2026 at 11:30:46AM -0700, Nhat Pham wrote:
> On Tue, Dec 1, 2026 at 10:27 PM Chris Li <chrisl@xxxxxxxxxx> wrote:
> >
> > On Mon, Nov 30, 2026 at 4:26 AM Nhat Pham <nphamcs@xxxxxxxxx> wrote:
> > > Ah I see. It's logical footprint, but enforced on an allocation/used
> > > basis rather than mapping (i.e address space reservation, which
> > > existing vm.overcommit modes regulate).
> > >
> > > I think swap sizing is still the wrong interface for this. IMHO, it's
> > > a crude emulation, with some downsides:
> > >
> > > Say the desired logical memory limit is 4GB. We have 2GB of physical
> > > memory limit, so we emulate that by setting swap size to 2GB. Now say
> > > I have a hot file cache of 1GB, and 3GB of cold anon. That should be
> > > allowed, but you'd thrash prematurely or OOM because you can only
> >
> > I think you and Kairui have different requirement and assumption in mind.
> > You seem to want the maximum compression. (Max memory savings).
> > Kairui's usage case cares about the consistency serving quality by
> > limiting the total amount of swap (a bounded performance penalty
> > caused by swap). My read is that, page faults have a much higher
> > access latency than RAM. He is trading less memory saving for more
> > consistent run time behavior. The compression ratio is determined by
> > the workload, which lacks consistency from a job scheduling
> > perspective; he does not want a high compression ratio if it causes
> > too many page faults in the worst-case scenario, which would impact
> > serving performance. It is OK to OOM there, because if you have too
> > much swap, your worst-case performance is trashed anyway. In this case
> > the solution is to increase RAM not increase the swap limit.
> >
> > Both requirements can be valid use cases.
>
> Yes, my personal use case is closer to the second one (maximum
> compression), but I'm actually describing both use cases here, and I
> think static sizing interface seems wrong for both.
>
> For the first use case, gating phys mem and gating swap size
> separately is not the same as gating "logical memory footprint". It's
> essentially the equivalent of using memory.max and memory.swap.max to
> simulate memsw. It's not quite accurate tbh. That's is my point. The
> user is only still using 4GB, logically speaking (1GB file and 3GB of
> anon). We're violating that guarantee, because we give the host 2GB of
> memory and 2G of offload capability, which fails to serve 4GB because
> we incorrectly predict the split.
IIRC, Kairui mentioned in the first meeting that he tried emulating
his usecase exactly this way in cgroup2 and it didn't work.
Kairui, please correct me if I misremember.
IMO, the best option is still a transparent virtualization layer at
the bottom. And an optional control plane on top for those who care.
One that actually fits the usecase, doesn't get in the way of those
who do not want it, and composes well with the rest of the kernel.
I know I've said this a few times without offering a concrete
proposal. But I'm also in the camp of people who do not care. I worked
with everyone who thought they had such a case at my company to switch
to psi-based utilization control, and still think this is a better use
of resources. It would be good for those who have that "fixed cloud
capacity" case to lay it out cleanly and help design a solution.
It shouldn't be a vswap blocker. This is as incremental as it gets.
No memsw setup is broken, no zram setup is broken.