[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJZ5v0iT66HGuXG7G78G1=44DOTFgZvH=53ghsYWXyj1Pd+dHA@mail.gmail.com>
Date: Fri, 23 May 2025 17:19:35 +0200
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Zihuan Zhang <zhangzihuan@...inos.cn>
Cc: rafael@...nel.org, len.brown@...el.com, pavel@...nel.org,
linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
akpm@...ux-foundation.org, tzungbi@...nel.org, a.fatoum@...gutronix.de,
jani.nikula@...el.com, joel.granados@...nel.org, paulmck@...nel.org,
zhangguopeng@...inos.cn, linux@...ssschuh.net
Subject: Re: [PATCH v2 0/3] PM / Sleep: Introduce and use system sleep lock helpers
On Thu, May 22, 2025 at 4:35 AM Zihuan Zhang <zhangzihuan@...inos.cn> wrote:
>
> This patch series introduces wrapper functions for locking
> system_transition_mutex used in system sleep (suspend/hibernate) code,
> and refactors the existing usage in kernel/power to improve maintainability,
> readability, and future extensibility.
>
> Currently, mutex_lock/unlock(&system_transition_mutex) is used directly
> in multiple places in the suspend and hibernation paths. This results in
> boilerplate repetition and makes it harder to change the locking mechanism
> later if needed (e.g., for debugging, tracing, or replacing the mutex
> with another primitive).
>
> Summary:
>
> - Patch 1 replaces mutex_lock with lock_system_sleep.
>
> - Patch 2 adds a non-blocking `try_lock_system_sleep()` for code paths that
> should proceed only if the lock is immediately available.
>
> - Patch 3 replaces remaining uses of `system_transition_mutex` in
> `kernel/power/` with the new helper functions.
>
> This change brings all system sleep transition locking behind well-named
> abstractions, preparing the code for future evolution while simplifying
> reasoning and avoiding repeated direct mutex usage.
>
> change log:
> V2:
> Fix PF_NOFREEZE leakage on try_lock_system_sleep() failure.
>
> Zihuan Zhang (3):
> PM / Sleep: Replace mutex_[un]lock(&system_transition_mutex) with
> [un]lock_system_sleep()
> PM / Sleep: Introduce try_lock_system_sleep()
> PM / Sleep: Replace mutex_trylock(&system_transition_mutex) with
> try_lock_system_sleep()
>
> include/linux/suspend.h | 2 ++
> kernel/power/hibernate.c | 11 +++++++----
> kernel/power/main.c | 14 ++++++++++++++
> kernel/power/suspend.c | 7 +++++--
> kernel/power/user.c | 6 ++++--
> kernel/reboot.c | 5 +++--
> 6 files changed, 35 insertions(+), 10 deletions(-)
>
> --
This is a bit too late for 6.16, please resubmit when 6.16-rc1 is out.
Thanks!
Powered by blists - more mailing lists