diff mbox series

[v2,3/6] KVM: x86: Simplify msr_filter update

Message ID 20230107001256.2365304-4-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
Replace srcu_dereference()+rcu_assign_pointer() sequence with
a single rcu_replace_pointer().

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

Patch

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 7d398e0da834..8abce24ec020 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6486,11 +6486,8 @@  static int kvm_vm_ioctl_set_msr_filter(struct kvm *kvm,
 	}
 
 	mutex_lock(&kvm->lock);
-
 	/* The per-VM filter is protected by kvm->lock... */
-	old_filter = srcu_dereference_check(kvm->arch.msr_filter, &kvm->srcu, 1);
-
-	rcu_assign_pointer(kvm->arch.msr_filter, new_filter);
+	old_filter = rcu_replace_pointer(kvm->arch.msr_filter, new_filter, 1);
 	mutex_unlock(&kvm->lock);
 	synchronize_srcu(&kvm->srcu);