Re: [PATCH 1/1] zsmalloc: account for handle size in class lookup

Sergey Senozhatsky <[email protected]>
Newsgroups gmane.linux.kernel.stable,gmane.linux.kernel.mm,gmane.linux.kernel
Message-ID <[email protected]>
On (26/08/09 19:55), Longlong Xia wrote:
> zs_lookup_class_index() lets zram recompression decide whether a newly
> compressed object would use a smaller size class. It currently classifies
> the payload size directly, while zs_malloc() adds ZS_HANDLE_SIZE before
> selecting the class.
> 
> This makes lookup disagree with allocation near size-class boundaries.
> With 4 KiB pages, CONFIG_ZSMALLOC_CHAIN_SIZE=8, and 64-bit handles, a
> 1025-to-1024-byte recompression appears to move from class 64 to class 62
> although both allocations use class 64. Conversely, a 1049-to-1025-byte
> recompression appears to stay in class 64 although the allocations move
> from class 65 to class 64.
> 
> As a result, zram can accept replacements with no allocation benefit or
> reject ones that would save memory, potentially marking the object
> incompressible.
> 
> Factor size-class selection into lookup_size_class(), account for the
> handle there, and use the helper for both lookup and allocation.
> 
> Fixes: 7c2af309abd2 ("zram: add size class equals check into recompression")
> Assisted-by: Codex:gpt-5.6-sol
> Cc: [email protected]
> Signed-off-by: Longlong Xia <[email protected]>

Reviewed-by: Sergey Senozhatsky <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.