From: Yosry Ahmed <yosry@kernel.org>
To: Barry Song <baohua@kernel.org>
Cc: Jiayuan Chen <jiayuan.chen@linux.dev>,
Usama Arif <usama.arif@linux.dev>,
linux-mm@kvack.org, Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Muchun Song <muchun.song@linux.dev>,
Nhat Pham <nphamcs@gmail.com>,
Chengming Zhou <chengming.zhou@linux.dev>,
Andrew Morton <akpm@linux-foundation.org>,
Chris Li <chrisl@kernel.org>, Kairui Song <kasong@tencent.com>,
Kemeng Shi <shikemeng@huaweicloud.com>,
Baoquan He <baoquan.he@linux.dev>,
Youngjun Park <youngjun.park@lge.com>,
David Hildenbrand <david@kernel.org>,
Qi Zheng <qi.zheng@linux.dev>, Lorenzo Stoakes <ljs@kernel.org>,
Axel Rasmussen <axelrasmussen@google.com>,
Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
cgroups@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH mm-new v1 2/2] mm: vmscan: skip anon folios zswap would refuse when writeback is off
Date: Fri, 30 Oct 2026 22:32:15 +0000 [thread overview]
Message-ID: <auUZPZfxNNBCH5uf@google.com> (raw)
In-Reply-To: <CAGsJ_4y52-hyd=JrPaX-isNWNFUfX30aLCgbsiCAFjxDzhYs8Q@mail.gmail.com>
On Sat, Oct 31, 2026 at 03:03:26AM +0800, Barry Song wrote:
> On Sat, Oct 31, 2026 at 1:52 AM Yosry Ahmed <yosry@kernel.org> wrote:
> >
> > On Fri, Oct 30, 2026 at 2:53 AM Jiayuan Chen <jiayuan.chen@linux.dev> wrote:
> > >
> > > A memcg with memory.zswap.writeback=0 can only swap into zswap. Once
> > > zswap stops taking its pages, because the pool is at its limit or the
> > > memcg is at memory.zswap.max, swap_writeout() has nowhere to put a
> > > dirty folio and returns AOP_WRITEPAGE_ACTIVATE.
> > >
> > > shrink_folio_list() only learns that at the very end. Every folio it
> > > picks gets a swap slot, is unmapped, fails in swap_writeout() and goes
> > > back to the active list, to be aged and tried again. Each round costs
> > > a slot, an rmap walk, a TLB flush and a minor fault for the owner, and
> > > frees nothing. The folio also stays in the swap cache holding its slot.
> > >
> > > The obvious place for a zswap check is can_reclaim_anon_pages(), but
> > > it cannot go there. Zero-filled folios never reach zswap:
> > > swap_writeout() marks them in the swap table and returns before
> > > zswap_store() is called. They need no pool space, they are common, and
> > > a memcg-wide "no anon" decision would keep them in memory for as long
> > > as zswap is full. With zswap full they must still be reclaimable.
> >
> > I really wonder if we should revisit not swapping zero-filled pages at
> > all, and instead mapping them to the zero page read-only (and whatever
> > the equivalent for shmem could be), because yes, the right place is
> > can_reclaim_anon_pages(). I don't remember what happened to that
> > proposal, Usama do you remember?
>
> Hi Yosry,
>
> FYI, I recalled that we discussed something similar in this
> thread too:
> https://lore.kernel.org/linux-mm/20241212073711.82300-1-21cnbao@gmail.com/
>
> It would be nice to see an implementation that maps
> zero-filled pages to the shared zero page.
Yeah I also found Usama's attempt and the complication that were found,
unfortunately it's not simple:
https://lore.kernel.org/linux-mm/20240604105950.1134192-1-usamaarif642@gmail.com/.
prev parent reply other threads:[~2026-10-30 22:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 9:52 [PATCH mm-new v1 0/2] mm: vmscan: skip anon folios zswap would refuse when writeback is off Jiayuan Chen
2026-10-30 9:52 ` [PATCH mm-new v1 1/2] mm: memcontrol: split mem_cgroup_may_zswap() out of obj_cgroup_may_zswap() Jiayuan Chen
2026-10-30 9:52 ` [PATCH mm-new v1 2/2] mm: vmscan: skip anon folios zswap would refuse when writeback is off Jiayuan Chen
2026-10-30 17:52 ` Yosry Ahmed
2026-10-30 19:03 ` Barry Song
2026-10-30 22:32 ` Yosry Ahmed [this message]
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=auUZPZfxNNBCH5uf@google.com \
--to=yosry@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=baoquan.he@linux.dev \
--cc=cgroups@vger.kernel.org \
--cc=chengming.zhou@linux.dev \
--cc=chrisl@kernel.org \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=jiayuan.chen@linux.dev \
--cc=kasong@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=nphamcs@gmail.com \
--cc=qi.zheng@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=shikemeng@huaweicloud.com \
--cc=usama.arif@linux.dev \
--cc=weixugc@google.com \
--cc=youngjun.park@lge.com \
--cc=yuanchu@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.