History

kvm: better MWAIT emulation for guests

Guests that are heavy on futexes end up IPI'ing each other a lot. That can lead to significant slowdowns and latency increase for those guests when running within KVM. If only a single guest is needed on a host, we have a lot of spare host CPU time we can throw at the problem. Modern CPUs implement a feature called "MWAIT" which allows guests to wake up sleeping remote CPUs without an IPI - thus without an exit - at the expense of never going out of guest context. The decision whether this is something sensible to use should be up to the VM admin, so to user space. We can however allow MWAIT execution on systems that support it properly hardware wise. This patch adds a CAP to user space and a KVM cpuid leaf to indicate availability of native MWAIT execution. With that enabled, the worst a guest can do is waste as many cycles as a "jmp ." would do, so it's not a privilege problem. We consciously do *not* expose the feature in our CPUID bitmap, as most people will want to benefit from sleeping vCPUs to allow for over commit.

Michael S. Tsirkin committed 9 years ago

Commit 668fffa1 parent db2336a6 files · +58 −4Browse files

Showing the changes to include/uapi/linux (1 of 6 files). Show all

Unified · Split

include/uapi/linux/kvm.h+1−0
@@ -893,6 +893,7 @@ struct kvm_ppc_resize_hpt { · 892 unmodified lines
893#define KVM_CAP_S390_GS 140893#define KVM_CAP_S390_GS 140
894#define KVM_CAP_S390_AIS 141894#define KVM_CAP_S390_AIS 141
895#define KVM_CAP_SPAPR_TCE_VFIO 142895#define KVM_CAP_SPAPR_TCE_VFIO 142
896#define KVM_CAP_X86_GUEST_MWAIT 143
896 897
897#ifdef KVM_CAP_IRQ_ROUTING898#ifdef KVM_CAP_IRQ_ROUTING
898 899