The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Chris Wiseman <chriswiseman@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	 Minchan Kim <minchan@kernel.org>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	 Johannes Weiner <hannes@cmpxchg.org>,
	Yosry Ahmed <yosry@kernel.org>, Nhat Pham <nphamcs@gmail.com>,
	 Chengming Zhou <chengming.zhou@linux.dev>,
	Xueyuan Chen <xueyuan.chen21@gmail.com>,
	 Xueyuan Chen <xueyuan.chen@vivo.com>,
	Barry Song <baohua@kernel.org>,
	 Brian Geffon <bgeffon@google.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/zsmalloc: remove shrinker
Date: Wed, 2 Dec 2026 11:09:24 +0900	[thread overview]
Message-ID: <aw99Yd_HQpv42lbT@google.com> (raw)
In-Reply-To: <18ed2967f99a2eff.3137322e32332e3235332e313736.2c2157.0000sendgmr@google.com>

On (26/12/01 15:02), Chris Wiseman wrote:
> zsmalloc registers a shrinker to run automatic pool compaction under
> memory pressure.  Because zs_shrinker_scan() calls zs_compact(), it
> ignores sc->nr_to_scan and compacts every size class, taking
> write_lock(&pool->lock) and per-class locks (dropping them only when a
> destination zspage fills or pool->lock is contended).  During active
> memory pressure, swap-out allocates concurrently from the same size
> classes, so physical pages freed by mid-swap compaction are immediately
> reallocated.  Incoming swap-out refills free slots on its own, while
> shrinker compaction contends with page faults and swap-out.
> 
> In the RFC discussion, Xueyuan Chen reported compaction stalls up to
> 269.68 ms (p95 38.86 ms) on a 12 GB Android device.  Testing on ARM64
> QEMU shows that removing the shrinker eliminates mid-swap compaction
> churn without increasing active pool memory usage for either zram or
> zswap, and cuts zswap page-fault latency under active swap-out:
> 
> ARM64 QEMU (Linux 7.3.0+, zram0, 16 boots per config, ~240 MB swap-out):
> 
>                                        Before      After
>   Pages compacted mid-swap              2,218          0
>   zram mem_used_total (mid-swap)     121.0 MB   120.9 MB
>   zram mem_used_total (post-compact) 111.2 MB   110.9 MB
> 
> ARM64 QEMU (Linux 7.3.0+, 4 vCPUs, zswap lz4):
> 
>                                        Before      After
>   Active swap-out pool size           95.9 MB    95.1 MB
>   Active swap-out p50 fault          3,262 us   2,414 us (-26%)
>   After swap-out stops (holes held)   44.2 MB    65.1 MB (+20.9 MB)
> 
> For zram, userspace can still trigger compaction explicitly via
> /sys/block/zram<id>/compact (zs_compact()), and mm_stat's
> pages_compacted now reflects manual compaction only.  For zswap, the
> shrinker only reduced pool size after new swap-outs stopped; as
> discussed on the RFC thread, reclaim-time compaction hurts active fault
> latency without reducing active pool size, and any proactive compaction
> interface for zswap can be evaluated separately.
> 
> Remove the zsmalloc shrinker callbacks, registration, and header
> include.  Because zs_register_shrinker() was the only remaining reader
> of pool->name (zs_pool_stat_create() passes the name parameter directly
> to debugfs), also remove pool->name and its kstrdup()/kfree()
> allocation.
> 
> On arm64 defconfig (4K pages, Clang), this shrinks struct zs_pool from
> 2128 bytes (34 cachelines) to 2112 bytes (33 cachelines) via pahole and
> reduces mm/zsmalloc.o object size (scripts/bloat-o-meter):
> 
>   arm64 defconfig (Clang):   30684 -> 30127 bytes (-557 bytes, -1.82%)
>   x86_64 minimal (GCC):      12584 -> 12169 bytes (-415 bytes, -3.30%)
> 
> Link: https://lore.kernel.org/cover.1786003779.git.xueyuan.chen@vivo.com
> Suggested-by: Sergey Senozhatsky <senozhatsky@chromium.org>
> Suggested-by: Yosry Ahmed <yosry@kernel.org>
> Signed-off-by: Chris Wiseman <chriswiseman@google.com>

Acked-by: Sergey Senozhatsky <senozhatsky@chromium.org>

      parent reply	other threads:[~2026-12-02  2:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 15:02 [PATCH] mm/zsmalloc: remove shrinker Chris Wiseman
2026-12-01 16:45 ` Nhat Pham
2026-12-01 16:53 ` Yosry Ahmed
2026-12-02  0:46 ` Xueyuan Chen
2026-12-02  2:09 ` Sergey Senozhatsky [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=aw99Yd_HQpv42lbT@google.com \
    --to=senozhatsky@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=bgeffon@google.com \
    --cc=chengming.zhou@linux.dev \
    --cc=chriswiseman@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@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