From: Nhat Pham <nphamcs@gmail.com>
To: Kairui Song <ryncsn@gmail.com>
Cc: linux-mm@kvack.org, akpm@linux-foundation.org,
hannes@cmpxchg.org, hughd@google.com, yosry.ahmed@linux.dev,
mhocko@kernel.org, roman.gushchin@linux.dev,
shakeel.butt@linux.dev, muchun.song@linux.dev,
len.brown@intel.com, chengming.zhou@linux.dev,
chrisl@kernel.org, huang.ying.caritas@gmail.com,
ryan.roberts@arm.com, viro@zeniv.linux.org.uk,
baohua@kernel.org, osalvador@suse.de,
lorenzo.stoakes@oracle.com, christophe.leroy@csgroup.eu,
pavel@kernel.org, kernel-team@meta.com,
linux-kernel@vger.kernel.org, cgroups@vger.kernel.org,
linux-pm@vger.kernel.org
Subject: Re: [RFC PATCH 00/14] Virtual Swap Space
Date: Tue, 8 Apr 2025 09:47:54 -0700 [thread overview]
Message-ID: <CAKEwX=M5y4yoW62U5GkHTxaDaD7UOJu_sgkkwNXJ5Hn4Gvot9g@mail.gmail.com> (raw)
In-Reply-To: <CAMgjq7CdARdTEZB3ik4X9cAzNUFa6GRqjT61brygihGUYFBAeQ@mail.gmail.com>
On Tue, Apr 8, 2025 at 9:23 AM Kairui Song <ryncsn@gmail.com> wrote:
>
>
> Thanks for sharing the code, my initial idea after the discussion at
> LSFMM is that there is a simple way to combine this with the "swap
> table" [1] design of mine to solve the performance issue of this
> series: just store the pointer of this struct in the swap table. It's
> a bruteforce and glue like solution but the contention issue will be
> gone.
Was waiting for your submission, but I figured I should send what I
had out first for immediate feedback :)
Johannes actually proposed something similar to your physical swap
allocator for the virtual swap slots allocation logic, to solve our
lock contention problem. My apologies - I should have name-dropped you
in the RFC cover as well (the cover was a bit outdated, and I haven't
updated the newest developments that came from the LSFMMBPF
conversation in the cover letter).
>
> Of course it's not a good approach, ideally the data structure can be
> simplified to an entry type in the swap table. The swap table series
> handles locking and synchronizations using either cluster lock
> (reusing swap allocator and existing swap logics) or folio lock (kind
> of like page cache). So many parts can be much simplified, I think it
> will be at most ~32 bytes per page with a virtual device (including
> the intermediate pointers).Will require quite some work though.
>
> The good side with that approach is we will have a much lower memory
> overhead and even better performance. And the virtual space part will
> be optional, for non virtual setup the memory consumption will be only
> 8 bytes per page and also dynamically allocated, as discussed at
> LSFMM.
I think one problem with your design, which I alluded to at the
conference, is that it doesn't quite work for our requirements -
namely the separation of zswap from its underlying backend.
All the metadata HAVE to live at the virtual layer. For once, we are
duplicating the logic if we push this to the backend.
But more than that, there are lifetime operations that HAVE to be
backend-agnostic. For instance, on the swap out path, when we unmap
the page from the page table, we do swap_duplicate() (i.,e increasing
the swap count/reference count of the swap entries). At that point, we
have not (and cannot) make a decision regarding the backend storage
yet, and thus does not have any backend-specific places to hold this
piece of information. If we couple all the backends then yeah sure we
can store it at the physical swapfile level, but that defeats the
purpose of swap virtualization :)
>
> So sorry that I still have a few parts undone, looking forward to
> posting in about one week, eg. After this weekend it goes well. I'll
> also try to check your series first to see how these can be
> collaborated better.
Of course, I'm not against collaboration :) As I mentioned earlier, we
need more work on the allocation part, which your physical swapfile
allocator should either work, or serve as the inspiration for.
Cheers,
Nhat
next prev parent reply other threads:[~2025-04-08 16:48 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-07 23:42 Nhat Pham
2025-04-07 23:42 ` [RFC PATCH 01/14] swapfile: rearrange functions Nhat Pham
2025-04-07 23:42 ` [RFC PATCH 02/14] mm: swap: add an abstract API for locking out swapoff Nhat Pham
2025-04-07 23:42 ` [RFC PATCH 03/14] mm: swap: add a separate type for physical swap slots Nhat Pham
2025-04-08 14:15 ` Johannes Weiner
2025-04-08 15:11 ` Nhat Pham
2025-04-22 14:41 ` Yosry Ahmed
[not found] ` <6807ab09.670a0220.152ca3.502fSMTPIN_ADDED_BROKEN@mx.google.com>
2025-04-22 15:50 ` Nhat Pham
2025-04-22 18:50 ` Kairui Song
2025-04-07 23:42 ` [RFC PATCH 04/14] mm: swap: swap cache support for virtualized swap Nhat Pham
2025-04-08 15:00 ` Johannes Weiner
2025-04-08 15:34 ` Nhat Pham
2025-04-08 15:43 ` Nhat Pham
2025-04-07 23:42 ` [RFC PATCH 05/14] zswap: unify zswap tree " Nhat Pham
2025-04-07 23:42 ` [RFC PATCH 06/14] mm: swap: allocate a virtual swap slot for each swapped out page Nhat Pham
2025-04-07 23:42 ` [RFC PATCH 07/14] swap: implement the swap_cgroup API using virtual swap Nhat Pham
2025-04-07 23:42 ` [RFC PATCH 08/14] swap: manage swap entry lifetime at the virtual swap layer Nhat Pham
2025-04-07 23:42 ` [RFC PATCH 09/14] swap: implement locking out swapoff using virtual swap slot Nhat Pham
2025-04-07 23:42 ` [RFC PATCH 10/14] mm: swap: decouple virtual swap slot from backing store Nhat Pham
2025-04-07 23:42 ` [RFC PATCH 11/14] memcg: swap: only charge physical swap slots Nhat Pham
2025-04-07 23:42 ` [RFC PATCH 12/14] vswap: support THP swapin and batch free_swap_and_cache Nhat Pham
2025-04-07 23:42 ` [RFC PATCH 13/14] swap: simplify swapoff using virtual swap Nhat Pham
2025-04-07 23:42 ` [RFC PATCH 14/14] zswap: do not start zswap shrinker if there is no physical swap slots Nhat Pham
2025-04-08 13:04 ` [RFC PATCH 00/14] Virtual Swap Space Usama Arif
2025-04-08 15:20 ` Nhat Pham
2025-04-08 15:45 ` Johannes Weiner
2025-04-08 16:25 ` Nhat Pham
2025-04-08 16:27 ` Nhat Pham
2025-04-08 16:22 ` Kairui Song
2025-04-08 16:47 ` Nhat Pham [this message]
2025-04-08 16:59 ` Kairui Song
2025-04-22 14:43 ` Yosry Ahmed
2025-04-22 14:56 ` Yosry Ahmed
[not found] ` <6807afd0.a70a0220.2ae8b9.e07cSMTPIN_ADDED_BROKEN@mx.google.com>
2025-04-22 17:15 ` Nhat Pham
2025-04-22 19:29 ` 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='CAKEwX=M5y4yoW62U5GkHTxaDaD7UOJu_sgkkwNXJ5Hn4Gvot9g@mail.gmail.com' \
--to=nphamcs@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=chengming.zhou@linux.dev \
--cc=chrisl@kernel.org \
--cc=christophe.leroy@csgroup.eu \
--cc=hannes@cmpxchg.org \
--cc=huang.ying.caritas@gmail.com \
--cc=hughd@google.com \
--cc=kernel-team@meta.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-pm@vger.kernel.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
--cc=pavel@kernel.org \
--cc=roman.gushchin@linux.dev \
--cc=ryan.roberts@arm.com \
--cc=ryncsn@gmail.com \
--cc=shakeel.butt@linux.dev \
--cc=viro@zeniv.linux.org.uk \
--cc=yosry.ahmed@linux.dev \
/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