Re: [PATCH v5 15/17] mm/huge_memory: clean up after-split folio freeing in __folio_split
From: David Hildenbrand (Arm)
Date: Fri Sep 18 2026 - 17:04:49 EST
On 9/14/26 19:14, Kairui Song via B4 Relay wrote:
> From: Kairui Song <kasong@xxxxxxxxxxx>
>
> Replace free_folio_and_swap_cache() with an explicit folio_free_swap()
> and folio_put() in the after-split loop. free_folio_and_swap_cache()
> must trylock it again and re-check folio_mapped() before freeing the
> swap cache entries. If the trylock loses a race, the entries are left
> behind even though the folio reference is dropped.
>
> The sub folios are still locked here, so just directly call
> folio_free_swap() under the lock if it's unmapped, then unlock and
> drop the reference. This makes the swap cache freeing deterministic
> and the reference drop explicit.
>
> Reviewed-by: Zi Yan <ziy@xxxxxxxxxx>
> Reviewed-by: Yeoreum Yun <yeoreum.yun@xxxxxxx>
> Reviewed-by: Kiryl Shutsemau (Meta) <kas@xxxxxxxxxx>
> Signed-off-by: Kairui Song <kasong@xxxxxxxxxxx>
> ---
Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
--
Cheers,
David