From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Nhat Pham <nphamcs@gmail.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
Xueyuan Chen <xueyuan.chen@vivo.com>,
Barry Song <baohua@kernel.org>,
Yosry Ahmed <yosry.ahmed@linux.dev>,
Johannes Weiner <hannes@cmpxchg.org>,
Brian Geffon <bgeffon@google.com>,
Minchan Kim <minchan@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
xueyuan.chen21@gmail.com
Subject: Re: [RFC PATCH 0/2] mm: zsmalloc: make shrinker compaction budget-aware
Date: Thu, 29 Oct 2026 10:43:04 +0900 [thread overview]
Message-ID: <auKjuiRxQwtsZF_0@google.com> (raw)
In-Reply-To: <CAKEwX=Mm2tXcen-quRXHf1Y2qSHYvpEUe4xiw-mHYaJnRUR-EA@mail.gmail.com>
On (26/08/07 09:25), Nhat Pham wrote:
> > On (26/08/07 18:57), Xueyuan Chen wrote:
> > > Hi Sergey,
> > >
> > > Here is some additional data:
> > >
> > > I used the following definitions:
> > > compactable ratio = freeable_pages / total_pages
> > > memory reclaimed = pages_freed * PAGE_SIZE
> > >
> > > freeable_pages is the estimate before compaction, based on the same
> > > calculation as zs_shrinker_count(), while pages_freed is the actual
> > > number of backing pages released.
> > >
> > > There were 264 callbacks in the trace:
> > > callback elapsed time:
> > > median: 5.77 ms
> > > p95: 55.82 ms
> > > maximum: 271.36 ms
> > >
> > > compactable ratio before compaction:
> > > median: 0.32%
> > > p95: 2.86%
> > > maximum: 8.33%
> > >
> > > memory reclaimed per callback:
> > > median: 3.80 MiB
> > > p95: 30.45 MiB
> > > maximum: 92.73 MiB
> > >
> > > The longest callback took 271.36 ms. Its compactable ratio was 3.25%,
> > > and it released 7,650 pages, or about 29.88 MiB.
> > >
> > > There was also a 241.91 ms callback (with 30 schedule-outs) with a
> > > compactable ratio of 0.44%. It released 1,019 pages, or about
> > > 3.98 MiB.
> > >
> > > Based on this data, it seems better to remove the shrinker.
> > >
> > > Would you prefer that I change v2 to remove the zsmalloc shrinker
> > > callbacks directly?
> >
> > Let's bring in heavy artillery to this discussion, in addition to Andrew
> > and Minchan, adding Nhat, Yosry, Barry, Johannes, Brian (random order).
> >
> > Folks, I'm bullish on removal of zsmalloc shrinker callbacks.
> > I don't think those buy us much apart from memcpy-s and lock
> > contention. Systems that want to compact zsmalloc have a sysfs
> > knob (and API) to do so (based on zram mm_stat numbers).
>
> Hmm we'd need to collect more data in our workloads to determine, but
> if we can compute compactable ratio (freeable_pages / total_pages) on
> a per size class basis, can we just skip the size class whose ratio is
> too bad? Would that at least cut down on the vast majority of
> fruitless memcpys and lock acquisitions etc?
>
> I'm always a bit hesitant to over-rely on userspace, especially when
> kernel has information to do something smart about it. It might not
> react in time, and many proactive reclaiming schemes back off under
> heavy memory pressure.
Apologies for the delay.
The thing about shrinker compaction is that it's sort of on the
wrong end. It doesn't trigger compaction when memory is plentiful,
no matter the internal fragmentation rate, and start firing compaction
scans when memory pressure hits. The problem with this is that, now
compaction moves objects (if can compact zspages) and releases empty
zspages, in parallel with potentially heavy swapping out activities,
which can simply allocate those released pages back. Which seems like
a useless exercise and needless memcpy-s. So I was thinking about
either putting it under config or just removing it (this might be a
harder decision).
next prev parent reply other threads:[~2026-10-29 1:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 8:27 [RFC PATCH 0/2] mm: zsmalloc: make shrinker compaction budget-aware xueyuan.chen
2026-08-06 8:27 ` [RFC PATCH 1/2] mm: zsmalloc: add a page limit to pool compaction xueyuan.chen
2026-08-06 8:27 ` [RFC PATCH 2/2] mm: zsmalloc: use the shrinker reclaim budget xueyuan.chen
2026-08-07 3:56 ` [RFC PATCH 0/2] mm: zsmalloc: make shrinker compaction budget-aware Sergey Senozhatsky
2026-08-07 10:57 ` Xueyuan Chen
2026-08-07 12:12 ` Sergey Senozhatsky
2026-08-07 16:25 ` Nhat Pham
2026-08-11 9:03 ` Xueyuan Chen
2026-08-11 16:25 ` Nhat Pham
2026-08-14 16:50 ` Xueyuan Chen
2026-08-18 12:11 ` Xueyuan Chen
2026-10-29 1:43 ` Sergey Senozhatsky [this message]
2026-10-29 1:48 ` Sergey Senozhatsky
2026-10-29 2:26 ` Sergey Senozhatsky
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=auKjuiRxQwtsZF_0@google.com \
--to=senozhatsky@chromium.org \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=bgeffon@google.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=nphamcs@gmail.com \
--cc=xueyuan.chen21@gmail.com \
--cc=xueyuan.chen@vivo.com \
--cc=yosry.ahmed@linux.dev \
/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