Re: [PATCH v4 1/4] mm/zsmalloc: encode class index in obj value for lockless class lookup
From: Wenchao Hao
Date: Wed Jun 10 2026 - 23:15:57 EST
On Thu, Jun 11, 2026 at 5:28 AM Barry Song <baohua@xxxxxxxxxx> wrote:
>
> On Wed, Jun 10, 2026 at 11:18 AM Wenchao Hao <haowenchao22@xxxxxxxxx> wrote:
> [...]
> >
> > The "_LOG2" suffix names the math but hides the intent. How about
> > renaming them as:
> >
> > ZS_CHAIN_LOG2 -> ZS_MAX_BITS_PAGES_PER_ZSPAGE
> > ZS_MAX_OBJ_PER_PAGE_LOG2 -> ZS_MAX_BITS_OBJS_PER_PAGE
> > ZS_OBJ_IDX_DENSE_BITS -> ZS_MAX_BITS_OBJS_PER_ZSPAGE
> >
>
> Do we need MAX_ while everybody just uses _BITS? e.g.
>
> #if defined(MAX_POSSIBLE_PHYSMEM_BITS)
> #define SWAP_CACHE_PFN_BITS (MAX_POSSIBLE_PHYSMEM_BITS - PAGE_SHIFT)
> #elif defined(MAX_PHYSMEM_BITS)
> #define SWAP_CACHE_PFN_BITS (MAX_PHYSMEM_BITS - PAGE_SHIFT)
> #else
> #define SWAP_CACHE_PFN_BITS (BITS_PER_LONG - PAGE_SHIFT)
> #endif
>
Agreed, will follow the convention and drop MAX_:
ZS_CHAIN_LOG2 -> ZS_PAGES_PER_ZSPAGE_BITS
ZS_MAX_OBJ_PER_PAGE_LOG2 -> ZS_OBJS_PER_PAGE_BITS
ZS_OBJ_IDX_DENSE_BITS -> ZS_OBJS_PER_ZSPAGE_BITS
Nhat -- sorry for the churn; this supersedes the names I proposed
earlier. Let me know if the new naming still reads well to you.
Wenchao
> Best Regards
> Barry