Re: [PATCH] mm/zsmalloc: keep fullness stats consistent with CONFIG_ZSMALLOC_STAT
From: Xueyuan Chen
Date: Sat Nov 07 2026 - 21:54:08 EST
On 2026-11-06 09:34 -0700, Nhat Pham wrote:
> On Fri, Nov 6, 2026 at 2:56 AM Xueyuan Chen <xueyuan.chen21@xxxxxxxxx> wrote:
> >
> > The fullness-group counters are only used by the debugfs classes report,
> > which is enabled by CONFIG_ZSMALLOC_STAT. However, these counters are
> > stored and updated even when the option is disabled.
> >
> > Make the counter storage and updates conditional on CONFIG_ZSMALLOC_STAT.
> > Keep ZS_OBJS_ALLOCATED and ZS_OBJS_INUSE, since zs_can_compact()
> > still needs these counters.
> >
> > The behavior with CONFIG_ZSMALLOC_STAT=y remains unchanged.
>
Hi Nhat,
> Do we need CONFIG_ZSMALLOC_STAT in the first place? Is the overhead that high?
Good idea, thanks. CONFIG_ZSMALLOC_STAT only controls the debugfs
interface; the counters are updated either way.
In my zram tests without readers, fullness counter updates changed CPU
time by less than 0.1%. Reading the stats adds overhead that depends on
the polling frequency.
Dropping CONFIG_ZSMALLOC_STAT seems simpler.
>
> Also we already have a #ifdef CONFIG_ZSMALLOC_STAT section. Can we
> just move these helpers inside it, and provide no-op skeletons in
> !CONFIG_ZSMALLOC_STAT case?
>
> And if we're going to have CONFIG_ZSMALLOC_STAT, anything else can we
> wrap in CONFIG_ZSMALLOC_STAT? stat field of struct size_class? struct
> zs_size_stat's definition?
>
>