Re: [PATCHv2 1/2] zsmalloc: use actual object size to detect spans
From: Nhat Pham
Date: Tue Jan 13 2026 - 23:18:10 EST
On Wed, Jan 7, 2026 at 2:24 PM Sergey Senozhatsky
<senozhatsky@xxxxxxxxxxxx> wrote:
>
> Using class->size to detect spanning objects is not entirely correct,
> because some size classes can hold a range of object sizes of up to
> class->size bytes in length, due to size-classes merge. Such classes
> use padding for cases when actually written objects are smaller than
> class->size. zs_obj_read_begin() can incorrectly hit the slow path
> and perform memcpy of such objects, basically copying padding bytes.
> Instead of class->size zs_obj_read_begin() should use the actual
> compressed object length (both zram and zswap know it) so that it can
> correctly handle situations when a written object is small enough to
> fit into the first physical page.
>
> Signed-off-by: Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx>
> ---
>
LGTM!
Reviewed-by: Nhat Pham <nphamcs@xxxxxxxxx>