Re: [PATCHv2 2/2] zsmalloc: simplify read begin/end logic

From: Sergey Senozhatsky

Date: Wed Jan 07 2026 - 20:17:54 EST


On (26/01/07 19:03), Yosry Ahmed wrote:
> On Wed, Jan 07, 2026 at 02:21:45PM +0900, Sergey Senozhatsky wrote:
> > From: Yosry Ahmed <yosry.ahmed@xxxxxxxxx>
>
> While I appreciate this, I think for all intents and purposes this patch
> should be credited to you, it's different from the diff I said as it
> applies on top of your change.
>
> If you're feeling really generous, I think Suggested-by or
> Co-developed-by + Signed-off-by is sufficient :)

Okey-dokey
Co-developed-by: Yosry Ahmed <yosry.ahmed@xxxxxxxxx>

> > When we switched from using class->size (for spans detection)
> > to actual compressed object size, we had to compensate for
> > the fact that class->size implicitly took inlined handle
> > into consideration. In fact, instead of adjusting the size
> > of compressed object (adding handle offset for non-huge size
> > classes), we can move some lines around and simplify the
> > code: there are already paths in read_begin/end that compensate
> > for inlined object handle offset.
>
> I think the commit log is not clear in isolation.
>
> How about something like this:
>
> zs_obj_read_begin() currently maps or copies the the compressed object
> with the prefix handle for !ZsHugePage case. Make the logic clearer and
> more officient 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.

Looks good to me.

Andrew, can we trouble you with commit message update or should I resend?