]> git.ipfire.org Git - thirdparty/linux.git/commit
zsmalloc: simplify read begin/end logic
authorYosry Ahmed <yosry.ahmed@linux.dev>
Wed, 7 Jan 2026 05:21:45 +0000 (14:21 +0900)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 27 Jan 2026 04:02:26 +0000 (20:02 -0800)
commit19c4707b535a31dc8a6009afc249f36db7011ac3
tree6e9974b0e5b47cd46a34f64cb50f1f5dffaa891d
parent0be909f114c4e82a4fe5964851af1ab8889dc76c
zsmalloc: simplify read begin/end logic

zs_obj_read_begin() currently maps or copies the compressed object with
the prefix handle for !ZsHugePage case.  Make the logic clearer and
more efficient by moving the offset of the object in the page after the
prefix handle instead, only copying the actual object and avoiding the
need to adjust the returned address to account for the prefix.

Adjust the logic to detect spanning objects in zs_obj_read_end()
accordingly, slightly simplifying it by avoiding the need to account
for the handle in both the offset and the object size.

Link: https://lkml.kernel.org/r/20260107052145.3586917-2-senozhatsky@chromium.org
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Co-developed-by: Yosry Ahmed <yosry.ahmed@linux.dev>
Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
Cc: Brian Geffon <bgeffon@google.com>
Cc: Chengming Zhou <chengming.zhou@linux.dev>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Nhat Pham <nphamcs@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/zsmalloc.c