Re: [PATCH v5 3/4] mm/zsmalloc: drop class lock before freeing zspage
From: Barry Song
Date: Mon Jun 22 2026 - 20:52:46 EST
On Tue, Jun 16, 2026 at 11:13 AM Wenchao Hao <haowenchao22@xxxxxxxxx> wrote:
>
> From: Xueyuan Chen <xueyuan.chen21@xxxxxxxxx>
>
> Currently in zs_free(), the class->lock is held until the zspage is
> completely freed and the counters are updated. However, freeing pages
> back to the buddy allocator requires acquiring the zone lock.
>
> Under heavy memory pressure, zone lock contention can be severe. When
> this happens, the CPU holding the class->lock will stall waiting for
> the zone lock, thereby blocking all other CPUs attempting to acquire
> the same class->lock.
>
> This patch shrinks the critical section of the class->lock to reduce
> lock contention. By moving the actual page freeing process outside the
> class->lock, we can improve the concurrency performance of zs_free().
>
> Testing on the RADXA O6 platform shows that with 12 CPUs concurrently
> performing zs_free() operations, the execution time is reduced by 20%.
>
> Signed-off-by: Xueyuan Chen <xueyuan.chen21@xxxxxxxxx>
> Reviewed-by: Nhat Pham <nphamcs@xxxxxxxxx>
> Reviewed-by: Joshua Hahn <joshua.hahnjy@xxxxxxxxx>
> Signed-off-by: Wenchao Hao <haowenchao@xxxxxxxxxx>
Reviewed-by: Barry Song <baohua@xxxxxxxxxx>