From: Rik van Riel <riel@surriel.com>
To: Chris Li <chrisl@kernel.org>
Cc: Nhat Pham <nphamcs@gmail.com>,
akpm@linux-foundation.org, kasong@tencent.com,
hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev,
shakeel.butt@linux.dev, yosry@kernel.org, david@kernel.org,
muchun.song@linux.dev, shikemeng@huaweicloud.com,
baoquan.he@linux.dev, baohua@kernel.org, youngjun.park@lge.com,
chengming.zhou@linux.dev, ljs@kernel.org, liam@infradead.org,
vbabka@kernel.org, rppt@kernel.org, surenb@google.com,
qi.zheng@linux.dev, axelrasmussen@google.com,
yuanchu@google.com, weixugc@google.com, gourry@gourry.net,
haowenchao22@gmail.com, corbet@lwn.net, hughd@google.com,
baolin.wang@linux.alibaba.com, tj@kernel.org, mkoutny@suse.com,
skhan@linuxfoundation.org, kunwu.chan@linux.dev,
kernel-team@meta.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
cgroups@vger.kernel.org
Subject: Re: [PATCH v5 01/11] mm, swap: add virtual swap device infrastructure
Date: Thu, 24 Sep 2026 21:23:46 -0400 [thread overview]
Message-ID: <a30eb60221cda2fe726a86c2c6f859f71fc7a46d.camel@surriel.com> (raw)
In-Reply-To: <CACePvbV-tazW=LmsbUtAhHzR2d6JwFT5R1jYZ9_NTp1hxXH=bw@mail.gmail.com>
On Thu, 2026-09-24 at 15:17 -1000, Chris Li wrote:
> On Thu, Sep 24, 2026 at 8:13 AM Rik van Riel <riel@surriel.com>
> wrote:
> >
> > On Tue, 2026-09-22 at 23:18 -1000, Chris Li wrote:
> > > On Fri, Sep 18, 2026 at 1:03 PM Nhat Pham <nphamcs@gmail.com>
> > > wrote:
> > > >
> > > >
> > > > @@ -482,6 +491,11 @@ void swap_read_folio(struct swap_io_ctx
> > > > *ctx,
> > > > struct folio *folio)
> > > > if (zswap_load(folio) != -ENOENT)
> > > > goto finish;
> > > >
> > > > + if (unlikely(swap_is_vswap(sis))) {
> > >
> > > There are too many swap_is_vswap() in this series. It fragments
> > > the
> > > code path, making things harder to reason about. Esepcially
> > > around
> > > locks. I count 22 in this patch alone.
> > >
> > > I consider this the biggest drawback of this series. This
> > > fragmentation of the code path.
> >
> > Could we avoid that by simply always having everything
> > go through the vswap abstraction layer?
>
> Yes, but it will pay the price for going through the unnecessary
> redirection layer always. It incurs performance and meta data
> overhead. That was one of my previous objections to the earlier vswap
> version. Sorry I enjoy micro optimization too much, that is both my
> strength and weakness.
We really only have two cases here, don't we?
Either the data is in the swap cache, and
the vswap layer can directly look up the
swap cache page.
Or the data is in some slower back-end,
and doing a second lookup is not going to
introduce noticeable overhead.
If the micro optimization come at the cost
of less flexibility, and harder to maintain
code, are they really worth it?
>
> > Handling the details of what's behind the vswap would
> > be handled one layer down.
> >
> > Chris, do you think that would be cleaner?
>
> If it can wrap below the swap_ops, it is just priviate inernal dedail
> of implementing its own indirections. That would be much cleaner.
> That
> is what I am trying to pitch to Nhat in prevoius email but does not
> have following actions.
>
Can you sketch out the details of what you
think that should look like?
What would the data structures look like?
What operations should there be at the
abstraction layer, and at the swap layers
below?
How should migration of data from one swap
backend to another be handled?
At this point the best way to make progress
would be to hash out those details.
If you are unhappy with what you have seen
from others, what does your ideal design
look like?
--
All Rights Reversed.
next prev parent reply other threads:[~2026-09-25 1:24 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 18:02 [PATCH v5 00/11] Virtual Swap Space (Swap Table Edition) Nhat Pham
2026-09-18 18:02 ` [PATCH v5 01/11] mm, swap: add virtual swap device infrastructure Nhat Pham
2026-09-23 9:18 ` Chris Li
2026-09-24 16:20 ` Nhat Pham
2026-09-25 0:43 ` Chris Li
2026-09-25 1:14 ` Rik van Riel
2026-09-25 1:20 ` Chris Li
2026-09-24 18:12 ` Rik van Riel
2026-09-25 1:17 ` Chris Li
2026-09-25 1:23 ` Rik van Riel [this message]
2026-09-18 18:02 ` [PATCH v5 02/11] mm, swap: support zswap and zero-filled swap pages as vswap backends Nhat Pham
2026-09-18 18:02 ` [PATCH v5 03/11] mm, swap: prepare the swap IO path for vswap Nhat Pham
2026-09-18 18:02 ` [PATCH v5 04/11] mm, swap: support physical swap as a vswap backend Nhat Pham
2026-09-18 18:02 ` [PATCH v5 05/11] mm, swap: enable THP swapin for vswap entries Nhat Pham
2026-09-18 18:02 ` [PATCH v5 06/11] mm, swap: write back vswap zswap entries to physical swap Nhat Pham
2026-09-18 18:02 ` [PATCH v5 07/11] mm, swap: reclaim physical slots backing cache-only vswap entries Nhat Pham
2026-09-18 18:02 ` [PATCH v5 08/11] mm, swap: only charge physical swap entries Nhat Pham
2026-09-18 18:02 ` [PATCH v5 09/11] mm, swap: add debugfs counters for vswap Nhat Pham
2026-09-18 18:02 ` [PATCH v5 10/11] mm, swap: defer memcg_table allocation for physical swap clusters Nhat Pham
2026-09-18 18:02 ` [RFC PATCH v5 11/11] mm, swap: back vswap clusters with a VM_SPARSE array Nhat Pham
2026-09-18 18:38 ` [PATCH v5 00/11] Virtual Swap Space (Swap Table Edition) Nhat Pham
2026-09-21 13:42 ` [syzbot ci] " syzbot ci
2026-09-21 19:00 ` Nhat Pham
2026-09-24 12:54 ` [PATCH v5 00/11] " Klara Modin
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=a30eb60221cda2fe726a86c2c6f859f71fc7a46d.camel@surriel.com \
--to=riel@surriel.com \
--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=hannes@cmpxchg.org \
--cc=haowenchao22@gmail.com \
--cc=hughd@google.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=roman.gushchin@linux.dev \
--cc=rppt@kernel.org \
--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®