Re: [PATCH v4 12/19] mm, swap: use swap cache as the swap in synchronize layer

From: Baoquan He
Date: Wed Dec 17 2025 - 22:32:10 EST


On 12/05/25 at 03:29am, Kairui Song wrote:
> From: Kairui Song <kasong@xxxxxxxxxxx>
>
> Current swap in synchronization mostly uses the swap_map's
> SWAP_HAS_CACHE bit. Whoever sets the bit first does the actual
> work to swap in a folio.
>
> This has been causing many issues as it's just a poor implementation
> of a bit lock. Raced users have no idea what is pinning a slot, so
> it has to loop with a schedule_timeout_uninterruptible(1), which is
> ugly and causes long-tailing or other performance issues. Besides,
> the abuse of SWAP_HAS_CACHE has been causing many other troubles for
> synchronization or maintenance.
>
> This is the first step to remove this bit completely.
>
> We have just removed all swap in paths that bypass the swap cache, and

I think we didn't remove swap in paths that bypss the swap cache, we
just add folio to swap cache in those swap in paths where swap cache is
bypassed.