Message ID | 1676124399-16542-1-git-send-email-lirongqing@baidu.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | x86/kvm: Don't use PVspinlock when mwait is advertised | expand |
On Sat, Feb 11, 2023, lirongqing@baidu.com wrote: > From: Li RongQing <lirongqing@baidu.com> > > MWAIT is advertised in host is not overcommitted scenario, however, > pvspinlock should be enabled in host overcommitted scenario. Let's > add the MWAIT checking when enabling pvspinlock > > Signed-off-by: Li RongQing <lirongqing@baidu.com> > --- > arch/x86/kernel/kvm.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c > index 1cceac5..dfa1451 100644 > --- a/arch/x86/kernel/kvm.c > +++ b/arch/x86/kernel/kvm.c > @@ -1087,6 +1087,11 @@ void __init kvm_spinlock_init(void) > goto out; > } > > + if (boot_cpu_has(X86_FEATURE_MWAIT)) { IMO this is a bad idea. Odds are good that there are less-than-perfect VM configs that advertise MONITOR+MWAIT but don't disable interception. Ugh, but we've already added this logic for other features guaraded by KVM_HINTS_REALTIME in commit 40cd58dbf121 ("x86/kvm: Don't use PV TLB/yield when mwait is advertised") Why doesn't the host simply advertise KVM_HINTS_REALTIME?
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 1cceac5..dfa1451 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -1087,6 +1087,11 @@ void __init kvm_spinlock_init(void) goto out; } + if (boot_cpu_has(X86_FEATURE_MWAIT)) { + pr_info("PV spinlocks disabled with mwait\n"); + goto out; + } + if (num_possible_cpus() == 1) { pr_info("PV spinlocks disabled, single CPU\n"); goto out;