Thread (20 messages) flat view 20 messages, 4 authors, 2021-09-24

Re: [PATCH v7 5/6] KVM: x86: Refactor tsc synchronization code

From: Paolo Bonzini <pbonzini@redhat.com>
Date: 2021-09-24 09:31:21
Also in: kvm, kvmarm

On 02/09/21 21:21, Sean Christopherson wrote:
quoted
+	if (!matched) {
+		...
+		spin_lock(&kvm->arch.pvclock_gtod_sync_lock);
+		kvm->arch.nr_vcpus_matched_tsc = 0;
+	} else if (!already_matched) {
+		spin_lock(&kvm->arch.pvclock_gtod_sync_lock);
+		kvm->arch.nr_vcpus_matched_tsc++;
+	}
+
+	kvm_track_tsc_matching(vcpu);
+	spin_unlock(&kvm->arch.pvclock_gtod_sync_lock);
This unlock is imbalanced if matched and already_matched are both true.  It's not
immediately obvious that that_can't_  happen, and if it truly can't happen then
conditionally locking is pointless (because it's not actually conditional).
This is IMO another reason to unify tsc_write_lock and 
pvclock_gtod_sync_lock.  The chances of contention are pretty slim.  As 
soon as I sort out the next -rc3 pull request I'll send out my version 
of Oliver's patches.

Thanks,

Paolo


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help