From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Andrew Morton <akpm@linux-foundation.org>,
Wenchao Hao <haowenchao22@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Minchan Kim <minchan@kernel.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Nhat Pham <nphamcs@gmail.com>,
Joshua Hahn <joshua.hahnjy@gmail.com>,
Barry Song <baohua@kernel.org>,
Wenchao Hao <haowenchao@xiaomi.com>
Subject: Re: [PATCH v6 0/4] mm/zsmalloc: reduce lock contention in zs_free()
Date: Fri, 24 Jul 2026 13:55:26 +0900 [thread overview]
Message-ID: <amLm7ztljcJEN-9d@google.com> (raw)
In-Reply-To: <20260627213600.eb072ba84382807a8242efc9@linux-foundation.org>
Apologies for the delay.
On (26/06/27 21:36), Andrew Morton wrote:
[..]
> > Raspberry Pi 4B (4-core ARM64 Cortex-A72):
> >
> > mode Base Patched Speedup
> > single 59.0ms 56.0ms 1.05x
> > multi 2p 94.6ms 66.7ms 1.42x
> > multi 4p 202.9ms 110.6ms 1.83x
> >
> > x86 (20-core Intel i7-12700, 16 concurrent processes):
> >
> > mode Base Patched Speedup
> > single 11.7ms 9.8ms 1.19x
> > multi 2p 24.1ms 17.2ms 1.40x
> > multi 4p 63.0ms 45.3ms 1.39x
>
> Well that's a nice result.
Indeed.
> Sashiko AI review said .... nothing. I don't recall seeing that
> before ;)
grep-ing the code, I wonder if we maybe want to tweak some comments.
Namely, zs_page_migrate() says:
The pool migrate_lock protects the race between zpage migration
and zs_free
which is not entirely true anymore, as zs_free() has a lockless path
that doesn't take pool look (when ZS_OBJ_CLASS_BITS permit).
Likewise, __zs_compact() says the following about pool migrate_lock:
protect the race between zpage migration and zs_free
None of these are critical, very minor.
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Tested-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Unrelated to the series, no need to do anything. Just because I'm
looking at zs_page_migrate() at the moment, would something like
this make sense:
---
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 3d566a3ee96f..a6ca93ea1eb2 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1875,6 +1875,18 @@ static int zs_page_migrate(struct page *newpage, struct page *page,
* the class lock protects zpage alloc/free in the zspage.
*/
spin_lock(&class->lock);
+
+ /*
+ * Migrating an empty zspage is probably pointless as it's likely
+ * scheduled for a destruction anyway.
+ */
+ if (!get_zspage_inuse(zspage)) {
+ spin_unlock(&class->lock);
+ write_unlock(&pool->lock);
+ /* Same jusitification as below - we cannot return -EAGAIN. */
+ return -EBUSY;
+ }
+
/* the zspage write_lock protects zpage access via zs_obj_read/write() */
if (!zspage_write_trylock(zspage)) {
spin_unlock(&class->lock);
next prev parent reply other threads:[~2026-07-24 4:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 1:49 [PATCH v6 0/4] mm/zsmalloc: reduce lock contention in zs_free() Wenchao Hao
2026-06-26 1:50 ` [PATCH v6 1/4] mm/zsmalloc: encode class index in obj value for lockless class lookup Wenchao Hao
2026-06-26 1:50 ` [PATCH v6 2/4] mm/zsmalloc: drop pool->lock from zs_free on 64-bit systems Wenchao Hao
2026-06-30 2:50 ` Andrew Morton
2026-06-26 1:50 ` [PATCH v6 3/4] mm/zsmalloc: drop class lock before freeing zspage Wenchao Hao
2026-06-26 1:50 ` [PATCH v6 4/4] mm/zsmalloc: document free_zspage helper variants Wenchao Hao
2026-06-28 4:36 ` [PATCH v6 0/4] mm/zsmalloc: reduce lock contention in zs_free() Andrew Morton
2026-07-24 4:55 ` Sergey Senozhatsky [this message]
2026-07-07 7:18 ` 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=amLm7ztljcJEN-9d@google.com \
--to=senozhatsky@chromium.org \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=haowenchao22@gmail.com \
--cc=haowenchao@xiaomi.com \
--cc=joshua.hahnjy@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=nphamcs@gmail.com \
/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