Re: [RFC PATCH 0/2] mm: zsmalloc: make shrinker compaction budget-aware
From: Sergey Senozhatsky
Date: Wed Oct 28 2026 - 21:49:19 EST
On (26/10/29 10:43), Sergey Senozhatsky wrote:
[..]
> > Hmm we'd need to collect more data in our workloads to determine, but
> > if we can compute compactable ratio (freeable_pages / total_pages) on
> > a per size class basis, can we just skip the size class whose ratio is
> > too bad? Would that at least cut down on the vast majority of
> > fruitless memcpys and lock acquisitions etc?
> >
> > I'm always a bit hesitant to over-rely on userspace, especially when
> > kernel has information to do something smart about it. It might not
> > react in time, and many proactive reclaiming schemes back off under
> > heavy memory pressure.
>
> Apologies for the delay.
>
> The thing about shrinker compaction is that it's sort of on the
> wrong end. It doesn't trigger compaction when memory is plentiful,
> no matter the internal fragmentation rate, and start firing compaction
> scans when memory pressure hits. The problem with this is that, now
> compaction moves objects (if can compact zspages) and releases empty
> zspages, in parallel with potentially heavy swapping out activities,
> which can simply allocate those released pages back. Which seems like
> a useless exercise and needless memcpy-s. So I was thinking about
> either putting it under config or just removing it (this might be a
> harder decision).
In embedded (android/bookOS/etc.) there is a daemon, that triggers
various zram activities. We can wire in pool-compaction (once under
memory pressure), which is a zram sysfs device attribute, instead
of pondering zsmalloc with scan callbacks.