From: Jenhao Chen <jenhaochen@google.com>
To: Sergey Senozhatsky <senozhatsky@chromium.org>,
Minchan Kim <minchan@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, Johannes Weiner <hannes@cmpxchg.org>,
Yosry Ahmed <yosry@kernel.org>, Nhat Pham <nphamcs@gmail.com>,
Chengming Zhou <chengming.zhou@linux.dev>,
Brian Geffon <bgeffon@google.com>,
minchan@google.com, liumartin@google.com, benwei@google.com
Subject: [PATCH v2 0/2] mm/zsmalloc: optimize zs_store() fast path
Date: Wed, 2 Dec 2026 04:39:09 +0000 [thread overview]
Message-ID: <20261202043911.2556266-1-jenhaochen@google.com> (raw)
This two-patch series optimizes the zs_store() fast path on top of the
stabilized zsmalloc changes in mm-new / next-20261201 (mm tree commit
5973b750e388):
1. Outline zs_store()'s new-zspage allocation path into a 6-arg noinline
zs_store_slow(), matching free_page_chain(). This keeps alloc_zspage()
and its zpdescs[] array off the fast path, enables sibling tail calls
on x86_64, and shrinks zs_store() by 19-73%.
2. Pass size_class and a payload struct obj_loc directly from obj_malloc()
to obj_write() and mark both __always_inline, eliminating the
location_to_obj() -> obj_to_location() / class->size * obj_idx /
ZsHugePage() round-trip and two out-of-line calls per store.
Cumulative results (base -> patch 2; 4K pages, chain size 8):
- arm64 Clang 22 -O2: -5.2% insns/pair, net .text +858 B
- arm64 Clang 22 AFDO: -6.4% insns/pair, zs_store -56%, net .text +930 B
- x86_64 Clang 22 -O2: -5.9% insns/pair, -6.0% pair / -7.3% zs_store()
cycles, -5.0% pool growth, net .text +430 B
- x86_64 Clang 22 AFDO: -6.9% insns/pair, -4.7% pair / -6.9% zs_store()
cycles, -4.3% pool growth, zs_store -45%, net .text +446 B
- x86_64 GCC 15 -O2: -4.1% insns/pair, zs_store() cycles neutral,
-3.1% pool growth, zs_store -56%, net .text +372 B
Verified byte-for-byte read-back via zs_obj_read_sg_begin()/end() across
1,024 regular objects (384..3136 B, including page-spanning slots) plus
4096 B huge objects, and clean builds across default, CONFIG_COMPACTION=n,
and CONFIG_DEBUG_VM=y.
Changes in v2:
- Rebased onto next-20261201 (Sergey's object alloc API redesign and
Wenchao's ZS_OBJ_CLASS_BITS lockless zs_free()).
- Split into 2 patches separating slow-path outlining from the payload
location handoff and inlining.
- Outlined the full slow path into a 6-arg noinline zs_store_slow()
instead of only marking alloc_zspage() noinline.
- Passed size_class and struct obj_loc directly to obj_write() instead of
relying on compiler CSE across lock calls.
- Dropped __always_inline on obj_free(): on next-20261201, Clang 22
already inlines obj_free(), while forcing it inline on GCC 15 spills
handle across _raw_spin_lock and regresses zs_free() (~+5 cycles).
- Added bloat-o-meter / net .text deltas and cold pool growth numbers.
- Link to v1: https://lore.kernel.org/r/20261030121700.260975-1-jenhaochen@google.com
Jenhao Chen (2):
mm/zsmalloc: outline slow path in zs_store()
mm/zsmalloc: pass payload location to obj_write()
mm/zsmalloc.c | 126 ++++++++++++++++++++++++++++++--------------------
1 file changed, 77 insertions(+), 49 deletions(-)
--
2.56.1.911.g883d8bcb20-goog
next reply other threads:[~2026-12-02 4:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 4:39 Jenhao Chen [this message]
2026-12-02 4:39 ` [PATCH v2 1/2] mm/zsmalloc: outline slow path in zs_store() Jenhao Chen
2026-12-02 4:39 ` [PATCH v2 2/2] mm/zsmalloc: pass payload location to obj_write() Jenhao Chen
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=20261202043911.2556266-1-jenhaochen@google.com \
--to=jenhaochen@google.com \
--cc=akpm@linux-foundation.org \
--cc=benwei@google.com \
--cc=bgeffon@google.com \
--cc=chengming.zhou@linux.dev \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liumartin@google.com \
--cc=llvm@lists.linux.dev \
--cc=minchan@google.com \
--cc=minchan@kernel.org \
--cc=nphamcs@gmail.com \
--cc=senozhatsky@chromium.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
all inboxes | Powered by JetHome®