Re: [PATCH v4 15/17] mm/huge_memory: clean up after-split folio freeing in __folio_split

From: Kiryl Shutsemau

Date: Wed Sep 09 2026 - 04:34:25 EST


On Tue, Sep 08, 2026 at 02:12:19AM +0800, 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()
> unlocks the folio, then free_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 and unmapped
> here,

Are they mapped? remap_page() is above the point in function. It worth
rewording.

Code looks okay.

Reviewed-by: Kiryl Shutsemau (Meta) <kas@xxxxxxxxxx>

--
Kiryl Shutsemau / Kirill A. Shutemov