Re: [PATCH v5 1/3] mm: swap: move LRU insertion out of the swap cache allocator

Barry Song <[email protected]>
Newsgroups org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel,org.kvack.linux-mm
Message-ID <CAGsJ_4w1FxNMTWiYDU86=bifr6mWZ=Rs0suUBGtN4qs_pU88Bg@mail.gmail.com>
On Fri, Sep 11, 2026 at 8:15 PM Alexandre Ghiti <[email protected]> wrote:
>
> This is a preparatory patch.
>
> __swap_cache_alloc_folio() adds the new folio to the LRU itself, which
> leaves its callers no way to act on the folio before it becomes visible
> to reclaim.  Two users need exactly that:
>
>  - moving the refault evaluation out of the swap cache folio allocation
>    requires it to happen before folio_add_lru(): that consumes PG_active
>    to file the folio on the inactive or the active list, and under MGLRU
>    it also reads PG_workingset to pick the generation.  Setting either
>    flag afterwards does not move the folio;
>
>  - zswap writeback dropbehind needs the buffer folio to stay off the LRU
>    entirely, as the per-CPU LRU batch would hold a reference on it and
>    keep remove_mapping() from freeing it once writeback completes.
>
> Defer the LRU insertion to the callers of __swap_cache_alloc_folio():
> each of them adds the folio right after the allocation, so there is no
> functional change intended.
>
> Suggested-by: Kairui Song <[email protected]>
> Reviewed-by: Nhat Pham <[email protected]>
> Reviewed-by: Kunwu Chan <[email protected]>
> Acked-by: Usama Arif <[email protected]>
> Signed-off-by: Alexandre Ghiti <[email protected]>
> ---

LGTM,

Reviewed-by: Barry Song <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.