Re: [PATCH v5 3/3] mm: zswap: drop cold writeback folios via swap dropbehind

From: Nhat Pham

Date: Mon Sep 14 2026 - 14:18:13 EST


On Fri, Sep 11, 2026 at 5:17 AM Alexandre Ghiti <alex@xxxxxxxx> wrote:
>
> zswap writeback decompresses an entry into a fresh swap cache folio and
> writes it back. The folio is cold by construction, yet it is left on the
> LRU for reclaim to find and free later, wasting a reclaim scan and keeping
> cold memory resident longer than necessary.
>
> Allocate the folio off the LRU and mark it PG_dropbehind so the swap
> dropbehind path frees it from the swap cache once writeback completes.
>
> __swap_cache_alloc_folio() evaluates a refault on the new folio, and
> workingset_refault() sets PG_active when it looks recent. Until now
> folio_add_lru() consumed that flag and __page_cache_release() cleared it
> once the folio left the LRU. This folio never reaches the LRU, so nothing
> would clear PG_active and the folio would be freed with a
> PAGE_FLAGS_CHECK_AT_FREE flag set, tripping bad_page() under
> CONFIG_DEBUG_VM. Clear it after allocation.
>
> That is a workaround: the refault should not be evaluated on a writeback
> buffer at all. A fix for that is on the mailing list [1].
>
> Link: https://lore.kernel.org/linux-mm/20260911092012.92399-1-alex@xxxxxxxx/ [1]
> Suggested-by: Johannes Weiner <hannes@xxxxxxxxxxx>
> Suggested-by: Nhat Pham <nphamcs@xxxxxxxxx>
> Reviewed-by: Kunwu Chan <kunwu.chan@xxxxxxxxx>
> Signed-off-by: Alexandre Ghiti <alex@xxxxxxxx>

LGTM!

Reviewed-by: Nhat Pham <nphamcs@xxxxxxxxx>