[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250520032545.29558-1-zhangzihuan@kylinos.cn>
Date: Tue, 20 May 2025 11:25:42 +0800
From: Zihuan Zhang <zhangzihuan@...inos.cn>
To: rafael@...nel.org,
len.brown@...el.com,
pavel@...nel.org
Cc: 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,
Zihuan Zhang <zhangzihuan@...inos.cn>
Subject: [PATCH 0/3] PM / Sleep: Introduce and use system sleep lock helpers
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.
include/linux/suspend.h | 2 ++
kernel/power/hibernate.c | 11 +++++++----
kernel/power/main.c | 12 ++++++++++++
kernel/power/suspend.c | 7 +++++--
kernel/power/user.c | 6 ++++--
kernel/reboot.c | 5 +++--
6 files changed, 33 insertions(+), 10 deletions(-)
--
2.25.1
Powered by blists - more mailing lists