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

From: Peter Gonda
Date: Mon Apr 04 2022 - 18:29:03 EST


>
> This is rather gross, and I'm guessing it adds extra work for the non-lockdep
> case, assuming the compiler isn't so clever that it can figure out that the result
> is never used. Not that this is a hot path...
>
> Does each lock actually need a separate subclass? If so, why don't the other
> paths that lock all vCPUs complain?
>
> If differentiating the two VMs is sufficient, then we can pass in SINGLE_DEPTH_NESTING
> for the second round of locks. If a per-vCPU subclass is required, we can use the
> vCPU index and assign evens to one and odds to the other, e.g. this should work and
> compiles to a nop when LOCKDEP is disabled (compile tested only). It's still gross,
> but we could pretty it up, e.g. add defines for the 0/1 param.

I checked and the perf vCPU subclassing is required. If I just only
use a SINGLE_DEPTH_NESTING on the second VM's vCPUs I still see the
warning.

This odds and evens approach seems much better. I'll update to use
that in the V2 unless there is a better idea.