Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Barry Song (Xiaomi)" <baohua@kernel.org>
To: senozhatsky@chromium.org
Cc: akpm@linux-foundation.org, baohua@kernel.org,
	haowenchao22@gmail.com, haowenchao@xiaomi.com,
	joshua.hahnjy@gmail.com, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, minchan@kernel.org, nphamcs@gmail.com
Subject: Re: [PATCH v6 0/4] mm/zsmalloc: reduce lock contention in zs_free()
Date: Sat, 25 Jul 2026 11:57:33 +0800	[thread overview]
Message-ID: <20260725035733.53241-1-baohua@kernel.org> (raw)
In-Reply-To: <akynv_js-5G88rGd@google.com>

On Fri, Jul 24, 2026 at 12:55 PM Sergey Senozhatsky <senozhatsky@chromium.org> wrote:
>
> 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.

Does it look good to you if we squash the below change into patch2/4:

From 49091bd19445c8927ae063042bc7394e7cc359c0 Mon Sep 17 00:00:00 2001
From: "Barry Song (Xiaomi)" <baohua@kernel.org>
Date: Sat, 25 Jul 2026 11:45:09 +0800
Subject: [PATCH] mm: zsmalloc: update the comment about pool lock

Update the comment to reflect that `zs_free()` can be lockless when
`ZS_OBJ_CLASS_BITS` applies.

Suggested-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Barry Song (Xiaomi) <baohua@kernel.org>
---
 mm/zsmalloc.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 3d566a3ee96f..b5eadee0e8f0 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1865,8 +1865,8 @@ static int zs_page_migrate(struct page *newpage, struct page *page,
 	pool = zspage->pool;
 
 	/*
-	 * The pool migrate_lock protects the race between zpage migration
-	 * and zs_free.
+	 * The pool migrate_lock protects against races between zpage migration
+	 * and zs_free(), but only when ZS_OBJ_CLASS_BITS does not apply.
 	 */
 	write_lock(&pool->lock);
 	class = zspage_class(pool, zspage);
@@ -2045,8 +2045,9 @@ static unsigned long __zs_compact(struct zs_pool *pool,
 	unsigned long pages_freed = 0;
 
 	/*
-	 * protect the race between zpage migration and zs_free
-	 * as well as zpage allocation/free
+	 * Protect against races between zpage migration and zs_free()
+	 * (only when ZS_OBJ_CLASS_BITS does not apply), as well as
+	 * zpage allocation and free.
 	 */
 	write_lock(&pool->lock);
 	spin_lock(&class->lock);
-- 
2.39.3 (Apple Git-146)



  reply	other threads:[~2026-07-25  3:57 UTC|newest]

Thread overview: 11+ 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
2026-07-07  7:18 ` Sergey Senozhatsky
2026-07-25  3:57   ` Barry Song (Xiaomi) [this message]
2026-07-25  5:30     ` 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=20260725035733.53241-1-baohua@kernel.org \
    --to=baohua@kernel.org \
    --cc=akpm@linux-foundation.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 \
    --cc=senozhatsky@chromium.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