[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CABgObfbH6JAh0Puu6gTKfkLd+e5uqSyHHP5i86W-=G6x5zr1wg@mail.gmail.com>
Date: Thu, 17 Apr 2025 11:53:54 +0200
From: Paolo Bonzini <pbonzini@...hat.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Maxim Levitsky <mlevitsk@...hat.com>, kvm@...r.kernel.org,
Alexander Potapenko <glider@...gle.com>, "H. Peter Anvin" <hpa@...or.com>,
Suzuki K Poulose <suzuki.poulose@....com>, kvm-riscv@...ts.infradead.org,
Oliver Upton <oliver.upton@...ux.dev>, Dave Hansen <dave.hansen@...ux.intel.com>,
Jing Zhang <jingzhangos@...gle.com>, Waiman Long <longman@...hat.com>, x86@...nel.org,
Kunkun Jiang <jiangkunkun@...wei.com>, Boqun Feng <boqun.feng@...il.com>,
Anup Patel <anup@...infault.org>, Albert Ou <aou@...s.berkeley.edu>, kvmarm@...ts.linux.dev,
linux-kernel@...r.kernel.org, Zenghui Yu <yuzenghui@...wei.com>,
Borislav Petkov <bp@...en8.de>, Alexandre Ghiti <alex@...ti.fr>,
Keisuke Nishimura <keisuke.nishimura@...ia.fr>, Sebastian Ott <sebott@...hat.com>,
Atish Patra <atishp@...shpatra.org>, Paul Walmsley <paul.walmsley@...ive.com>,
Randy Dunlap <rdunlap@...radead.org>, Will Deacon <will@...nel.org>,
Palmer Dabbelt <palmer@...belt.com>, linux-riscv@...ts.infradead.org,
Marc Zyngier <maz@...nel.org>, linux-arm-kernel@...ts.infradead.org,
Joey Gouly <joey.gouly@....com>, Ingo Molnar <mingo@...hat.com>,
Andre Przywara <andre.przywara@....com>, Thomas Gleixner <tglx@...utronix.de>,
Sean Christopherson <seanjc@...gle.com>, Catalin Marinas <catalin.marinas@....com>,
Bjorn Helgaas <bhelgaas@...gle.com>
Subject: Re: [PATCH v2 2/4] KVM: x86: move sev_lock/unlock_vcpus_for_migration
to kvm_main.c
On Wed, Apr 16, 2025 at 8:50 PM Peter Zijlstra <peterz@...radead.org> wrote:
> > For the ARM case, which is the actual buggy one (it was complaining
> > about too high a depth) it still needs mutex_trylock_nest_lock();
> > the nest_lock is needed to avoid bumping the depth on every
> > mutex_trylock().
>
> Got a link to the ARM code in question ?
lock_all_vcpus() in arch/arm64/kvm/arm.c:
lockdep_assert_held(&kvm->lock);
kvm_for_each_vcpu(c, tmp_vcpu, kvm) {
if (!mutex_trylock(&tmp_vcpu->mutex)) {
unlock_vcpus(kvm, c - 1);
return false;
}
}
> And I'm assuming you're talking about task_struct::lockdep_depth ?
> The nest lock annotation does not in fact increment depth beyond
> one of each type. It does a refcount like thing.
Yes, exactly - mutex_trylock_nest_lock() is needed so that the
code above counts per-lock instead of using the per-task depth.
Paolo
Powered by blists - more mailing lists