Skip to content

Commit 708f799

Browse files
mmhalsean-jc
authored andcommitted
KVM: x86: Optimize kvm->lock and SRCU interaction (KVM_X86_SET_MSR_FILTER)
Reduce time spent holding kvm->lock: unlock mutex before calling synchronize_srcu(). There is no need to hold kvm->lock until all vCPUs have been kicked, KVM only needs to guarantee that all vCPUs will switch to the new filter before exiting to userspace. Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Suggested-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Michal Luczaj <mhal@rbox.co> Link: https://lore.kernel.org/r/20230107001256.2365304-3-mhal@rbox.co [sean: expand changelog] Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 95744a9 commit 708f799

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/kvm/x86.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6497,12 +6497,12 @@ static int kvm_vm_ioctl_set_msr_filter(struct kvm *kvm,
64976497
old_filter = srcu_dereference_check(kvm->arch.msr_filter, &kvm->srcu, 1);
64986498

64996499
rcu_assign_pointer(kvm->arch.msr_filter, new_filter);
6500+
mutex_unlock(&kvm->lock);
65006501
synchronize_srcu(&kvm->srcu);
65016502

65026503
kvm_free_msr_filter(old_filter);
65036504

65046505
kvm_make_all_cpus_request(kvm, KVM_REQ_MSR_FILTER_CHANGED);
6505-
mutex_unlock(&kvm->lock);
65066506

65076507
return 0;
65086508
}

0 commit comments

Comments
 (0)