Re: [PATCH v2 00/19] mm, swap: swap table phase II: unify swapin use swap cache and cleanup flags

From: Kairui Song
Date: Sun Nov 16 2025 - 22:22:17 EST


On Mon, Nov 17, 2025 at 2:11 AM Kairui Song <ryncsn@xxxxxxxxx> wrote:
>
> This series removes the SWP_SYNCHRONOUS_IO swap cache bypass swapin code and
> special swap flag bits including SWAP_HAS_CACHE, along with many historical
> issues. The performance is about ~20% better for some workloads, like
> Redis with persistence. This also cleans up the code to prepare for
> later phases, some patches are from a previously posted series.
>
> Swap cache bypassing and swap synchronization in general had many
> issues. Some are solved as workarounds, and some are still there [1]. To
> resolve them in a clean way, one good solution is to always use swap
> cache as the synchronization layer [2]. So we have to remove the swap
> cache bypass swap-in path first. It wasn't very doable due to
> performance issues, but now combined with the swap table, removing
> the swap cache bypass path will instead improve the performance,
> there is no reason to keep it.
>
> Now we can rework the swap entry and cache synchronization following
> the new design. Swap cache synchronization was heavily relying on
> SWAP_HAS_CACHE, which is the cause of many issues. By dropping the usage
> of special swap map bits and related workarounds, we get a cleaner code
> base and prepare for merging the swap count into the swap table in the
> next step.

A few things I forgot to mention about the following series, in phase
2 we removed the swap cache bypassing, unified the synchronization,
and removed special swap_map bits. Now swap_map is only used for swap
count, so in the next phase swap_map can be merged into the swap
table, which will clean up more things, and reduce memory usage (1
byte per slot).

Removal of swap_cgroup_ctrl is also doable, but need to be done after
we also simplify the allocation of swapin folios: always use the new
swap_cache_alloc_folio helper introduced in this series for folio
allocation so the folio accounting will also be managed by swap layer,
hence merging of the swap_cgroup_ctrl into swap table will be doable
by then.