Paolo Bonzini
2014-Mar-20 22:01 UTC
[PATCH v7 06/11] pvqspinlock, x86: Allow unfair queue spinlock in a KVM guest
Il 19/03/2014 21:14, Waiman Long ha scritto:> This patch adds a KVM init function to activate the unfair queue > spinlock in a KVM guest when the PARAVIRT_UNFAIR_LOCKS kernel config > option is selected. > > Signed-off-by: Waiman Long <Waiman.Long at hp.com> > --- > arch/x86/kernel/kvm.c | 17 +++++++++++++++++ > 1 files changed, 17 insertions(+), 0 deletions(-) > > diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c > index 713f1b3..a489140 100644 > --- a/arch/x86/kernel/kvm.c > +++ b/arch/x86/kernel/kvm.c > @@ -826,3 +826,20 @@ static __init int kvm_spinlock_init_jump(void) > early_initcall(kvm_spinlock_init_jump); > > #endif /* CONFIG_PARAVIRT_SPINLOCKS */ > + > +#ifdef CONFIG_PARAVIRT_UNFAIR_LOCKS > +/* > + * Enable unfair lock if running in a real para-virtualized environment > + */ > +static __init int kvm_unfair_locks_init_jump(void) > +{ > + if (!kvm_para_available()) > + return 0; > + > + static_key_slow_inc(¶virt_unfairlocks_enabled); > + printk(KERN_INFO "KVM setup unfair spinlock\n"); > + > + return 0; > +} > +early_initcall(kvm_unfair_locks_init_jump); > +#endif >No! Please do what I asked you to do. You are not handling Hyper-V or VMWare. Just use X86_FEATURE_HYPERVISOR and it will cover all hypervisors that actually follow Intel's guidelines. Paolo
H. Peter Anvin
2014-Mar-20 22:29 UTC
[PATCH v7 06/11] pvqspinlock, x86: Allow unfair queue spinlock in a KVM guest
On 03/20/2014 03:01 PM, Paolo Bonzini wrote:> > No! Please do what I asked you to do. You are not handling Hyper-V or > VMWare. Just use X86_FEATURE_HYPERVISOR and it will cover all > hypervisors that actually follow Intel's guidelines. >And for those that don't, we should turn on X86_FEATURE_HYPERVISOR in the Linux enumeration code as we do for other features we detect independently. -hpa
Paolo Bonzini
2014-Mar-20 22:40 UTC
[PATCH v7 06/11] pvqspinlock, x86: Allow unfair queue spinlock in a KVM guest
Il 20/03/2014 23:29, H. Peter Anvin ha scritto:> > No! Please do what I asked you to do. You are not handling Hyper-V or > > VMWare. Just use X86_FEATURE_HYPERVISOR and it will cover all > > hypervisors that actually follow Intel's guidelines. > > And for those that don't, we should turn on X86_FEATURE_HYPERVISOR in > the Linux enumeration code as we do for other features we detect > independently.Yeah, but all the hypervisors we detect right now are fine. Not surprising, since Microsoft won't certify Windows on your hypervisor unless you set the bit, and KVM/Xen/VMware are all certified (Hyper-V does not go through the same certification, but sets it anyway). I got a second-hand report that VirtualBox doesn't set it---and I haven't verified that yet---but we don't even try to detect vbox right now. Paolo
Waiman Long
2014-Mar-21 21:27 UTC
[PATCH v7 06/11] pvqspinlock, x86: Allow unfair queue spinlock in a KVM guest
On 03/20/2014 06:01 PM, Paolo Bonzini wrote:> Il 19/03/2014 21:14, Waiman Long ha scritto: >> This patch adds a KVM init function to activate the unfair queue >> spinlock in a KVM guest when the PARAVIRT_UNFAIR_LOCKS kernel config >> option is selected. >> >> Signed-off-by: Waiman Long <Waiman.Long at hp.com> >> --- >> arch/x86/kernel/kvm.c | 17 +++++++++++++++++ >> 1 files changed, 17 insertions(+), 0 deletions(-) >> >> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c >> index 713f1b3..a489140 100644 >> --- a/arch/x86/kernel/kvm.c >> +++ b/arch/x86/kernel/kvm.c >> @@ -826,3 +826,20 @@ static __init int kvm_spinlock_init_jump(void) >> early_initcall(kvm_spinlock_init_jump); >> >> #endif /* CONFIG_PARAVIRT_SPINLOCKS */ >> + >> +#ifdef CONFIG_PARAVIRT_UNFAIR_LOCKS >> +/* >> + * Enable unfair lock if running in a real para-virtualized environment >> + */ >> +static __init int kvm_unfair_locks_init_jump(void) >> +{ >> + if (!kvm_para_available()) >> + return 0; >> + >> + static_key_slow_inc(¶virt_unfairlocks_enabled); >> + printk(KERN_INFO "KVM setup unfair spinlock\n"); >> + >> + return 0; >> +} >> +early_initcall(kvm_unfair_locks_init_jump); >> +#endif >> > > No! Please do what I asked you to do. You are not handling Hyper-V > or VMWare. Just use X86_FEATURE_HYPERVISOR and it will cover all > hypervisors that actually follow Intel's guidelines. > > PaoloOK, I can modify the patch to use X86_FEATURE_HYPERVISOR. -Longman
Seemingly Similar Threads
- [PATCH v7 06/11] pvqspinlock, x86: Allow unfair queue spinlock in a KVM guest
- [PATCH v7 06/11] pvqspinlock, x86: Allow unfair queue spinlock in a KVM guest
- [PATCH v7 06/11] pvqspinlock, x86: Allow unfair queue spinlock in a KVM guest
- [PATCH v7 07/11] pvqspinlock, x86: Allow unfair queue spinlock in a XEN guest
- [PATCH v7 07/11] pvqspinlock, x86: Allow unfair queue spinlock in a XEN guest