Re: [PATCH v2 4/4] mm/swap: keep the swap-in pressure window open across a batch

From: Nhat Pham

Date: Tue Nov 03 2026 - 14:47:40 EST


On Tue, Nov 3, 2026 at 9:18 AM Kairui Song via B4 Relay
<devnull+kasong.tencent.com@xxxxxxxxxx> wrote:
>
> From: Johannes Weiner <hannes@xxxxxxxxxxx>
>
> For asynchronous block devices, swap reads are batched and submitted later
> since commit dda8fb68b590 ("mm/swap: also use struct swap_iocb for block
> I/O"), but the caller submits the batch after the pressure window in
> swap_read_folio() has closed. Batching is cheap, the submission is the
> part that can block, and that is no longer counted as pressure since then.
>
> Keep the pressure window open across the batch instead: swap_read_folio()
> opens it on the first folio, and swap_read_submit() closes it after the
> submission, also when the batch ends up with no folio queued. Each batch
> is then billed for its own read.
>
> A single workingset refault marks its whole batch as stalled, which is
> fine here: the batch is submitted as a whole, so its submission holds
> up that refault too. Before the batching, a blocking submission was billed
> only to the folio that issued it, even when it also delayed the refaults
> queued behind it in the same task, so this might be more accurate rather
> than less. Synchronous reads are already one folio per batch after the
> previous patch, which keeps their attribution tight.
>
> The same hole has been there for a swap file on a file system that submits
> through swap_fs_prepare_rw(), since commit 5169b844b7dd ("mm: submit
> multipage reads for SWP_FS_OPS swap-space"), which started batching its
> reads and deferring the submission to the caller, so this covers it there
> as well.
>
> Fixes: dda8fb68b590 ("mm/swap: also use struct swap_iocb for block I/O")
> Fixes: 5169b844b7dd ("mm: submit multipage reads for SWP_FS_OPS swap-space")
> Signed-off-by: Johannes Weiner <hannes@xxxxxxxxxxx>
> Link: https://lore.kernel.org/linux-mm/auOz00OGB_8dgniC@xxxxxxxxxxx/
> [kasong@xxxxxxxxxxx: added commit message and slight tweaks]
> Signed-off-by: Kairui Song <kasong@xxxxxxxxxxx>
> ---
> include/linux/swap_ops.h | 10 ++++++
> mm/page_io.c | 79 ++++++++++++++++++++++++++++++------------------
> 2 files changed, 60 insertions(+), 29 deletions(-)

Reviewed-by: Nhat Pham <nphamcs@xxxxxxxxx>