mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 00/11] zsmalloc: redesign object alloc API
@ 2026-11-10  5:48 Sergey Senozhatsky
  2026-11-10  5:48 ` [PATCH v2 01/11] zram: drop stale comment in write_incompressible_page() Sergey Senozhatsky
                   ` (11 more replies)
  0 siblings, 12 replies; 20+ messages in thread
From: Sergey Senozhatsky @ 2026-11-10  5:48 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Nhat Pham, Yosry Ahmed, Johannes Weiner, Brian Geffon,
	Minchan Kim, Richard Chang, linux-kernel, linux-block, linux-mm,
	Sergey Senozhatsky

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.

v1 -> v2:
-- addressed Yosry's v1 feedback (too lengthy to mention here, Yosry
   posted over a million comments, or something very close to that):
   split-ed some patches, squashed the other ones, added handle
   alignment run-time check, added 0 PFN defense, etc.

Sergey Senozhatsky (11):
  zram: drop stale comment in write_incompressible_page()
  zram: drop get_slot_handle() and set_slot_handle()
  zsmalloc: return handle from obj_allocated()
  zsmalloc: switch handle type to struct zs_handle
  zram: check mem_limit before allocating zsmalloc object
  zram: allocate zsmalloc object under slot lock
  zswap: do not free the entry if its pool is NULL
  zsmalloc: encode 1-based obj_idx so valid obj is never 0
  zsmalloc: embed struct zs_handle into zram and zswap entries
  zsmalloc: fold zs_obj_write() into zs_store()
  zsmalloc: populate new zspage outside class->lock in zs_store()

 Documentation/admin-guide/blockdev/zram.rst  |   4 +-
 Documentation/admin-guide/mm/slab.rst        |   2 +-
 Documentation/core-api/memory-allocation.rst |   2 +-
 Documentation/mm/zsmalloc.rst                |  22 +-
 drivers/block/zram/zram_drv.c                | 146 ++++------
 drivers/block/zram/zram_drv.h                |  10 +-
 include/linux/zsmalloc.h                     |  36 ++-
 mm/zsmalloc.c                                | 285 +++++++++++--------
 mm/zswap.c                                   |  28 +-
 9 files changed, 293 insertions(+), 242 deletions(-)

-- 
2.56.0.506.g506a7eabc5-goog


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2026-11-10 17:03 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-10  5:48 [PATCH v2 00/11] zsmalloc: redesign object alloc API Sergey Senozhatsky
2026-11-10  5:48 ` [PATCH v2 01/11] zram: drop stale comment in write_incompressible_page() Sergey Senozhatsky
2026-11-10  5:48 ` [PATCH v2 02/11] zram: drop get_slot_handle() and set_slot_handle() Sergey Senozhatsky
2026-11-10  5:48 ` [PATCH v2 03/11] zsmalloc: return handle from obj_allocated() Sergey Senozhatsky
2026-11-10 16:28   ` Yosry Ahmed
2026-11-10  5:48 ` [PATCH v2 04/11] zsmalloc: switch handle type to struct zs_handle Sergey Senozhatsky
2026-11-10 16:35   ` Yosry Ahmed
2026-11-10  5:48 ` [PATCH v2 05/11] zram: check mem_limit before allocating zsmalloc object Sergey Senozhatsky
2026-11-10  5:48 ` [PATCH v2 06/11] zram: allocate zsmalloc object under slot lock Sergey Senozhatsky
2026-11-10  5:48 ` [PATCH v2 07/11] zswap: do not free the entry if its pool is NULL Sergey Senozhatsky
2026-11-10 16:37   ` Yosry Ahmed
2026-11-10  5:48 ` [PATCH v2 08/11] zsmalloc: encode 1-based obj_idx so valid obj is never 0 Sergey Senozhatsky
2026-11-10 16:44   ` Yosry Ahmed
2026-11-10  5:48 ` [PATCH v2 09/11] zsmalloc: embed struct zs_handle into zram and zswap entries Sergey Senozhatsky
2026-11-10 16:57   ` Yosry Ahmed
2026-11-10  5:48 ` [PATCH v2 10/11] zsmalloc: fold zs_obj_write() into zs_store() Sergey Senozhatsky
2026-11-10 17:00   ` Yosry Ahmed
2026-11-10  5:48 ` [PATCH v2 11/11] zsmalloc: populate new zspage outside class->lock in zs_store() Sergey Senozhatsky
2026-11-10 17:03   ` Yosry Ahmed
2026-11-10 16:16 ` [PATCH v2 00/11] zsmalloc: redesign object alloc API Yosry Ahmed

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®