Re: [PATCH] mm/zsmalloc: remove shrinker

From: Barry Song

Date: Wed Dec 02 2026 - 22:24:37 EST


On Thu, Dec 3, 2026 at 11:08 AM Sergey Senozhatsky
<senozhatsky@xxxxxxxxxxxx> wrote:
>
> Hi Barry,
>
> On (26/12/02 18:21), Barry Song wrote:
> > > > Hi Chris, Xueyuan and all,
> > > >
> > > > Thanks for the patch and the report. Just curious, do we need
> > > > userspace-triggered proactive compaction
> > >
> > > Wouldn't hurt to keep it around, I guess. But maybe can NOOP it
> > > in the future (removing zram device attributes is a bit difficult,
> > > we usually give around 3-5 years of deprecation cooldown period
> > > before removal.)
> >
> > Hi Sergey,
> >
> > Thanks for your reply. Sorry, I might not have expressed my question
> > clearly. Here is what I meant:
>
> Oh, my bad!
>
> > We used to have automatic compaction through the shrinker. Now that
> > we have removed it, do we still expect compaction to be triggered,
> > either automatically or manually by writing to the zram sysfs
> > attribute?
> >
> > I know the changelog already says:
> >
> > " Testing on ARM64 QEMU shows that removing the shrinker eliminates
> > mid-swap compaction churn without increasing active pool memory
> > usage for either zram or zswap."
> >
> > But what about periods when swap-out is not active? Would compaction
> > still be beneficial in those cases?
>
> I suppose compaction will be beneficial after a huge app swap-in, e.g.
> bringing back a web browser with (usual) million tabs. Or after a huge
> app kill/termination, if the app had swap presence. Both of these
> release memory from zsmalloc and create fragmentation, so we might
> benefit from doing a de-fragmentation.

Right. I had Nanzhe(Cc-ed) test this patch on Pixel 6 phones by repeatedly
launching apps in a loop. We observed some negative results with
this patch in the absence of proactive compaction.

Nanzhe collected the time series of (mem_used_total - compr_data_size).
Without the patch, the median was 32 MB. With the patch, it increased
to 182 MB, peaking at 622 MB.

The median memory overhead due to fragmentation increased from
2.5% without the patch to 16.87% with the patch.

So it seems that while mid-swap compaction is undesirable from a
performance perspective, it does help reduce the memory footprint
on phones.

I agree that once we remove mid-swap compaction, we should trigger
compaction from userspace, either after killing some apps or after
proactive swap-out.

Thanks,
Barry