[PATCH 0/7] zsmalloc: redesign object alloc API

From: Sergey Senozhatsky

Date: Wed Nov 04 2026 - 23:54:24 EST


Both zram and zswap already have per-entry structures that store zsmalloc
handles, so allocating a separate handle_cachep object per stored page is
redundant. This series embeds struct zs_handle directly into zram and
zswap entries and drops handle_cachep, saving 8 bytes and a slab
alloc/free per stored object (2MB per 1GB of swapped out 4K pages).

It also folds zs_malloc() and zs_obj_write() into zs_store() so we don't
take pool->lock and look up object location again right after allocation.

A simple zram test on a 24-vCPU VM
==================================
165 fewer kernel instructions and 0.7-1.8% fewer kernel cycles per write;
lz4 single writer +2.3% IOPS / -2.6% average latency;
24 writers +0.9-+1.0% IOPS; no regressions.
Memory: 8 bytes less per stored page.

Sergey Senozhatsky (7):
zram: drop stale comment in write_incompressible_page()
zram: drop get_slot_handle() and set_slot_handle()
zsmalloc: switch handle type to struct zs_handle
zram: allocate zsmalloc object under slot lock
zsmalloc: embed struct zs_handle into zram and zswap entries
zsmalloc: fold zs_obj_write() into zs_store()
zsmalloc: constify struct zs_handle pointer in read-only functions

Documentation/admin-guide/mm/slab.rst | 2 +-
Documentation/core-api/memory-allocation.rst | 2 +-
Documentation/mm/zsmalloc.rst | 8 +-
drivers/block/zram/Kconfig | 1 +
drivers/block/zram/zram_drv.c | 130 +++++-------
drivers/block/zram/zram_drv.h | 10 +-
include/linux/zsmalloc.h | 37 +++-
mm/Kconfig | 3 +
mm/zsmalloc.c | 204 +++++++++++--------
mm/zswap.c | 21 +-
10 files changed, 229 insertions(+), 189 deletions(-)

--
2.56.0.398.g882cbad275-goog