Skip to content

Commit 7e9ae2c

Browse files
committed
x86/smp: PM/hibernate: Split arch_resume_nosmt()
JIRA: https://issues.redhat.com/browse/RHEL-113139 commit 4c529a4 Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Date: Sat Jun 7 14:22:56 2025 +0200 x86/smp: PM/hibernate: Split arch_resume_nosmt() Move the inner part of the arch_resume_nosmt() code into a separate function called arch_cpu_rescan_dead_smt_siblings(), so it can be used in other places where "dead" SMT siblings may need to be taken online and offline again in order to get into deep idle states. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Dave Hansen <dave.hansen@linux.intel.com> Tested-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Link: https://patch.msgid.link/3361688.44csPzL39Z@rjwysocki.net [ rjw: Prevent build issues with CONFIG_SMP unset ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: David Arcari <darcari@redhat.com>
1 parent d85e3d7 commit 7e9ae2c

File tree

3 files changed

+33
-13
lines changed

3 files changed

+33
-13
lines changed

arch/x86/kernel/smp.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,3 +299,27 @@ struct smp_ops smp_ops = {
299299
.send_call_func_single_ipi = native_send_call_func_single_ipi,
300300
};
301301
EXPORT_SYMBOL_GPL(smp_ops);
302+
303+
int arch_cpu_rescan_dead_smt_siblings(void)
304+
{
305+
enum cpuhp_smt_control old = cpu_smt_control;
306+
int ret;
307+
308+
/*
309+
* If SMT has been disabled and SMT siblings are in HLT, bring them back
310+
* online and offline them again so that they end up in MWAIT proper.
311+
*
312+
* Called with hotplug enabled.
313+
*/
314+
if (old != CPU_SMT_DISABLED && old != CPU_SMT_FORCE_DISABLED)
315+
return 0;
316+
317+
ret = cpuhp_smt_enable();
318+
if (ret)
319+
return ret;
320+
321+
ret = cpuhp_smt_disable(old);
322+
323+
return ret;
324+
}
325+
EXPORT_SYMBOL_GPL(arch_cpu_rescan_dead_smt_siblings);

arch/x86/power/hibernate.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ int relocate_restore_code(void)
188188

189189
int arch_resume_nosmt(void)
190190
{
191-
int ret = 0;
191+
int ret;
192+
192193
/*
193194
* We reached this while coming out of hibernation. This means
194195
* that SMT siblings are sleeping in hlt, as mwait is not safe
@@ -202,18 +203,10 @@ int arch_resume_nosmt(void)
202203
* Called with hotplug disabled.
203204
*/
204205
cpu_hotplug_enable();
205-
if (cpu_smt_control == CPU_SMT_DISABLED ||
206-
cpu_smt_control == CPU_SMT_FORCE_DISABLED) {
207-
enum cpuhp_smt_control old = cpu_smt_control;
208-
209-
ret = cpuhp_smt_enable();
210-
if (ret)
211-
goto out;
212-
ret = cpuhp_smt_disable(old);
213-
if (ret)
214-
goto out;
215-
}
216-
out:
206+
207+
ret = arch_cpu_rescan_dead_smt_siblings();
208+
217209
cpu_hotplug_disable();
210+
218211
return ret;
219212
}

include/linux/cpu.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ extern void cpu_maps_update_begin(void);
116116
extern void cpu_maps_update_done(void);
117117
int bringup_hibernate_cpu(unsigned int sleep_cpu);
118118
void bringup_nonboot_cpus(unsigned int setup_max_cpus);
119+
int arch_cpu_rescan_dead_smt_siblings(void);
119120

120121
#else /* CONFIG_SMP */
121122
#define cpuhp_tasks_frozen 0
@@ -130,6 +131,8 @@ static inline void cpu_maps_update_done(void)
130131

131132
static inline int add_cpu(unsigned int cpu) { return 0;}
132133

134+
static inline int arch_cpu_rescan_dead_smt_siblings(void) { return 0; }
135+
133136
#endif /* CONFIG_SMP */
134137
extern struct bus_type cpu_subsys;
135138

0 commit comments

Comments
 (0)