Re: [PATCH v3] KVM: SEV: Mark nested locking of vcpu->lock
From: Paolo Bonzini
Date: Fri Apr 29 2022 - 04:48:39 EST
On 4/29/22 03:03, Hillf Danton wrote:
Wonder if local lock classes [1] help.
[1]https://lore.kernel.org/lkml/165055518776.3745911.9346998911322224736.stgit@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/
No, they wouldn't. Local lock classes are more of a per-subsystem lock,
while here the issue is that we are taking an arbitrary amount of locks
at the same time.
Technically it would be possible to put a struct lock_class_key in
struct kvm_vcpu, but that wouldn't scale and would actually _reduce_ the
likelihood of lockdep reporting bad things.
The effectiveness of lockdep comes exactly from using the same map for
all locks in the class, so that AB/BA scenarios are caught throughout
the whole life of the system. If each lock has a separate they would be
caught only if the "B" is exactly the same mutex in both AB and BA cases.
Paolo