Re: [PATCH v3 4/4] mm/zsmalloc: document free_zspage helper variants
From: Wenchao Hao
Date: Tue Jun 09 2026 - 07:36:35 EST
On Sat, Jun 6, 2026 at 12:35 AM Nhat Pham <nphamcs@xxxxxxxxx> wrote:
>
> On Fri, Jun 5, 2026 at 1:43 AM Wenchao Hao <haowenchao22@xxxxxxxxx> wrote:
> >
> > From: Wenchao Hao <haowenchao@xxxxxxxxxx>
> >
> > 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@xxxxxxxxx>
> > Signed-off-by: Wenchao Hao <haowenchao@xxxxxxxxxx>
>
> I think it LGTM, but I'll let the zsmalloc maintainers have their say :)
>
> Feel free to add:
> Reviewed-by: Nhat Pham <nphamcs@xxxxxxxxx>
>
>
>
> > ---
> > 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().
>
> nit: maybe a short note on when async_free_zspage is needed?
>
> (IIUC, only when trylock_zspage() fails in zs_free(), correct?)
>
Thanks Nhat. Yes, that's exactly it. In v4 the comment now reads:
__free_zspage(): __free_zspage_lockless() + per-class accounting,
under class->lock. Used by async_free_zspage(), the worker for
zspages whose trylock_zspage() failed.
Your Reviewed-by is picked up. Note that 1/4 and 2/4 have non-trivial
rework in v4 in response to the sashiko AI review, so I dropped your
R-b on those two patches -- a re-review would be appreciated.
Wenchao