Re: [PATCH] mm/zsmalloc: inline obj_malloc() and obj_free()
From: Sergey Senozhatsky
Date: Thu Nov 05 2026 - 00:26:16 EST
On (26/10/30 12:17), Jenhao Chen wrote:
> In zs_malloc(), the fast path (if (likely(zspage))) allocates from an
> existing zspage via obj_malloc(), while the slow path allocates a new
> zspage via alloc_zspage().
>
> Because obj_malloc() has three call sites across zs_malloc() and
> migrate_zspage(), Clang at -O2 leaves obj_malloc() out-of-line, adding a
> function call on every fast-path allocation. Conversely, because the
> 362-instruction slow-path alloc_zspage() is static with a single caller,
> single-caller inlining under CONFIG_AUTOFDO_CLANG (e.g. with
> CONFIG_ZSMALLOC=m) inlines alloc_zspage() into zs_malloc(), growing it
> from 254 to 691 instructions.
>
> Mark obj_malloc() and obj_free() __always_inline and mark alloc_zspage()
> noinline to keep the fast path inline and the slow-path page allocation
> out-of-line.
I suppose there is performance benefit?
I guess I don't mind in principle, one thing to note is that this conflicts
with [1].
[1] https://lore.kernel.org/linux-kernel/20261105044752.1997895-1-senozhatsky@xxxxxxxxxxxx