Re: [PATCH v2 10/11] zsmalloc: fold zs_obj_write() into zs_store()

From: Yosry Ahmed

Date: Tue Nov 10 2026 - 12:23:29 EST


On Tue, Nov 10, 2026 at 02:48:15PM +0900, Sergey Senozhatsky wrote:
> zram and zswap always call zs_obj_write() right after zs_malloc(), and
> zs_obj_write() has to take pool->lock and look up object location
> again, which zs_malloc() just did.
>
> Replace zs_malloc() and zs_obj_write() with one single zs_store()
> call.
>
> zs_store() takes zspage read lock under class->lock, before it drops
> class->lock to copy the data, while zs_obj_write() used to take it
> under pool->lock. Compaction and page migration already take zspage
> lock under class->lock, so this follows the existing pool->lock ->
> class->lock -> zspage->lock order. We don't need pool->lock there,
> zs_store() doesn't look up the object via the handle, it already has
> the zspage from the allocation.
>
> Signed-off-by: Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx>
> ---
> Documentation/core-api/memory-allocation.rst | 2 +-
> Documentation/mm/zsmalloc.rst | 4 +-
> drivers/block/zram/zram_drv.c | 42 +++++---------
> include/linux/zsmalloc.h | 6 +-
> mm/zsmalloc.c | 58 +++++++++-----------
> mm/zswap.c | 5 +-
> 6 files changed, 47 insertions(+), 70 deletions(-)

zswap and zsmalloc bits LGTM:

Reviewed-by: Yosry Ahmed <yosry@xxxxxxxxxx>