Skip to content
This repository was archived by the owner on Jan 27, 2026. It is now read-only.
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions arch/x86/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -876,16 +876,25 @@ static int prefer_mwait_c1_over_halt(const struct cpuinfo_x86 *c)
*/
static __cpuidle void mwait_idle(void)
{
bool has_monitor_less_mwait;

if (!current_set_polling_and_test()) {
if (this_cpu_has(X86_BUG_CLFLUSH_MONITOR)) {
mb(); /* quirk */
clflush((void *)&current_thread_info()->flags);
mb(); /* quirk */
}

has_monitor_less_mwait = ((cpuid_ecx(CPUID_MWAIT_LEAF) & CPUID5_ECX_MONITOR_LESS) != 0);
/* CPUID may cause vmexit, which we do not wish to see between monitor/mwait. */
mb();
__monitor((void *)&current_thread_info()->flags, 0, 0);
if (!need_resched())
__sti_mwait(0, 0);
if (!need_resched()) {
if (!hypervisor_is_type(X86_HYPER_NATIVE) && has_monitor_less_mwait) {
current_clr_polling();
__sti_mwait(0, 0x4);
} else
__sti_mwait(0, 0);
}
else
raw_local_irq_enable();
} else {
Expand Down