Re: [PATCH] mm/zsmalloc: fix release order of locks in zs_page_migrate()
From: Andrew Morton
Date: Tue Jul 28 2026 - 14:25:30 EST
On Tue, 28 Jul 2026 05:53:33 +0000 Richard Chang <richardycc@xxxxxxxxxx> wrote:
> In zs_page_migrate(), locks are acquired in the following order:
> 1. write_lock(&pool->lock)
> 2. spin_lock(&class->lock)
> 3. zspage_write_trylock(zspage)
>
> However, upon successful page migration, they were being released in
> forward acquisition (FIFO) order:
> 1. write_unlock(&pool->lock)
> 2. spin_unlock(&class->lock)
> 3. zspage_write_unlock(zspage)
>
> Fix the unlocking order to release locks in strict reverse (LIFO)
> order of acquisition:
> 3. zspage_write_unlock(zspage)
> 2. spin_unlock(&class->lock)
> 1. write_unlock(&pool->lock)
>
> Releasing locks in reverse order of acquisition adheres to standard
> kernel locking hygiene, prevents potential lock ordering and lockdep
> inconsistencies.
>
Thanks.
Does this actually fix a lockdep splat? If so, is a link available?