Linux Documentation
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: Kairui Song <ryncsn@gmail.com>
Cc: "Chris Li" <chrisl@kernel.org>,
	"David Hildenbrand (Arm)" <david@kernel.org>,
	"Baoquan He" <baoquan.he@linux.dev>,
	"Nhat Pham" <nphamcs@gmail.com>,
	"Michal Hocko" <mhocko@kernel.org>,
	"Roman Gushchin" <roman.gushchin@linux.dev>,
	"Shakeel Butt" <shakeel.butt@linux.dev>,
	"Yosry Ahmed" <yosry@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>,
	"Rik van Riel" <riel@surriel.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>,
	linux-doc@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>
Subject: Re: Path forward for Virtualized Swap?
Date: Wed, 14 Oct 2026 22:24:35 +0200	[thread overview]
Message-ID: <20261014202435.GB371161@cmpxchg.org> (raw)
In-Reply-To: <CAMgjq7D_=_4ZsCWJYywpZhPtg+YeH8o=ymRrV3sQ_58G6rs0sg@mail.gmail.com>

Suren, if you've not been following this, there is a question you
might be best equipped to answer below.

On Thu, Oct 15, 2026 at 01:17:21AM +0800, Kairui Song wrote:
> On Tue, Oct 13, 2026 at 1:27 PM Chris Li <chrisl@kernel.org> wrote:
> > I understand that you have some face-to-face discussions at the
> > conference. Do we have a list of what has been aligned and what is
> > pending to discuss? We should have an agenda to avoid repeating
> > already aligned items.
> 
> Right, from my perspective, here are the following key points we can
> discuss further in the incoming meeting (most of them are not fully
> concluded yet):
> 
> 1. A limitation for the logical size: from my side, there are real
> usages for a global non-memcg limitation of the non-physical swap
> space: e.g. thin VMs as containers/pods with no cgroup limitations
> inside but which need in-VM memory compression and a proper limitation
> to avoid thrashing; or low-end devices/desktops that want global
> (root) limitations. And also, Android have a limitation on the ZRAM
> size (well for this one I'm not from Android team though so that's
> just my personal development experience with Android, enlarging the
> ZRAM size on several Phone swill cause serious junky of Apps due to
> over compression).

Android monitors psi to kill on excessive pressure. This should
capture thrashing from over compression.

Suren is CC'd, we should get his opinion.

> Nhat is concerned that exposing the sizing allows users to tune it and
> potentially misconfigure the system. However, I think a user with root
> permission should be fully aware of what they are doing or they can
> easily mess up the system in many ways and swap limitation is a very
> minor concern to me.
> 
> I think the requirement for a logical non-cgroup limitation is strong,
> but the discussion hasn't concluded on the implementation method.
> Perhaps something like a Kconfig combined with an interface or command
> line? More ideas are welcome.

I agree that overcommit control can be useful. But there are setups
that implement pressure-based policies and do utilization monitoring
just fine from userspace; they have no need for logical overcommit
bounds inside the kernel itself. *Defaulting* to a static limit and/or
making a choice mandatory seems like a mistake to me. It would make
more sense to treat this as a related but separate problem.

I'm happy to brainstorm solutions. But we should be open to discussing
this from scratch - userspace monitoring; an extension of
/proc/sys/vm/overcommit_* etc.

> 2. Charging: If you consider memory.swap is physical only then indeed
> we should not charge it, however, user are already doing that for
> years so this is a behavior change and we are also pushing memsw into
> memcgv2 as a interface to limit the logical memory usage of a
> container. So charging of the logical space is useful, how to handle
> that is tricky though.
> 
> From our usage, this should at least not block adding memsw or
> anything similar for memcgv2, even if you want more customized cgroup
> accounting, we need to charge it into some counter (a page counter,
> not just a statistic) in some way.

A path for memsw in cgroup2 is generally unlikely, actually. It was
intentionally split into separate memory and swap counters and not
forward-ported as a combined control.

Like I said, we should discuss overcommit control from scratch as an
orthogonal issue. I'm happy to do this and help find a solution. But I
want to get out of repeating that this is not compatible with cgroup2.

> 3. Swapoff: This was discussed again too, as vswap was trying to
> remove it. I think the concern is mostly about maintenance,
> performance, and practicality. From my perspective it's a critical
> component both for preventing minor or major faults before predictable
> high traffic arrives, or for operations/debugging, and for releasing
> the swap metadata to rule out any potential swap / page fault effect.
> There are concerns about maintenance or suggestions to use MADV, while
> I'll be happy to explore and improve the current in-kernel
> implementation of swapoff later if needed but removing it is a really
> bad idea in my view.

Here too I think we should be open about discussing the problem and
what a solution could look like.

"Swapoff" seems to presume the virtual space in the shape of a
manageable swapfile through standard interfaces.

A separate knob to clear out the vswap space would accomplish the same
functionality without pulling in the entire swapfile interface e.g.

> 4. Writeback: No doubt we all agree that we definitely should have
> writeback support, Nhat's concern is that we should handle the case
> where some cgroup doesn't need zswap/compression and ensure that works
> well.

+1

> 5. Interface: Given the issues above, what should the interface look
> like (swapfile, sysfs, /proc, etc.) and how should multiple
> (non-physical) swapfiles be used? Nothing much is discussed about this
> part though. I've heard users mention the use case of multiple
> compression swap spaces, but I don't have a use case for that myself,
> so I don't have many comments.

+1

It would be good to collect usecases first. Interfaces are forever and
we shouldn't add them on speculation.

> 6. The one part that I think we can and should agree on it shat the
> implement approach: at this point I think VM_SPARSE is the right
> direction, Nhat is concerned about the testing on it, and I think we
> can have more data for that, and collabration is highly encouraged. I
> previously conducted many tests on everything posted from both sides,
> will try to post more on this too.

Here I think we're actually least aligned.

The VM_SPARSE implementation requires a static size, and prior
discussion has made it clear that we actually have no consensus on how
to pick reasonable values - be it in the kernel or in userspace.

The xarray proposal requires none of these choices or interfaces, and
nobody has been able to show that it's actually a performance concern.

  parent reply	other threads:[~2026-10-14 20:24 UTC|newest]

Thread overview: 151+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04 21:14 Path forward for Virtualized Swap? 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-25 18:47                         ` Shakeel Butt
2026-10-05 11:06                   ` David Hildenbrand (Arm)
2026-10-07 16:47                     ` Nhat Pham
2026-10-07 16:54                       ` Yosry Ahmed
2026-10-09 17:40                     ` Shakeel Butt
2026-10-13  5:26                     ` Chris Li
2026-10-14 17:17                       ` Kairui Song
2026-10-14 18:46                         ` David Hildenbrand (Arm)
2026-10-14 19:11                         ` Nhat Pham
2026-10-14 20:24                         ` Johannes Weiner [this message]
2026-10-13 16:58                     ` Kairui Song
2026-10-13 17:01                       ` Nhat Pham
2026-10-14  1:30                     ` Baoquan He
2026-10-14 19:53                     ` Johannes Weiner
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-24 11:27                             ` Chris Li
2026-09-24 13:15                               ` Shakeel Butt
2026-09-25 13:15                           ` Kairui Song
2026-09-25 15:41                             ` Johannes Weiner
2026-09-25 19:21                               ` Kairui Song
2026-09-25 20:20                                 ` Johannes Weiner
2026-09-26 21:27                               ` Chris Li
2026-09-27  0:58                                 ` Rik van Riel
2026-09-27  6:23                                   ` Chris Li
2026-09-27 12:29                                     ` Rik van Riel
2026-09-27 16:17                                       ` Chris Li
2026-09-27 18:12                                         ` Rik van Riel
2026-09-27 23:50                                           ` Chris Li
2026-09-25 16:11                             ` Gregory Price
2026-09-25 20:44                               ` Kairui Song
2026-09-25 21:30                                 ` Gregory Price
2026-09-25 21:53                                   ` Johannes Weiner
2026-09-25 16:54                             ` Nhat Pham
2026-09-25 20:26                               ` Kairui Song
2026-09-28 12:38                                 ` Nhat Pham
2026-09-25 19:36                             ` Shakeel Butt
2026-09-25 20:20                               ` Kairui Song
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
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-24  5:51                                     ` Baoquan He
2026-09-24  7:20                                       ` Klara Modin
2026-09-24  7:53                                         ` Baoquan He
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-24 11:02                     ` Chris Li
2026-09-24 14:18                       ` 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=20261014202435.GB371161@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-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