|
[an error occurred while processing this directive]
|
|
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACePvbUB8wjEH1rsaRs+LwX4RKGrjLFSGzjhgrdS3e7Lcz6BeQ@mail.gmail.com>
Date: Tue, 25 Nov 2025 22:50:02 +0400
From: Chris Li <chrisl@...nel.org>
To: Yosry Ahmed <yosry.ahmed@...ux.dev>
Cc: Johannes Weiner <hannes@...xchg.org>, Andrew Morton <akpm@...ux-foundation.org>,
Kairui Song <kasong@...cent.com>, Kemeng Shi <shikemeng@...weicloud.com>,
Nhat Pham <nphamcs@...il.com>, Baoquan He <bhe@...hat.com>, Barry Song <baohua@...nel.org>,
Chengming Zhou <chengming.zhou@...ux.dev>, linux-mm@...ck.org,
Rik van Riel <riel@...riel.com>, linux-kernel@...r.kernel.org, pratmal@...gle.com,
sweettea@...gle.com, gthelen@...gle.com, weixugc@...gle.com
Subject: Re: [PATCH RFC] mm: ghost swapfile support for zswap
On Mon, Nov 24, 2025 at 11:32 PM Yosry Ahmed <yosry.ahmed@...ux.dev> wrote:
>
> I think what Chris's idea is (and Chris correct me if I am wrong), is
> that we use ghost swapfiles (that are not backed by disk space) for
> zswap. So zswap has its own swapfiles, separate from disk swapfiles.
Ack.
> memory.tiers establishes the ordering between swapfiles, so you put
> "ghost" -> "real" to get today's zswap writeback behavior. When you
> writeback, you keep page tables pointing at the swap entry in the ghost
> swapfile. What you do is:
> - Allocate a new swap entry in the "real" swapfile.
> - Update the swap table of the "ghost" swapfile to point at the swap
> entry in the "real" swapfile, reusing the pointer used for the
> swapcache.
Ack, with minor adjustment in mapping the swap entry to the physical
location. The swap entry has swap cache, the physical location does
not.
> Then, on swapin, you read the swap table of the "ghost" swapfile, find
> the redirection, and read to the swap table of the "real" swapfile, then
> read the page from disk into the swap cache. The redirection in the
> "ghost" swapfile will keep existing, wasting that slot, until all
> references to it are dropped.
Ack. That is assuming we don't have a rmap a like for the swap entry.
> I think this might work for this specific use case, with less overhead
> than the xarray. BUT there are a few scenarios that are not covered
> AFAICT:
>
> - You still need to statically size the ghost swapfiles and their
> overheads.
No true, both ghost swapfile and physical swapfile can expand
additional clusters beyond the original physical size, for allocating
the continued high order entry or redirection. For a ghost swapfile,
there is no physical layer, only the front end. So the size can grow
dynamically. Just allocate more clusters. The current swapfile header
file size is just an initial size. My current patch does not implement
that. It will need some later swap table phase to make it happen. But
that is not an architecture limit, it has been considered as part of
normal business.
> - Wasting a slot in the ghost swapfile for the redirection. This
> complicates static provisioning a bit, because you have to account for
> entries that will be in zswap as well as writtenback. Furthermore,
> IIUC swap.tiers is intended to be generic and cover other use cases
> beyond zswap like SSD -> HDD. For that, I think wasting a slot in the
> SSD when we writeback to the HDD is a much bigger problem.
Yes and No. Yes it only wastes a front end swap entry (with swap
cache). The physical location is a seperate layer. No, the physical
SSD space is not wasted because you can allocate additional front end
swap entry by growing the swap entry front end. Then have the
additional front end swap entry point to the physical location you
just directed away from. There is a lot more consideration of the
front end vs the physical layer. The physical layer does not care
about location order size 2^N alignment. The physical layer cares a
bit about continuity and the number of IOV that it needs to issue.
The swap entry front end and the physical layer have slightly
different constraints.
> - We still cannot do swapoff efficiently as we need to walk the page
> tables (and some swap tables) to find and swapin all entries in a
> swapfile. Not as important as other things, but worth mentioning.
That need rmap for swap entries. It It is an independent issue.
Chris
Powered by blists - more mailing lists