Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: Nhat Pham <nphamcs@gmail.com>
Cc: "Chris Li" <chrisl@kernel.org>, "Kairui Song" <ryncsn@gmail.com>,
	"David Hildenbrand (Arm)" <david@kernel.org>,
	"Baoquan He" <baoquan.he@linux.dev>,
	"Michal Hocko" <mhocko@kernel.org>,
	"Roman Gushchin" <roman.gushchin@linux.dev>,
	"Shakeel Butt" <shakeel.butt@linux.dev>,
	"Muchun Song" <muchun.song@linux.dev>,
	"Kemeng Shi" <shikemeng@huaweicloud.com>,
	"Barry Song" <baohua@kernel.org>,
	"YoungJun Park" <youngjun.park@lge.com>,
	"Chengming Zhou" <chengming.zhou@linux.dev>,
	"Lorenzo Stoakes (Oracle)" <ljs@kernel.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	"Vlastimil Babka (SUSE)" <vbabka@kernel.org>,
	"Mike Rapoport" <rppt@kernel.org>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Qi Zheng" <qi.zheng@linux.dev>,
	"Axel Rasmussen" <axelrasmussen@google.com>,
	"Yuanchu Xie" <yuanchu@google.com>,
	"Gregory Price" <gourry@gourry.net>,
	"Wenchao Hao" <haowenchao22@gmail.com>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Hugh Dickins" <hughd@google.com>,
	"Baolin Wang" <baolin.wang@linux.alibaba.com>,
	"Tejun Heo" <tj@kernel.org>, "Michal Koutný" <mkoutny@suse.com>,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	"Kunwu Chan" <kunwu.chan@linux.dev>,
	"Meta kernel team" <kernel-team@meta.com>,
	"Linux Memory Management List" <linux-mm@kvack.org>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"open list:CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG)"
	<cgroups@vger.kernel.org>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Joshua Hahn" <joshua.hahnjy@gmail.com>,
	"Rik van Riel" <riel@surriel.com>, "Wei Xu" <weixugc@google.com>,
	"Yosry Ahmed" <yosry@kernel.org>
Subject: Re: Virtual Swap Sync
Date: Fri, 4 Dec 2026 14:44:13 -0500	[thread overview]
Message-ID: <axMYDd1BrX41s_H1@cmpxchg.org> (raw)
In-Reply-To: <CAKEwX=MsPkczkkU8HsbOOCC-Ntf5k2wea+u51cgdnpGy4vD-uA@mail.gmail.com>

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@kernel.org> wrote:
> >
> > On Mon, Nov 30, 2026 at 4:26 AM Nhat Pham <nphamcs@gmail.com> 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.


  reply	other threads:[~2026-12-04 19:44 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05 21:06 Virtual Swap Sync Nhat Pham
2026-11-06 12:55 ` David Hildenbrand (Arm)
2026-11-22 15:31 ` Nhat Pham
2026-11-26  6:03   ` Baoquan He
2026-11-26 17:30     ` Nhat Pham
2026-11-29 17:25       ` Kairui Song
2026-11-29 22:12         ` Chris Li
2026-12-03  0:47           ` Chris Li
2026-12-04 18:58             ` Nhat Pham
2026-11-29 16:40   ` Kairui Song
2026-11-30  2:40     ` Rik van Riel
2026-11-30 12:26     ` Nhat Pham
2026-11-30 12:34       ` Nhat Pham
2026-12-02  5:27       ` Chris Li
2026-12-04 18:30         ` Nhat Pham
2026-12-04 19:44           ` Johannes Weiner [this message]
2026-12-04 20:31             ` Rik van Riel
2026-12-03 22:12   ` Nhat Pham

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=axMYDd1BrX41s_H1@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=baoquan.he@linux.dev \
    --cc=cgroups@vger.kernel.org \
    --cc=chengming.zhou@linux.dev \
    --cc=chrisl@kernel.org \
    --cc=corbet@lwn.net \
    --cc=david@kernel.org \
    --cc=gourry@gourry.net \
    --cc=haowenchao22@gmail.com \
    --cc=hughd@google.com \
    --cc=joshua.hahnjy@gmail.com \
    --cc=kernel-team@meta.com \
    --cc=kunwu.chan@linux.dev \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@kernel.org \
    --cc=mkoutny@suse.com \
    --cc=muchun.song@linux.dev \
    --cc=nphamcs@gmail.com \
    --cc=qi.zheng@linux.dev \
    --cc=riel@surriel.com \
    --cc=roman.gushchin@linux.dev \
    --cc=rppt@kernel.org \
    --cc=ryncsn@gmail.com \
    --cc=shakeel.butt@linux.dev \
    --cc=shikemeng@huaweicloud.com \
    --cc=skhan@linuxfoundation.org \
    --cc=surenb@google.com \
    --cc=tj@kernel.org \
    --cc=vbabka@kernel.org \
    --cc=weixugc@google.com \
    --cc=yosry@kernel.org \
    --cc=youngjun.park@lge.com \
    --cc=yuanchu@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox