Skip to content

Commit a18d098

Browse files
committed
Reapply "x86/smp: Eliminate mwait_play_dead_cpuid_hint()"
Revert commit 70523f3 ("Revert "x86/smp: Eliminate mwait_play_dead_cpuid_hint()"") to reapply the changes from commit 96040f7 ("x86/smp: Eliminate mwait_play_dead_cpuid_hint()") reverted by it. Previously, these changes caused idle power to rise on systems booting with "nosmt" in the kernel command line because they effectively caused "dead" SMT siblings to remain in idle state C1 after executing the HLT instruction, which prevented the processor from reaching package idle states deeper than PC2 going forward. Now, the "dead" SMT siblings are rescanned after initializing a proper cpuidle driver for the processor (either intel_idle or ACPI idle), at which point they are able to enter a sufficiently deep idle state in native_play_dead() via cpuidle, so the code changes in question can be reapplied. 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]
1 parent f694481 commit a18d098

File tree

1 file changed

+7
-47
lines changed

1 file changed

+7
-47
lines changed

arch/x86/kernel/smpboot.c

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,10 @@ void play_dead_common(void)
12441244
local_irq_disable();
12451245
}
12461246

1247+
/*
1248+
* We need to flush the caches before going to sleep, lest we have
1249+
* dirty data in our caches when we come back up.
1250+
*/
12471251
void __noreturn mwait_play_dead(unsigned int eax_hint)
12481252
{
12491253
struct mwait_cpu_dead *md = this_cpu_ptr(&mwait_cpu_dead);
@@ -1289,50 +1293,6 @@ void __noreturn mwait_play_dead(unsigned int eax_hint)
12891293
}
12901294
}
12911295

1292-
/*
1293-
* We need to flush the caches before going to sleep, lest we have
1294-
* dirty data in our caches when we come back up.
1295-
*/
1296-
static inline void mwait_play_dead_cpuid_hint(void)
1297-
{
1298-
unsigned int eax, ebx, ecx, edx;
1299-
unsigned int highest_cstate = 0;
1300-
unsigned int highest_subcstate = 0;
1301-
int i;
1302-
1303-
if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||
1304-
boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)
1305-
return;
1306-
if (!this_cpu_has(X86_FEATURE_MWAIT))
1307-
return;
1308-
if (!this_cpu_has(X86_FEATURE_CLFLUSH))
1309-
return;
1310-
1311-
eax = CPUID_LEAF_MWAIT;
1312-
ecx = 0;
1313-
native_cpuid(&eax, &ebx, &ecx, &edx);
1314-
1315-
/*
1316-
* eax will be 0 if EDX enumeration is not valid.
1317-
* Initialized below to cstate, sub_cstate value when EDX is valid.
1318-
*/
1319-
if (!(ecx & CPUID5_ECX_EXTENSIONS_SUPPORTED)) {
1320-
eax = 0;
1321-
} else {
1322-
edx >>= MWAIT_SUBSTATE_SIZE;
1323-
for (i = 0; i < 7 && edx; i++, edx >>= MWAIT_SUBSTATE_SIZE) {
1324-
if (edx & MWAIT_SUBSTATE_MASK) {
1325-
highest_cstate = i;
1326-
highest_subcstate = edx & MWAIT_SUBSTATE_MASK;
1327-
}
1328-
}
1329-
eax = (highest_cstate << MWAIT_SUBSTATE_SIZE) |
1330-
(highest_subcstate - 1);
1331-
}
1332-
1333-
mwait_play_dead(eax);
1334-
}
1335-
13361296
/*
13371297
* Kick all "offline" CPUs out of mwait on kexec(). See comment in
13381298
* mwait_play_dead().
@@ -1383,9 +1343,9 @@ void native_play_dead(void)
13831343
play_dead_common();
13841344
tboot_shutdown(TB_SHUTDOWN_WFS);
13851345

1386-
mwait_play_dead_cpuid_hint();
1387-
if (cpuidle_play_dead())
1388-
hlt_play_dead();
1346+
/* Below returns only on error. */
1347+
cpuidle_play_dead();
1348+
hlt_play_dead();
13891349
}
13901350

13911351
#else /* ... !CONFIG_HOTPLUG_CPU */

0 commit comments

Comments
 (0)