[PATCH 2/2] KVM: Protect vCPU's "last run PID" with rwlock, not RCU
Oliver Upton
oliver.upton at linux.dev
Fri Aug 9 11:05:49 PDT 2024
On Tue, Aug 06, 2024 at 04:59:03PM -0700, Sean Christopherson wrote:
> > Can you nest this lock inside of the vcpu->mutex acquisition in
> > kvm_vm_ioctl_create_vcpu() so lockdep gets the picture?
>
> I don't think that's necessary. Commit 42a90008f890 ("KVM: Ensure lockdep knows
> about kvm->lock vs. vcpu->mutex ordering rule") added the lock+unlock in
> kvm_vm_ioctl_create_vcpu() purely because actually taking vcpu->mutex inside
> kvm->lock is rare, i.e. lockdep would be unable to detect issues except for very
> specific VM types hitting very specific flows.
I don't think the perceived rarity matters at all w/ this. Beyond the
lockdep benefits, it is a self-documenting way to describe lock ordering.
Dunno about you, but I haven't kept up with locking.rst at all :)
Having said that, an inversion would still be *very* obvious, as it
would be trying to grab a mutex while holding a spinlock...
--
Thanks,
Oliver
More information about the linux-arm-kernel
mailing list