KVM: add spinlock optimization framework
If a vcpu exits due to request a user mode spinlock, then the spinlock-holder may be preempted in user mode or kernel mode. (Note that not all architectures trap spin loops in user mode, only AMD x86 and ARM/ARM64 currently do). But if a vcpu exits in kernel mode, then the holder must be preempted in kernel mode, so we should choose a vcpu in kernel mode as a more likely candidate for the lock holder. This introduces kvm_arch_vcpu_in_kernel() to decide whether the vcpu is in kernel-mode when it's preempted. kvm_vcpu_on_spin's new argument says the same of the spinning VCPU. Signed-off-by:Longpeng(Mike) <longpeng2@huawei.com> Signed-off-by:
Paolo Bonzini <pbonzini@redhat.com>
Showing
- arch/arm/kvm/handle_exit.c 1 addition, 1 deletionarch/arm/kvm/handle_exit.c
- arch/arm64/kvm/handle_exit.c 1 addition, 1 deletionarch/arm64/kvm/handle_exit.c
- arch/mips/kvm/mips.c 5 additions, 0 deletionsarch/mips/kvm/mips.c
- arch/powerpc/kvm/powerpc.c 5 additions, 0 deletionsarch/powerpc/kvm/powerpc.c
- arch/s390/kvm/diag.c 1 addition, 1 deletionarch/s390/kvm/diag.c
- arch/s390/kvm/kvm-s390.c 5 additions, 0 deletionsarch/s390/kvm/kvm-s390.c
- arch/x86/kvm/hyperv.c 1 addition, 1 deletionarch/x86/kvm/hyperv.c
- arch/x86/kvm/svm.c 1 addition, 1 deletionarch/x86/kvm/svm.c
- arch/x86/kvm/vmx.c 1 addition, 1 deletionarch/x86/kvm/vmx.c
- arch/x86/kvm/x86.c 5 additions, 0 deletionsarch/x86/kvm/x86.c
- include/linux/kvm_host.h 2 additions, 1 deletioninclude/linux/kvm_host.h
- virt/kvm/arm/arm.c 5 additions, 0 deletionsvirt/kvm/arm/arm.c
- virt/kvm/kvm_main.c 3 additions, 1 deletionvirt/kvm/kvm_main.c
Please register or sign in to comment