From: Hongfeng Chen <chenhongfeng0212@gmail.com>
To: Nhat Pham <nphamcs@gmail.com>
Cc: Hongfeng Chen <chenhongfeng0212@163.com>,
Andrew Morton <akpm@linux-foundation.org>,
Barry Song <baohua@kernel.org>,
Chengming Zhou <chengming.zhou@linux.dev>,
Jens Axboe <axboe@kernel.dk>,
Johannes Weiner <hannes@cmpxchg.org>,
Minchan Kim <minchan@kernel.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Shakeel Butt <shakeel.butt@linux.dev>,
Yosry Ahmed <yosry@kernel.org>,
Wenchao Hao <haowenchao@xiaomi.com>,
Wenchao Hao <haowenchao22@gmail.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-block@vger.kernel.org,
Hongfeng Chen <hongfengchen@xiaomi.com>,
Hongfeng Chen <chenhongfeng0212@gmail.com>
Subject: Re: [RFC PATCH v4 0/2] mm/zsmalloc: defer object free to per-cpu batches
Date: Mon, 9 Nov 2026 18:59:55 +0800 [thread overview]
Message-ID: <20261109105957.2577351-1-chenhongfeng0212@gmail.com> (raw)
In-Reply-To: <CAKEwX=M4jTnxmq6cj115Gw4u5jdY7Ex65jPtVTEopW70jGzfuQ@mail.gmail.com>
From: Hongfeng Chen <chenhongfeng0212@163.com>
On Fri, Oct 23, 2026 at 11:19 AM Nhat Pham <nphamcs@gmail.com> wrote:
> Is there any more juice we can squeeze from zsmalloc in that case?
>
> It would be nice if you can perf zsmalloc freeing. And yeah, maybe we
> can't optimize any further, but let's eliminate that first before we
> rely on offloading.
Here is the perf breakdown of the free path:
zram:
__swap_cluster_free_entries 90.28%
zram_slot_free_notify 86.01%
slot_free 74.15%
zs_free 56.01%
__free_frozen_pages 19.85%
kmem_cache_free 10.15%
_raw_spin_lock 5.53%
fix_fullness_group 3.31%
dec_zone_page_state 2.43%
obj_free 2.17%
trylock_zspage 2.12%
zswap:
__swap_cluster_free_entries 94.30%
zswap_invalidate 93.49%
zswap_entry_free 73.76%
zs_free 34.03%
__free_frozen_pages 11.13%
kmem_cache_free 5.57%
fix_fullness_group 2.66%
_raw_spin_lock 2.45%
trylock_zspage 1.75%
dec_zone_page_state 1.67%
obj_free 0.96%
obj_cgroup_uncharge_zswap 13.90%
list_lru_del 11.73%
kmem_cache_free 4.62%
xa_erase 19.27%
Most of zs_free() is returning memory: empty zspages, handles and
zspage slab objects. So returning memory cannot be avoided, it can
only be batched or deferred.
In zram, zs_free() is 56% of the time, so deferring only zs_free()
can speed up munmap() by at most about 2.3x. In zswap, zs_free() is
34% of the time, so the speed up limit is about 1.5x.
That leaves two places to go further.
1. Async freeing at or above __swap_cluster_free_entries()
Deferring at or above __swap_cluster_free_entries() covers zram and
zswap with one mechanism.
2. Optimizing zram alone
For zram I would rather go back to v1 [1], which defers in zram. v1
also uses a single gc_work per device to offer a best-effort service,
which greatly reduces the impact of the unbound worker on other
tenants.
[1] https://lore.kernel.org/linux-mm/20260412060450.15813-1-baohua@kernel.org/
Thanks,
Hongfeng
next prev parent reply other threads:[~2026-11-09 11:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 12:09 Hongfeng Chen
2026-10-16 12:09 ` [RFC PATCH v4 1/2] mm/zsmalloc: defer object free to per-cpu batches and a drain worker Hongfeng Chen
2026-10-16 16:09 ` [RFC PATCH v4 0/2] mm/zsmalloc: defer object free to per-cpu batches Nhat Pham
2026-10-22 2:55 ` Sergey Senozhatsky
2026-10-23 12:37 ` Hongfeng Chen
2026-10-23 18:19 ` Nhat Pham
2026-11-09 10:59 ` Hongfeng Chen [this message]
2026-10-17 3:15 ` [RFC PATCH v4 2/2] zram: keep the hot statistics per cpu Hongfeng 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=20261109105957.2577351-1-chenhongfeng0212@gmail.com \
--to=chenhongfeng0212@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=baohua@kernel.org \
--cc=chengming.zhou@linux.dev \
--cc=chenhongfeng0212@163.com \
--cc=hannes@cmpxchg.org \
--cc=haowenchao22@gmail.com \
--cc=haowenchao@xiaomi.com \
--cc=hongfengchen@xiaomi.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=nphamcs@gmail.com \
--cc=senozhatsky@chromium.org \
--cc=shakeel.butt@linux.dev \
--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®