From 0abea609f37e984647f9a2af95eb6256c3227b7a Mon Sep 17 00:00:00 2001 From: Wenchao Hao Date: Fri, 26 Jun 2026 09:50:03 +0800 Subject: [PATCH] mm/zsmalloc: document free_zspage helper variants 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. Link: https://lore.kernel.org/20260626015003.2965881-5-haowenchao22@gmail.com Signed-off-by: Wenchao Hao Suggested-by: Nhat Pham Reviewed-by: Nhat Pham Reviewed-by: Barry Song Cc: Joshua Hahn Cc: Minchan Kim Cc: Sergey Senozhatsky Cc: Xueyuan Chen Signed-off-by: Andrew Morton --- mm/zsmalloc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 6d3ed196f6f9..b5eadee0e8f0 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -877,6 +877,22 @@ 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(), the worker for + * zspages whose trylock_zspage() failed. + * + * 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 zspage *zspage) { struct zpdesc *zpdesc, *next;