Re: Virtual Swap Sync
From: Chris Li
Date: Wed Dec 02 2026 - 00:27:48 EST
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.
> offload 2GB of anon, and compressed anon + 1GB of uncompressed anon +
> 1GB of file cache does not fit in that 2GB limit. If we can just
> compressed a bit more all would be good, but this requires knowing
> apriori compression ratio to properly set this limit right.
>
> It also limits the offloading potential of the system. On a system
Yes, that is the desired behavior for him because you two have
different constraints.
> that relies on proactive guest-side reclaim to overcommit VMs, we
> could have offloaded 3GB, but instead had to stop at 2. This adds up.
>
> Unironically host-wide memsw is correct semantics here: physical
> memory usage + anon offloaded ("swap"), but irregardless of split. I
> think this calls for a new interface. If we're going to design
> interfaces, why not go for the right one?
I see different usage requirements; there is no right or wrong there.
> >
> > I really want to know more about the Android case here too, does
> > Android set a limited zram size for a similar reason?
>
> Zram just presents itself like a physical swapfile, so I don't think
> there's even an option to make it unlimited?
It is just an example, the goal is to discuss the desired behavior he
wants from the swap system. He does not want it unlimited. You do,
that is a different requirement.
Chris