Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Usama Arif <usama.arif@linux.dev>
To: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
Cc: Usama Arif <usama.arif@linux.dev>,
	Andrew Morton <akpm@linux-foundation.org>,
	hughd@google.com, david@kernel.org,
	baolin.wang@linux.alibaba.com, hannes@cmpxchg.org,
	yosry@kernel.org, nphamcs@gmail.com, chengming.zhou@linux.dev,
	chrisl@kernel.org, kasong@tencent.com, baohua@kernel.org,
	shikemeng@huaweicloud.com, baoquan.he@linux.dev,
	youngjun.park@lge.com, alex@ghiti.fr, linux-mm@kvack.org,
	riel@surriel.com, shakeel.butt@linux.dev, kernel-team@meta.com,
	rkeilty@meta.com, atish.patra@linux.dev, dgreid@meta.com
Subject: Re: [PATCH] mm/shmem: bypass swap readahead for zswap
Date: Fri,  4 Dec 2026 07:32:14 -0800	[thread overview]
Message-ID: <20261204153215.3310837-1-usama.arif@linux.dev> (raw)
In-Reply-To: <axLYJ4jGuzVBHqZK@gremlin>

On Fri, 4 Dec 2026 15:14:02 +0000 "Lorenzo Stoakes (ARM)" <ljs@kernel.org> wrote:

> On Thu, Dec 03, 2026 at 10:02:53AM -0800, Usama Arif wrote:
> > Commit 7ed825f0f766 ("mm: bypass swap readahead for zswap") made
> > do_swap_page() skip readahead for zswap entries, but
> > shmem_swapin_folio() still only skips it for SWP_SYNCHRONOUS_IO
> > devices.
> >
> > zswap decompresses in the faulting task, so readahead has no I/O to
> > overlap and only slows the fault down. And since zswap loads are
> > exclusive, pages read ahead but never used stay uncompressed in memory
> > until reclaim compresses them again.
> >
> > Use swap_entry_synchronous() in shmem_swapin_folio(), like
> > do_swap_page(). zswap entries then take the SWP_SYNCHRONOUS_IO path,
> > which already uses order-0 folios once zswap has been enabled. Entries
> > on the backing device keep cluster readahead.
> >
> > On productions hosts that run VM workloads backed by shmem guest memory
> > with memfds and swaps only to zswap, about a third of shmem readahead pages
> > were never used. In a QEMU guest with a 2 GB memfd in zswap and
> > page-cluster=3, faulting in 10% of it left 36 MiB in the swap cache before
> > this change and none after. The memcg grew 24 MiB less and the faults took
> > 12% less time.
> >
> > Signed-off-by: Usama Arif <usama.arif@linux.dev>
> 
> Something's gone wrong here, maybe the original series that introduced
> swap_entry_synchronous() was removed from the tree but this is making the
> for-next tree not build:
> 
> mm/shmem.c:2583:7: error: call to undeclared function 'swap_entry_synchronous'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
>  2583 |                 if (swap_entry_synchronous(si, swap)) {
>       |                     ^
> 1 error generated.
> make[3]: *** [scripts/Makefile.build:290: mm/shmem.o] Error 1
> 

Yes the patch depends on [1] that introduced swap_entry_synchronous().

David and Andrew, could the patch go on whichever branch [1] went into?

Also this is a slightly broader topic. I always used to send non fixes
on top of mm-new. Should I still do this?

I see mm-new, but then I also see feature branches in [2] (or is that
just sub system fixes?). [2] also doesnt have a zswap tree.

Sorry if the above was discussed somewhere and I missed it.

Thanks!
Usama

[1] https://lore.kernel.org/all/20261102144835.304017-1-alex@ghiti.fr/
[2] https://git.kernel.org/pub/scm/linux/kernel/git/mm/core.git/refs/heads

> 
> 
> > ---
> >  mm/shmem.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/mm/shmem.c b/mm/shmem.c
> > index 344f7edf5e15a3..eba2a22af9a052 100644
> > --- a/mm/shmem.c
> > +++ b/mm/shmem.c
> > @@ -2570,8 +2570,8 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index,
> >  	/* Look it up and read it in.. */
> >  	folio = swap_cache_get_folio(swap);
> >  	if (!folio) {
> > -		if (data_race(si->flags & SWP_SYNCHRONOUS_IO)) {
> > -			/* Direct swapin skipping swap cache & readahead */
> > +		if (swap_entry_synchronous(si, swap)) {
> > +			/* Skip readahead: synchronous device or zswap */
> >  			folio = shmem_swap_alloc_folio(inode, vmf, index,
> >  						       swap, order, gfp);
> >  		} else {
> > --
> > 2.53.1-Meta
> >
> >
> >
> 
> --
> Cheers, Lorenzo
> 
> 


  reply	other threads:[~2026-12-04 15:32 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 18:02 [PATCH] mm/shmem: bypass swap readahead for zswap Usama Arif
2026-12-03 19:49 ` Yosry Ahmed
2026-12-03 19:53 ` Nhat Pham
2026-12-03 19:57 ` Shakeel Butt
2026-12-03 20:03 ` Andrew Morton
2026-12-03 20:07   ` Usama Arif
2026-12-04  3:21     ` Barry Song
2026-12-04 10:52       ` David Hildenbrand (Arm)
2026-12-04  1:24 ` SJ Park
2026-12-04  6:39 ` Baolin Wang
2026-12-04  7:46 ` Chris Down
2026-12-04 10:53 ` David Hildenbrand
2026-12-04 12:24 ` Harry Yoo
2026-12-04 15:14 ` Lorenzo Stoakes (ARM)
2026-12-04 15:32   ` Usama Arif [this message]
2026-12-04 16:03     ` Yosry Ahmed
2026-12-04 17:23       ` David Hildenbrand (Arm)
2026-12-04 17:28         ` Yosry Ahmed
2026-12-04 18:26           ` Andrew Morton
2026-12-04 18:03 ` sashiko-bot
2026-12-04 18:36   ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261204153215.3310837-1-usama.arif@linux.dev \
    --to=usama.arif@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=alex@ghiti.fr \
    --cc=atish.patra@linux.dev \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=baoquan.he@linux.dev \
    --cc=chengming.zhou@linux.dev \
    --cc=chrisl@kernel.org \
    --cc=david@kernel.org \
    --cc=dgreid@meta.com \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=kasong@tencent.com \
    --cc=kernel-team@meta.com \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=nphamcs@gmail.com \
    --cc=riel@surriel.com \
    --cc=rkeilty@meta.com \
    --cc=shakeel.butt@linux.dev \
    --cc=shikemeng@huaweicloud.com \
    --cc=yosry@kernel.org \
    --cc=youngjun.park@lge.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox