Re: [PATCH 1/3] mm/swap: revert to single-folio writes for synchronous swap devices

Usama Arif <[email protected]> Wed, 22 Jul 2026 09:36:00 -0700
Newsgroups org.kernel.vger.linux-nfs,org.kernel.vger.linux-cifs,org.kvack.linux-mm
Message-ID <[email protected]>
On Wed, 22 Jul 2026 15:06:07 +0200 Christoph Hellwig <[email protected]> wrote:

> Kairui Song reported that zram benefits from submitting each folio
> directly instead of batching up I/O because the classic LRU scanning
> benefits from clearing the folio writeback bit in the scan loop.
> 
> Accommodate that by kicking off reads for synchronous devices for

s/reads/writes/ ?

> each iteration.
> 
> Signed-off-by: Christoph Hellwig <[email protected]>
> ---
>  mm/page_io.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 


Change makes sense.

After the commit message fix above, feel free to add

Acked-by: Usama Arif <[email protected]>


> diff --git a/mm/page_io.c b/mm/page_io.c
> index e4fa7ffffe8b..c984a4023a65 100644
> --- a/mm/page_io.c
> +++ b/mm/page_io.c
> @@ -358,7 +358,16 @@ static void swap_add_folio(struct swap_io_ctx *ctx, struct folio *folio, int rw)
>  	}
>  	bvec_set_folio(&sio->bvecs[sio->nr_bvecs], folio, folio_size(folio), 0);
>  	sio->len += folio_size(folio);
> -	if (++sio->nr_bvecs == ARRAY_SIZE(sio->bvecs)) {
> +
> +	/*
> +	 * Write out the iocb if we filled it, or if the device is synchronous.
> +	 *
> +	 * The latter is to work around expectations in the classic LRU code
> +	 * which make synchronous clearing of the folio writeback flag in the
> +	 * reclaim path beneficial.
> +	 */
> +	if (++sio->nr_bvecs == ARRAY_SIZE(sio->bvecs) ||
> +	    (rw == WRITE && (sis->flags & SWP_SYNCHRONOUS_IO))) {
>  		if (rw == WRITE)
>  			swap_write_submit(ctx);
>  		else
> -- 
> 2.53.0
> 
>