Re: [PATCH v3 4/4] mm: clarify the folio_free_swap() for do_swap_page()
From: David Hildenbrand (Arm)
Date: Thu Jul 02 2026 - 04:15:13 EST
On 7/2/26 01:59, Barry Song (Xiaomi) wrote:
> Since commit 4b34f1d82c654 ("mm, swap: free the swap cache after
> folio is mapped"), we have relied on do_wp_page() to handle the
> non-exclusive case, where the folio may either be reused or require
> CoW.
>
> As a result, using the refcount in do_swap_page() to decide when to
> free the swap cache is no longer necessary, since do_wp_page() can
> handle this more cleanly and consistently.
>
> We can now simply use FAULT_FLAG_WRITE together with exclusivity to
> decide when to free the swap cache in do_swap_page().
>
> Suggested-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
> Signed-off-by: Barry Song (Xiaomi) <baohua@xxxxxxxxxx>
> ---
Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
--
Cheers,
David