Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Yosry Ahmed and committed by
Andrew Morton
19c4707b 0be909f1

+2 -7
+2 -7
mm/zsmalloc.c
··· 1088 1088 off = offset_in_page(class->size * obj_idx); 1089 1089 1090 1090 if (!ZsHugePage(zspage)) 1091 - mem_len += ZS_HANDLE_SIZE; 1091 + off += ZS_HANDLE_SIZE; 1092 1092 1093 1093 if (off + mem_len <= PAGE_SIZE) { 1094 1094 /* this object is contained entirely within a page */ ··· 1110 1110 0, sizes[1]); 1111 1111 } 1112 1112 1113 - if (!ZsHugePage(zspage)) 1114 - addr += ZS_HANDLE_SIZE; 1115 - 1116 1113 return addr; 1117 1114 } 1118 1115 EXPORT_SYMBOL_GPL(zs_obj_read_begin); ··· 1130 1133 off = offset_in_page(class->size * obj_idx); 1131 1134 1132 1135 if (!ZsHugePage(zspage)) 1133 - mem_len += ZS_HANDLE_SIZE; 1136 + off += ZS_HANDLE_SIZE; 1134 1137 1135 1138 if (off + mem_len <= PAGE_SIZE) { 1136 - if (!ZsHugePage(zspage)) 1137 - off += ZS_HANDLE_SIZE; 1138 1139 handle_mem -= off; 1139 1140 kunmap_local(handle_mem); 1140 1141 }