From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Andrew Morton <akpm@linux-foundation.org>,
Richard Chang <richardycc@google.com>
Cc: Minchan Kim <minchan@kernel.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Martin Liu <liumartin@google.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/zsmalloc: fix release order of locks in zs_page_migrate()
Date: Tue, 28 Jul 2026 15:39:59 +0900 [thread overview]
Message-ID: <amhOkJPfTjkuWElp@google.com> (raw)
In-Reply-To: <20260728055333.421080-1-richardycc@google.com>
On (26/07/28 05:53), Richard Chang 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.
>
> Signed-off-by: Richard Chang <richardycc@google.com>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Tested-by: Sergey Senozhatsky <senozhatsky@chromium.org>
next prev parent reply other threads:[~2026-07-28 6:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 5:53 [PATCH] mm/zsmalloc: fix release order of locks in zs_page_migrate() Richard Chang
2026-07-28 6:39 ` Sergey Senozhatsky [this message]
2026-07-28 18:15 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=amhOkJPfTjkuWElp@google.com \
--to=senozhatsky@chromium.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liumartin@google.com \
--cc=minchan@kernel.org \
--cc=richardycc@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox