[PATCH v2 0/3] mm: bypass swap readahead for zswap
From: Alexandre Ghiti
Date: Wed Jul 22 2026 - 12:54:18 EST
First, the title is a bit misleading but this patchset is a follow-up of
the zswap bypass readahead, so I kept it.
Swap readahead walks a window around the faulting entry and reads every
neighbour. Some of those reads are synchronous (a zswap-resident entry
or an entry on an SWP_SYNCHRONOUS_IO device) with no asynchronous device I/O
to overlap them with. Today they run inline during the window walk, so they
are pure added latency in front of the read the fault is actually waiting on.
This series splits the window walk into two passes and reorders it around that
distinction:
Patch 1 (overlap): issue the asynchronous device reads first, defer the
synchronous neighbours, and read them while the device I/O is in flight. This
overlaps the synchronous work with the disk reads instead of serialising it in
front of them -- the win for mixed (zswap + disk) workloads.
Patch 2 (bypass unless the target needs I/O): when the faulting target is
itself synchronous there is no in-flight I/O to hide the second pass behind, so
skip it. This is the zswap readahead bypass, gated on the target: it helps
pure-zswap workloads and, above all, keeps synchronous-target page-fault
latency low.
Patch 3 (SWP_SYNCHRONOUS_IO): treat SWP_SYNCHRONOUS_IO devices (zram) as
synchronous sources too, so a disk-target fault overlaps its zram neighbours'
reads behind its own disk I/O -- the same benefit patch 1 gives zswap
neighbours, now for mixed zram+disk workloads.
Changes since the RFC [1]:
- patch 1: overlap the synchronous decompression with the in-flight disk I/O
- patch 2: bypass the second pass when the target needs no disk I/O
- patch 3: extend the same handling to SWP_SYNCHRONOUS_IO devices (zram)
[1] https://lore.kernel.org/all/20260624075700.751467-1-alex@xxxxxxxx/
Alexandre Ghiti (3):
mm: swap: overlap synchronous readahead decompression with disk I/O
mm: swap: bypass synchronous readahead unless the target needs I/O
mm: swap: treat SWP_SYNCHRONOUS_IO devices as synchronous in readahead
include/linux/swap.h | 6 ++++
include/linux/zswap.h | 6 ++++
mm/swap_state.c | 67 +++++++++++++++++++++++++++++++++++++++++--
mm/swapfile.c | 11 +++++++
mm/zswap.c | 17 +++++++++++
5 files changed, 105 insertions(+), 2 deletions(-)
base-commit: 13a1e1a618858407fa12c391f664ea750651f6b2
--
2.53.0-Meta