Re: [RFC PATCH v2 2/3] mm/zsmalloc: drop pool->lock from zs_free on 64-bit systems
From: Nhat Pham
Date: Fri May 29 2026 - 18:52:49 EST
On Wed, May 27, 2026 at 5:01 AM Wenchao Hao <haowenchao22@xxxxxxxxx> wrote:
>
> With class_idx encoded in obj, zs_free() can locate the size_class
> without holding pool->lock on 64-bit systems. Page migration also
> takes class->lock and only rewrites the PFN field of obj, so:
>
> 1. read obj locklessly,
> 2. lock the size_class derived from obj's class_idx,
> 3. re-read obj under class->lock to get a stable PFN.
>
> This eliminates the rwlock read-side cacheline bouncing between
> zs_free() and migration/compaction on multi-core systems.
>
> On 32-bit systems pool->lock is preserved.
>
> Signed-off-by: Wenchao Hao <haowenchao@xxxxxxxxxx>
Thanks for doing this!
Reviewed-by: Nhat Pham <nphamcs@xxxxxxxxx>