Re: [PATCH] mm/zsmalloc: remove shrinker
From: Sergey Senozhatsky
Date: Thu Dec 03 2026 - 01:17:49 EST
Hi Barry,
On (26/12/03 13:10), Barry Song wrote:
> > static void __init zs_stat_init(void)
> > @@ -1461,6 +1471,7 @@ void zs_free(struct zs_pool *pool, struct zs_handle *handle)
> > struct size_class *class;
> > int fullness;
> > struct zspage *zspage_to_free = NULL;
> > + bool kick_compact = false;
> >
> > if (!zs_handle_is_allocated(handle))
> > return;
> > @@ -1481,6 +1492,10 @@ void zs_free(struct zs_pool *pool, struct zs_handle *handle)
> > } else {
> > kick_deferred_free(pool);
> > }
> > + } else if (READ_ONCE(pool->compact_threshold) &&
> > + !delayed_work_pending(&pool->compact_work) &&
> > + zs_class_can_compact(class)) {
> > + kick_compact = true;
> > }
> >
> > spin_unlock(&class->lock);
> > @@ -1488,6 +1503,8 @@ void zs_free(struct zs_pool *pool, struct zs_handle *handle)
> > if (zspage_to_free) {
> > __free_zspage_lockless(zspage_to_free);
> > atomic_long_sub(class->pages_per_zspage, &pool->pages_allocated);
> > + } else if (kick_compact) {
> > + kick_deferred_compact(pool);
> > }
> > }
>
> Hi Sergey,
>
> Thanks very much for the quick patch! I'm always amazed by how
> quickly you come up with patches :-)
:)
> For both zram and zsmalloc deferred compaction, the kick is currently
> in the free path (zs_free() or slot_free()). I wonder whether we
> also need to kick compaction from the allocation path.
So allocation path doesn't create fragmentation. It adds a new zspage,
but only if other class zspages are full. And that new zspage with one
active element is the worst case, but there is nothing to compact: we
have all full zspages and one nearly empty zspage. Am I missing the
point you are trying to make?