]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: Avoid atomic operations when kicking the running vCPU
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 20 Oct 2021 10:38:05 +0000 (06:38 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 8 Dec 2021 09:24:44 +0000 (04:24 -0500)
commitcd1f2353c1625228d2cabda11bd94e98cb6f788c
treee43dae70e1e18b3d19304fe2c8c88959f16d22d9
parent15fde12bed56d6964d3c6d115d37c13d3fbecb74
KVM: Avoid atomic operations when kicking the running vCPU

If we do have the vcpu mutex, as is the case if kvm_running_vcpu is set
to the target vcpu of the kick, changes to vcpu->mode do not need atomic
operations; cmpxchg is only needed _outside_ the mutex to ensure that
the IN_GUEST_MODE->EXITING_GUEST_MODE change does not race with the vcpu
thread going OUTSIDE_GUEST_MODE.

Use this to optimize the case of a vCPU sending an interrupt to itself.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
virt/kvm/kvm_main.c