From: Johannes Weiner <hannes@cmpxchg.org>
To: Chris Li <chrisl@kernel.org>
Cc: "Rik van Riel" <riel@surriel.com>,
"Gregory Price" <gourry@gourry.net>,
"Baoquan He" <baoquan.he@linux.dev>,
"Nhat Pham" <nphamcs@gmail.com>,
"Kairui Song" <kasong@tencent.com>,
"Michal Hocko" <mhocko@kernel.org>,
"Roman Gushchin" <roman.gushchin@linux.dev>,
"Shakeel Butt" <shakeel.butt@linux.dev>,
"Yosry Ahmed" <yosry@kernel.org>,
"David Hildenbrand" <david@kernel.org>,
"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>, "Wei Xu" <weixugc@google.com>,
"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>,
linux-doc@vger.kernel.org,
"open list:CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG)"
<cgroups@vger.kernel.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Kairui Song" <ryncsn@gmail.com>,
"Joshua Hahn" <joshua.hahnjy@gmail.com>
Subject: Re: Path forward for Virtualized Swap?
Date: Wed, 23 Sep 2026 09:55:54 -0400 [thread overview]
Message-ID: <arPaalt234UG2qHV@cmpxchg.org> (raw)
In-Reply-To: <CACePvbW9=HTg69J1JTAUROZui4vD00g4=xbFk8QfL5Xdrg6pAQ@mail.gmail.com>
On Tue, Sep 22, 2026 at 09:32:17PM -1000, Chris Li wrote:
> On Tue, Sep 22, 2026 at 7:31 AM Johannes Weiner <hannes@cmpxchg.org> wrote:
> >
> > On Tue, Sep 22, 2026 at 01:14:31PM -0400, Rik van Riel wrote:
> > > On Mon, 2026-09-21 at 06:11 -1000, Chris Li wrote:
> > > > On Mon, Sep 21, 2026 at 2:53 AM Gregory Price <gourry@gourry.net>
> > > > > That should tell you that your model of reasoning about this issue
> > > > > is
> > > > > ill-suited to address the problem.
> > > >
> > > > That is what I'm suspecting. Nobody in a sane mind would want to
> > > > zswap
> > > > 100% of the RAM and maintain reasonable SLO.
> > > >
> > > It could make a lot of sense to have some default
> > > limit upstream, that says the zswap pool is not
> > > allowed to take more than half of memory, because
> > > at that point the compressed content will be
> > > crowding other things out of memory.
> > >
> > > That seems like the kind of limit that is large
> > > enough that very few people will run into it,
> > > while also being small enough to prevent actual
> > > corner case trouble.
> >
> > Just to be sure we're all on the same page:
> >
> > Zswap *backing memory*, the space needed for compressed data, is not
> > the problem. It actually has a limit that defaults to 20% of
> > memory. And there is memory.zswap.max for users to define everybody's
> > fair share of that limited backing storage.
>
> Just curious, how is the 20% determined?
If you look at the git tree, you'll find it came in with the original
commit that introduced zswap. There was no explanation.
> May I apply the same argument used in this thread: since you haven't
> surveyed all users in the world so you can't determine that 20% is a
> good value. Let's make that 200% for safety.
Yes, thank you:
" the practical usecase for limiting zswap memory to begin with is
quite unclear to me. Zswap is not a limited resource. It's just
memory. And you already had the memory for the uncompressed copy. So
it's a bit strange to me to say "you have compressed your memory
enough, so now you get sent to disk (or we declare OOM)". What would
be a reason to limit it? "
- https://lore.kernel.org/linux-mm/20240925192006.GB876370@cmpxchg.org/
This is my whole point. Swap/compression is a low level layer in the
reclaim stack. You're asking it to make a page smaller and it does it.
- It's *reclaim* that determines who and how much gets swapped.
- Cgroups provide configurable memory.low and memory.min residency
enforcement based on volume.
- MGLRU has the min_ttl setting to configure residency based on
hotness.
- Many real world environments use some form of pressure-based OOM
killing to determine when too many pages have become non-resident
and the workload meets some subjective threshold of "suffering".
There is a whole stack of clever algorithms and configurable QoL
policies that make judgements about residency.
The compression layer has one job: compress the pages I feed you. It's
purely mechanical. It does not need an opinion on which pages are hot,
how much compression is "too much". It's a glaring layering violation.
The reason we keep talking past each other is that you think I'm
arguing for a larger limit. I am not. I'm saying the mechanical
compression layer has no business editorializing what the policy
layers above it have determined.
> > The point of conflict is the pre-compressed side. How many swap
> > entries can vswap hand out. Hard limiting this is the point of
> > conflict. Any given swap entry can refer to several things: a page
> > full of zeroes that has no backing space; a compressed page in zswap
> > that consumes some amount of backing space; a page that was written
> > back from zswap and now consumes physical swapfile space.
> >
> > All mapped by the same address space.
> >
> > I don't see why you would limit this at all. I don't see how you would
> > pick a sane default. And if you limit it and workloads run into it,
> > there are no cgroup controls to manage fair access.
>
> I am not using a limit to enforce the workload. I am just using the
> limit with a safe margin to set the vmalloc max size for xswap.
And this would carry a lot of weight if we HAD to go with vmalloc.
But there is an alternative proposal based on xarray that does not
have that limitation at all. Neither Nhat nor Boaquan seem to have
been able to find any performance issues with it.
It's YOUR claim that we need to go the vmalloc route. That means it's
YOUR burden to (1) propse an implementation limit that everybody
agrees is safe and (2) why the usability risk of having a limited
implementation is even justified (e.g. performance numbers).
You clearly haven't done either.
> This is similar to the 20% for the compressed pool. I do believe the
> app will suffer if too much of its memory is swapped out. e.g. 100%
> of system RAM.
>
> > (Despite what has been said in this thread, memory.swap.max is for
> > those entries that compete over physical swapfile space. It must not
> > and can not control vswap space used for all sorts of backends.)
>
> Doesn't memory.swap.max limit existing zswap? Then that is a
> user-visible behavior change to make zswap don't go through the swap
> counter. That is a change we need to avoid.
No. This has been explained to you repeatedly.
It's for managing fair access to a physical swapfile space because
that's a constrained resource.
After vswap, zswap does not use physical swapfile space anymore. But
other things will, and it's important it keeps working for them.
This "user-visible behavior change" is the whole dang point.
And it's opt-in, so nobody "breaks" through kernel upgrades.
I'm sorry if your setup is abusing this knob for enforcing some sort
of residency. This isn't what it was designed for, and it is clearly
not a generalizable model - most workloads have page cache.
You're in fact asking for it to STOP being usable for managing
physical swapfile space. You're asking to break the broader container
and memory management model as designed so you can continue supporting
what is essentially a case of creative abuse.
This is unreasonable.
next prev parent reply other threads:[~2026-09-23 13:56 UTC|newest]
Thread overview: 110+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 21:14 Nhat Pham
2026-09-07 5:51 ` Kairui Song
2026-09-08 16:36 ` Nhat Pham
2026-09-11 16:09 ` Kairui Song
2026-09-11 16:57 ` Nhat Pham
2026-09-11 18:14 ` Kairui Song
2026-09-11 19:03 ` Nhat Pham
2026-09-12 8:47 ` Kairui Song
2026-09-14 16:49 ` Nhat Pham
2026-09-08 18:30 ` Johannes Weiner
2026-09-09 16:41 ` Nhat Pham
2026-09-09 17:47 ` Nhat Pham
2026-09-12 9:00 ` Kairui Song
2026-09-12 11:51 ` Johannes Weiner
2026-09-19 7:23 ` Chris Li
2026-09-20 1:06 ` Rik van Riel
2026-09-21 0:18 ` Chris Li
2026-09-21 0:35 ` Rik van Riel
2026-09-21 0:53 ` Chris Li
2026-09-14 16:10 ` Nhat Pham
2026-09-10 23:27 ` Nhat Pham
2026-09-07 11:30 ` David Hildenbrand (Arm)
2026-09-08 16:45 ` Nhat Pham
2026-09-10 10:56 ` David Hildenbrand (Arm)
2026-09-10 16:22 ` Nhat Pham
2026-09-10 17:57 ` David Hildenbrand (Arm)
2026-09-11 16:20 ` Kairui Song
2026-09-11 16:56 ` David Hildenbrand (Arm)
2026-09-14 15:00 ` Baoquan He
2026-09-19 6:50 ` Chris Li
2026-09-21 18:55 ` Nhat Pham
2026-09-22 13:38 ` Chris Li
2026-09-22 14:43 ` Shakeel Butt
2026-09-22 14:56 ` Chris Li
2026-09-22 15:07 ` Johannes Weiner
2026-09-22 15:30 ` Chris Li
2026-09-22 15:45 ` Shakeel Butt
2026-09-23 6:44 ` Chris Li
2026-09-22 15:46 ` Johannes Weiner
2026-09-22 15:28 ` Baoquan He
2026-09-10 7:09 ` Baoquan He
2026-09-10 16:39 ` Shakeel Butt
2026-09-11 13:06 ` Baoquan He
2026-09-11 16:45 ` Shakeel Butt
2026-09-15 5:48 ` Baoquan He
2026-09-15 6:44 ` Baoquan He
2026-09-19 6:55 ` Chris Li
2026-09-19 16:15 ` Rik van Riel
2026-09-19 21:21 ` Chris Li
2026-09-19 22:50 ` Rik van Riel
2026-09-21 0:13 ` Chris Li
2026-09-22 17:54 ` Nhat Pham
2026-09-23 7:44 ` Chris Li
2026-09-23 16:30 ` Shakeel Butt
2026-09-19 7:07 ` Chris Li
2026-09-10 17:03 ` Johannes Weiner
2026-09-11 12:27 ` Baoquan He
2026-09-11 16:21 ` Johannes Weiner
2026-09-19 8:45 ` Chris Li
2026-09-19 16:08 ` Gregory Price
2026-09-19 19:02 ` Chris Li
2026-09-20 1:14 ` Rik van Riel
2026-09-20 1:53 ` Gregory Price
2026-09-21 9:43 ` Chris Li
2026-09-21 12:53 ` Gregory Price
2026-09-21 16:11 ` Chris Li
2026-09-22 17:14 ` Rik van Riel
2026-09-22 17:21 ` Nhat Pham
2026-09-23 7:20 ` Chris Li
2026-09-22 17:31 ` Johannes Weiner
2026-09-23 7:32 ` Chris Li
2026-09-23 13:55 ` Johannes Weiner [this message]
2026-09-21 14:06 ` Rik van Riel
2026-09-21 16:15 ` Chris Li
2026-09-21 15:16 ` Rik van Riel
2026-09-21 16:31 ` Chris Li
2026-09-21 16:36 ` Rik van Riel
2026-09-21 18:10 ` Chris Li
2026-09-21 18:52 ` Rik van Riel
2026-09-22 13:32 ` Chris Li
2026-09-22 14:59 ` Rik van Riel
2026-09-22 15:23 ` Chris Li
2026-09-22 15:43 ` Johannes Weiner
2026-09-23 6:10 ` Chris Li
2026-09-22 15:48 ` Rik van Riel
2026-09-23 7:00 ` Chris Li
2026-09-23 14:21 ` Rik van Riel
2026-09-22 17:32 ` Nhat Pham
2026-09-23 7:37 ` Chris Li
2026-09-23 14:11 ` Johannes Weiner
2026-09-23 15:39 ` Nhat Pham
2026-09-22 15:20 ` Gregory Price
2026-09-22 15:43 ` Chris Li
2026-09-22 15:52 ` Rik van Riel
2026-09-23 7:10 ` Chris Li
2026-09-23 12:52 ` Klara Modin
2026-09-23 15:43 ` Nhat Pham
2026-09-23 17:26 ` Klara Modin
2026-09-21 10:01 ` Kairui Song
2026-09-21 13:27 ` Gregory Price
2026-09-21 15:27 ` Rik van Riel
2026-09-21 15:48 ` Gregory Price
2026-09-21 16:32 ` Chris Li
2026-09-21 17:02 ` Gregory Price
2026-09-23 9:39 ` Baoquan He
2026-09-23 12:11 ` Gregory Price
2026-09-23 14:34 ` Kairui Song
2026-09-21 18:11 ` Nhat Pham
2026-09-22 17:16 ` Johannes Weiner
2026-09-10 17:16 ` 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=arPaalt234UG2qHV@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=kasong@tencent.com \
--cc=kernel-team@meta.com \
--cc=kunwu.chan@linux.dev \
--cc=liam@infradead.org \
--cc=linux-doc@vger.kernel.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
all inboxes | Powered by JetHome®