Skip to content

Commit 4c529a4

Browse files
committed
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 <[email protected]> Acked-by: Dave Hansen <[email protected]> Tested-by: Artem Bityutskiy <[email protected]> Link: https://patch.msgid.link/[email protected] [ rjw: Prevent build issues with CONFIG_SMP unset ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent c0f6913 commit 4c529a4

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
@@ -192,7 +192,8 @@ int relocate_restore_code(void)
192192

193193
int arch_resume_nosmt(void)
194194
{
195-
int ret = 0;
195+
int ret;
196+
196197
/*
197198
* We reached this while coming out of hibernation. This means
198199
* that SMT siblings are sleeping in hlt, as mwait is not safe
@@ -206,18 +207,10 @@ int arch_resume_nosmt(void)
206207
* Called with hotplug disabled.
207208
*/
208209
cpu_hotplug_enable();
209-
if (cpu_smt_control == CPU_SMT_DISABLED ||
210-
cpu_smt_control == CPU_SMT_FORCE_DISABLED) {
211-
enum cpuhp_smt_control old = cpu_smt_control;
212-
213-
ret = cpuhp_smt_enable();
214-
if (ret)
215-
goto out;
216-
ret = cpuhp_smt_disable(old);
217-
if (ret)
218-
goto out;
219-
}
220-
out:
210+
211+
ret = arch_cpu_rescan_dead_smt_siblings();
212+
221213
cpu_hotplug_disable();
214+
222215
return ret;
223216
}

include/linux/cpu.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ extern void cpu_maps_update_begin(void);
120120
extern void cpu_maps_update_done(void);
121121
int bringup_hibernate_cpu(unsigned int sleep_cpu);
122122
void bringup_nonboot_cpus(unsigned int max_cpus);
123+
int arch_cpu_rescan_dead_smt_siblings(void);
123124

124125
#else /* CONFIG_SMP */
125126
#define cpuhp_tasks_frozen 0
@@ -134,6 +135,8 @@ static inline void cpu_maps_update_done(void)
134135

135136
static inline int add_cpu(unsigned int cpu) { return 0;}
136137

138+
static inline int arch_cpu_rescan_dead_smt_siblings(void) { return 0; }
139+
137140
#endif /* CONFIG_SMP */
138141
extern const struct bus_type cpu_subsys;
139142

0 commit comments

Comments
 (0)