Re: [RFC PATCH] zsmalloc: make common caches global

From: Sergey Senozhatsky

Date: Fri Jan 16 2026 - 21:24:09 EST


On (26/01/16 20:49), Yosry Ahmed wrote:
> On Fri, Jan 16, 2026 at 01:48:41PM +0900, Sergey Senozhatsky wrote:
> > Currently, zsmalloc creates kmem_cache of handles and zspages
> > for each pool, which may be suboptimal from the memory usage
> > point of view (extra internal fragmentation per pool). Systems
> > that create multiple zsmalloc pools may benefit from shared
> > common zsmalloc caches.
>
> I had a similar patch internally when we had 32 zsmalloc pools with
> zswap.

Oh, nice.

> You can calculate the savings by using /proc/slabinfo. The unused memory
> is (num_objs-active_objs)*objsize. You can sum this across all caches
> when you have multiple pools, and compare it to the unused memory with a
> single cache.

Right. Just curious, do you recall any numbers?

[..]
> Hmm instead of the repeated kmem_cache_destroy() calls, can we do sth
> like this:

Sure.