Re: [PATCH 1/2] mm: zswap: free synchronous-IO writeback folios directly
From: Johannes Weiner
Date: Thu Jul 23 2026 - 09:46:42 EST
On Sat, Jul 18, 2026 at 11:36:39AM +0200, Alexandre Ghiti wrote:
> @@ -972,6 +972,30 @@ static bool zswap_decompress(struct zswap_entry *entry, struct folio *folio)
> /*********************************
> * writeback code
> **********************************/
> +static void zswap_writeback_free_folio(struct folio *folio)
> +{
> + folio_lock(folio);
> +
> + /* The folio was allocated off the LRU and nothing re-adds it here. */
> + VM_WARN_ON_ONCE_FOLIO(folio_test_lru(folio), folio);
> +
> + /*
> + * Gate remove_mapping() on folio_test_swapcache(): a racing swapin may
> + * have freed the swap slot (folio_free_swap()) and dropped the folio from
> + * the cache, and remove_mapping() must not run on a non-swapcache folio
> + * (it would trip __remove_mapping()'s mapping == folio_mapping() check).
> + */
> + if (folio_test_swapcache(folio) &&
> + remove_mapping(swap_address_space(folio->swap), folio))
I just chatted with Alexandre off-list, but this path does not store
an eviction shadow like the reclaim path does. That means no refaults
are detected from dropbehind pages, which can fundamentally alter
reclaim decisions, zswap shrinker force, and pressure detection.