KVM: Don't take mmu_lock for range invalidation unless necessary
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 3 Aug 2021 07:45:41 +0000 (03:45 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 3 Aug 2021 07:54:08 +0000 (03:54 -0400)
commit071064f14d87536e38235df1bdeabe404023203f
treebe48cfdff46fbaedb60513a0049d1b49f2c328ce
parent52ac8b358b0cb7e91c966225fca61be5d1c984bc
KVM: Don't take mmu_lock for range invalidation unless necessary

Avoid taking mmu_lock for .invalidate_range_{start,end}() notifications
that are unrelated to KVM.  This is possible now that memslot updates are
blocked from range_start() to range_end(); that ensures that lock elision
happens in both or none, and therefore that mmu_notifier_count updates
(which must occur while holding mmu_lock for write) are always paired
across start->end.

Based on patches originally written by Ben Gardon.

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