From: Wenchao Hao <haowenchao22@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Minchan Kim <minchan@kernel.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Nhat Pham <nphamcs@gmail.com>,
Joshua Hahn <joshua.hahnjy@gmail.com>,
Barry Song <baohua@kernel.org>,
Wenchao Hao <haowenchao@xiaomi.com>
Subject: [PATCH v3 4/4] mm/zsmalloc: document free_zspage helper variants
Date: Fri, 5 Jun 2026 16:42:42 +0800 [thread overview]
Message-ID: <20260605084242.1549811-5-haowenchao22@gmail.com> (raw)
In-Reply-To: <20260605084242.1549811-1-haowenchao22@gmail.com>
From: Wenchao Hao <haowenchao@xiaomi.com>
After splitting __free_zspage() into a lockless core and a wrapper that
does the class-stat bookkeeping, three similarly-named helpers coexist:
free_zspage / __free_zspage / __free_zspage_lockless.
Add a comment block above them describing what each does and where it
is used, so the names are not easy to confuse.
No functional change.
Suggested-by: Nhat Pham <nphamcs@gmail.com>
Signed-off-by: Wenchao Hao <haowenchao@xiaomi.com>
---
mm/zsmalloc.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 2ecdf79cea03..9f588b63ec0d 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -856,6 +856,21 @@ static int trylock_zspage(struct zspage *zspage)
return 0;
}
+/*
+ * Three free helpers, kept apart here:
+ *
+ * __free_zspage_lockless(): bare core; walks zpdescs and returns pages
+ * to the buddy allocator. Caller owns all zpdesc locks and has
+ * removed the zspage from its class list. Used by zs_free() outside
+ * class->lock so the buddy-side work does not stall the class.
+ *
+ * __free_zspage(): __free_zspage_lockless() + per-class accounting,
+ * under class->lock. Used by async_free_zspage().
+ *
+ * free_zspage(): full wrapper - trylock zpdescs, remove from class
+ * list, call __free_zspage(); kicks deferred free on contention.
+ * Used by compaction.
+ */
static inline void __free_zspage_lockless(struct zs_pool *pool, struct zspage *zspage)
{
struct zpdesc *zpdesc, *next;
--
2.34.1
next prev parent reply other threads:[~2026-06-05 8:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-05 8:42 [PATCH v3 0/4] mm/zsmalloc: reduce lock contention in zs_free() Wenchao Hao
2026-06-05 8:42 ` [PATCH v3 1/4] mm/zsmalloc: encode class index in obj value for lockless class lookup Wenchao Hao
2026-06-05 8:42 ` [PATCH v3 2/4] mm/zsmalloc: drop pool->lock from zs_free on 64-bit systems Wenchao Hao
2026-06-05 8:42 ` [PATCH v3 3/4] mm/zsmalloc: drop class lock before freeing zspage Wenchao Hao
2026-06-05 8:42 ` Wenchao Hao [this message]
2026-06-05 16:34 ` [PATCH v3 4/4] mm/zsmalloc: document free_zspage helper variants Nhat Pham
2026-06-09 11:31 ` Wenchao Hao
2026-06-06 1:19 ` [PATCH v3 0/4] mm/zsmalloc: reduce lock contention in zs_free() Andrew Morton
2026-06-09 11:27 ` Wenchao Hao
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=20260605084242.1549811-5-haowenchao22@gmail.com \
--to=haowenchao22@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--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
all inboxes | Powered by JetHome®