From: Nhat Pham <nphamcs@gmail.com>
To: Hao Jia <jiahao.kernel@gmail.com>
Cc: Yosry Ahmed <yosry@kernel.org>,
akpm@linux-foundation.org, tj@kernel.org, hannes@cmpxchg.org,
shakeel.butt@linux.dev, mhocko@kernel.org, mkoutny@suse.com,
chengming.zhou@linux.dev, muchun.song@linux.dev,
roman.gushchin@linux.dev, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
Hao Jia <jiahao1@lixiang.com>
Subject: Re: [PATCH 2/2] mm/zswap: Support batch writeback in shrink_memcg()
Date: Thu, 16 Jul 2026 11:04:02 -0700 [thread overview]
Message-ID: <CAKEwX=Mdi5au5aXWdx3C7d1N4_3o2uiJh2sZ=sf6kpKAdtD1zQ@mail.gmail.com> (raw)
In-Reply-To: <b910e870-9583-a2f5-b681-e69edb9af290@gmail.com>
On Wed, Jul 15, 2026 at 7:54 PM Hao Jia <jiahao.kernel@gmail.com> wrote:
>
>
>
> On 2026/7/16 00:14, Yosry Ahmed wrote:
> >>>> Test Setup:
> >>>> Total memory: 32 GB.
> >>>> zswap settings: max_pool_percent=1, accept_threshold_percent=50,
> >>>> shrinker_enabled=N.
> >>>> Allocate 512MB of anonymous pages and fill them with random data (to avoid
> >>>> compression), then use cgroup memory.reclaim to force a large amount of
> >>>> anonymous pages into zswap. At an interval of 2ms, allocate a 4K anonymous
> >>>> page where the first 4 bytes are random numbers and the rest are zeros, and
> >>>> then trigger a reclamation of this 4K anonymous page through cgroup
> >>>> memory.reclaim. When the pool threshold is reached, shrink_memcg() will
> >>>> be triggered.
> >>>>
> >>>> The test data after running for 120s is as follows:
> >>>> Baseline Patched
> >>>> shrink_worker wakeups 5363 85
> >>>> shrink_memcg calls 11,345,012 188,264
> >>>> written_back 40214 40275
> >>>>
> >>>> Conclusion:
> >>>> Under the same workload and run duration, the patched kernel shows a
> >>>> significant reduction in both shrink_worker wakeups and shrink_memcg calls.
> >>>
> >>> Please also include data from the case where zswap store failures are
> >>> observed and pages go to disk, and compare before and after this
> >>> patch. I think that part is also really important.
> >>
> >> I retested and added some collected information. Perhaps
> >> `pool_limit_hit` and `pswpout` can explain that batch shrinking of zswap
> >> can reduce the number of pages that fail to be stored due to the pool
> >> limit, allowing zswap to skip zswap and go directly to disk.
> >
> > Oh I meant the other test case with high memory pressure where we saw
> > a lot more writeback with this patch. Do you have similar data from
> > that test case?
> >
>
> Below are the results from stress-ng (high memory pressure case), which
> lead to a similar conclusion:
>
> Baseline Patched
> shrink_worker wakeups 5,640 987
> shrink_memcg calls 8,481,500 2,504,818
> written_back pages 260 768,576
> zswap_store calls 2,742,756 2,301,414
> store succeeded (ret=1) 934,640 1,308,686
> store rejected (ret=0) 1,808,116 992,728 <-
> store reject rate ~65% ~43%
> pool_limit_hit delta 1,181,310 101,593 <-
> pswpout 1,808,376 1,761,304
> pswpin 4,288,497 3,902,658
>
>
> pswpout = store rejected + written_back pages
> Note that pswpout comprises two parts: the store rejected count (where
> we skip zswap and go directly to disk) and the number of pages written
> back by shrink_memcg().
>
> Therefore, we can directly leverage store rejected to evaluate the
> scenario where zswap is skipped and pages bypass it to disk. This
> provides a much clearer picture than looking at pswpout alone.
>
> Do we need to include both sets of test results along with the
> comparison data in the final commit message?
I mean, it helps your case no? :)
But nicely done. My understanding is, this batching of the global
shrinker reduces overall disk swap fallback, correct?
Other than Yosry's comment, the rest LGTM FWIW :) Thanks for fixing this, Hao!
next prev parent reply other threads:[~2026-07-16 18:04 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 8:15 [PATCH 0/2] mm/zswap: Fixes and improves the zswap global shrinker Hao Jia
2026-07-14 8:15 ` [PATCH 1/2] mm/zswap: Fix global shrinker when memory cgroup is disabled Hao Jia
2026-07-14 16:52 ` Yosry Ahmed
2026-07-15 2:31 ` Andrew Morton
2026-07-15 12:30 ` Hao Jia
2026-07-15 16:13 ` Yosry Ahmed
2026-07-16 2:21 ` Hao Jia
2026-07-16 18:18 ` Nhat Pham
2026-07-17 0:08 ` Yosry Ahmed
2026-07-17 8:46 ` Hao Jia
2026-07-14 8:15 ` [PATCH 2/2] mm/zswap: Support batch writeback in shrink_memcg() Hao Jia
2026-07-14 16:52 ` Yosry Ahmed
2026-07-15 11:28 ` Hao Jia
2026-07-15 16:14 ` Yosry Ahmed
2026-07-16 2:54 ` Hao Jia
2026-07-16 18:04 ` Nhat Pham [this message]
2026-07-17 8:29 ` Hao Jia
2026-07-16 20:35 ` Yosry Ahmed
2026-07-17 16:50 ` Nhat Pham
2026-07-17 16:55 ` Yosry Ahmed
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='CAKEwX=Mdi5au5aXWdx3C7d1N4_3o2uiJh2sZ=sf6kpKAdtD1zQ@mail.gmail.com' \
--to=nphamcs@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=chengming.zhou@linux.dev \
--cc=hannes@cmpxchg.org \
--cc=jiahao.kernel@gmail.com \
--cc=jiahao1@lixiang.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=mkoutny@suse.com \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=tj@kernel.org \
--cc=yosry@kernel.org \
/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