Skip to content

Commit 0f42194

Browse files
storulfrafaeljw
authored andcommitted
PM: s2idle: Drop redundant locks when entering s2idle
The calls to cpus_read_lock|unlock() protects us from getting CPUS hotplugged, while entering suspend-to-idle. However, when s2idle_enter() is called we should be far beyond the point when CPUs may be hotplugged. Let's therefore simplify the code and drop the use of the lock. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Link: https://patch.msgid.link/20250311160827.1129643-2-ulf.hansson@linaro.org [ rjw: Rewrote the new comment ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 13b4f9e commit 0f42194

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

kernel/power/suspend.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,19 @@ static void s2idle_enter(void)
9191
{
9292
trace_suspend_resume(TPS("machine_suspend"), PM_SUSPEND_TO_IDLE, true);
9393

94+
/*
95+
* The correctness of the code below depends on the number of online
96+
* CPUs being stable, but CPUs cannot be taken offline or put online
97+
* while it is running.
98+
*/
99+
94100
raw_spin_lock_irq(&s2idle_lock);
95101
if (pm_wakeup_pending())
96102
goto out;
97103

98104
s2idle_state = S2IDLE_STATE_ENTER;
99105
raw_spin_unlock_irq(&s2idle_lock);
100106

101-
cpus_read_lock();
102-
103107
/* Push all the CPUs into the idle loop. */
104108
wake_up_all_idle_cpus();
105109
/* Make the current CPU wait so it can enter the idle loop too. */
@@ -112,8 +116,6 @@ static void s2idle_enter(void)
112116
*/
113117
wake_up_all_idle_cpus();
114118

115-
cpus_read_unlock();
116-
117119
raw_spin_lock_irq(&s2idle_lock);
118120

119121
out:

0 commit comments

Comments
 (0)