mwait
mwait 指令
A hint that allows the processor to stop instruction execution and enter an implementation-dependent optimized state until occurrence of a class of events.
MWAIT instruction provides hints to allow the processor to enter an implementation-dependent optimized state. There are two principal targeted usages: address-range monitor and advanced power management. Both usages of MWAIT require the use of the MONITOR instruction.
MWAIT是一种CPU处理器指令,主要用于让CPU进入低功耗状态以节省能源,并等待一些事件的发生。当CPU使用MWAIT指令时,它可以在不消耗太多能源的情况下监控外部设备的事件,如外部设备的中断或唤醒信号。这种方式不仅节省了电力,还能提高系统的响应速度,因为CPU不必频繁地从低功耗状态中唤醒。
内核如何使用?
X86_FEATURE_MWAIT (arch/x86/include/asm/cpufeatures.h)
mwait实现 -> arch/x86/include/asm/mwait.h
mwait_idle_with_hints
intel-idle
arch/x86/kernel/process.c
1 |
|
KVM 支持虚机mwait
kvm_emulate_mwait
kvm_emulate_monitor_mwait
kvm_vm_ioctl_enable_cap
vmx_exec_control
EXIT_REASON_MWAIT_INSTRUCTION