Re: [PATCH v3] KVM: SEV: Mark nested locking of vcpu->lock

From: Paolo Bonzini
Date: Fri Apr 29 2022 - 09:44:51 EST


On 4/29/22 13:40, Hillf Danton wrote:
To avoid acquiring more than one mutexes at the same time, add a completion
in paralle to the mutex in question and ask mutex locker for non-migration
purpose to take a nap on completion instead of mutex.

Acquiring more than one mutex at a time is perfectly fine. It also cannot get into philosophers-problem-like deadlocks because 1) it's got a well-defined iteration order 2) it's protected by sev_lock_two_vms.

Just, lockdep that has to be convinced that it is fine. I don't shy away from complex locking schemes if they're necessary, but here it absolutely isn't.

Paolo