Re: [PATCH v5 0/3] mm: fix workingset refaults in the zswap writeback path

From: Yosry Ahmed

Date: Thu Dec 03 2026 - 12:01:03 EST


On Thu, Dec 3, 2026 at 8:58 AM Chris Li <chrisl@xxxxxxxxxx> wrote:
>
> On Thu, Dec 3, 2026 at 8:25 AM Yosry Ahmed <yosry@xxxxxxxxxx> wrote:
> >
> > > > Thanks for checking and raising the swapoff case, that is a good
> > > > point. I am thinking zswap writeback can just add a reference count to
> > > > the swap entry for the writeback and release it when done. That
> > > > ensures the swap entry will not be freed during writeback. Then most
> > > > of the races you mention for swap entry shouldn't need special
> > > > handling. Swap off is different, draining the page table is not going
> > > > to free those swap count own by the write back. Because swapoff is
> > > > very slow and writeback is very fast in comparison. Mark the swap
> > > > device as not in use then wait for outstanding writes to complete
> > > > before trying to unmap the swap entry, we should be good? Can you
> > > > check on that?
> > >
> > > I prototyped your approach with my favourite llm to see what it takes,
> > > and three things stand out:
> > >
> > > - the zswap entry has to stay until the write completes, so every
> > > writeback now holds both the compressed and the decompressed data at
> > > the same time. Since writeback is called under memory pressure, this
> > > is to me the major negative point.
> > > - struct zswap_entry needs a refcount (a racing swapin must not
> > > decompress from an entry the completion frees) which makes the struct
> > > grows from 48 to 56 bytes
> >
> > Increasing the size of zswap_entry has to have a *very* strong reason
> > behind it. 8 extra bytes is 0.2% of the uncompressed size of pages in
> > zswap. If pages compress 3x, that's an extra 0.6% memory overhead on
> > the compressed pool, which could be gigabytes of memory on a large
> > host.
>
> First of all, it is likely we don't need to bump the zswap entry size.
>
> Previously, I suggested reducing the zswap entry size -8 by indexing
> the pool handle or something similar. The idea is being pursued by
> someone else but the review got stalled. So if you want to save space
> there are other low-hanging fruit opportunities.

That was not stalled, it is already merged :)