diff mbox series

[v2,2/6] KVM: x86: Optimize kvm->lock and SRCU interaction (KVM_X86_SET_MSR_FILTER)

Message ID 20230107001256.2365304-3-mhal@rbox.co (mailing list archive)
State New, archived
Headers show
Series kvm->lock vs. SRCU sync optimizations | expand

Commit Message

Michal Luczaj Jan. 7, 2023, 12:12 a.m. UTC
Reduce time spent holding kvm->lock: unlock mutex before calling
synchronize_srcu().

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Michal Luczaj <mhal@rbox.co>
---
 arch/x86/kvm/x86.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index da4bbd043a7b..7d398e0da834 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6491,12 +6491,12 @@  static int kvm_vm_ioctl_set_msr_filter(struct kvm *kvm,
 	old_filter = srcu_dereference_check(kvm->arch.msr_filter, &kvm->srcu, 1);
 
 	rcu_assign_pointer(kvm->arch.msr_filter, new_filter);
+	mutex_unlock(&kvm->lock);
 	synchronize_srcu(&kvm->srcu);
 
 	kvm_free_msr_filter(old_filter);
 
 	kvm_make_all_cpus_request(kvm, KVM_REQ_MSR_FILTER_CHANGED);
-	mutex_unlock(&kvm->lock);
 
 	return 0;
 }