All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Maxim Levitsky <mlevitsk@redhat.com>
Cc: kvm@vger.kernel.org, Suzuki K Poulose <suzuki.poulose@arm.com>,
	Jing Zhang <jingzhangos@google.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Sebastian Ott <sebott@redhat.com>,
	Shusen Li <lishusen2@huawei.com>,
	Waiman Long <longman@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-arm-kernel@lists.infradead.org,
	Bjorn Helgaas <bhelgaas@google.com>,
	Borislav Petkov <bp@alien8.de>, Anup Patel <anup@brainfault.org>,
	Will Deacon <will@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Alexander Potapenko <glider@google.com>,
	kvmarm@lists.linux.dev,
	Keisuke Nishimura <keisuke.nishimura@inria.fr>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Atish Patra <atishp@atishpatra.org>,
	Joey Gouly <joey.gouly@arm.com>,
	x86@kernel.org, Sean Christopherson <seanjc@google.com>,
	Andre Przywara <andre.przywara@arm.com>,
	Kunkun Jiang <jiangkunkun@huawei.com>,
	linux-riscv@lists.infradead.org,
	Randy Dunlap <rdunlap@infradead.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Boqun Feng <boqun.feng@gmail.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Alexandre Ghiti <alex@ghiti.fr>,
	linux-kernel@vger.kernel.org,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Oliver Upton <oliver.upton@linux.dev>,
	kvm-riscv@lists.infradead.org, Ingo Molnar <mingo@redhat.com>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Albert Ou <aou@eecs.berkeley.edu>
Subject: Re: [PATCH v5 3/6] KVM: add kvm_lock_all_vcpus and kvm_trylock_all_vcpus
Date: Wed, 14 May 2025 10:33:50 +0100	[thread overview]
Message-ID: <86o6vvfse9.wl-maz@kernel.org> (raw)
In-Reply-To: <20250512180407.659015-4-mlevitsk@redhat.com>

On Mon, 12 May 2025 19:04:04 +0100,
Maxim Levitsky <mlevitsk@redhat.com> wrote:
> 
> In a few cases, usually in the initialization code, KVM locks all vCPUs
> of a VM to ensure that userspace doesn't do funny things while KVM performs
> an operation that affects the whole VM.
> 
> Until now, all these operations were implemented using custom code,
> and all of them share the same problem:
> 
> Lockdep can't cope with simultaneous locking of a large number of locks of
> the same class.
> 
> However if these locks are taken while another lock is already held,
> which is luckily the case, it is possible to take advantage of little known
> _nest_lock feature of lockdep which allows in this case to have an
> unlimited number of locks of same class to be taken.
> 
> To implement this, create two functions:
> kvm_lock_all_vcpus() and kvm_trylock_all_vcpus()
> 
> Both functions are needed because some code that will be replaced in
> the subsequent patches, uses mutex_trylock, instead of regular mutex_lock.
> 
> Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>

Acked-by: Marc Zyngier <maz@kernel.org>

	M.

-- 
Without deviation from the norm, progress is not possible.

-- 
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Maxim Levitsky <mlevitsk@redhat.com>
Cc: kvm@vger.kernel.org, Suzuki K Poulose <suzuki.poulose@arm.com>,
	Jing Zhang <jingzhangos@google.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Sebastian Ott <sebott@redhat.com>,
	Shusen Li <lishusen2@huawei.com>,
	Waiman Long <longman@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-arm-kernel@lists.infradead.org,
	Bjorn Helgaas <bhelgaas@google.com>,
	Borislav Petkov <bp@alien8.de>, Anup Patel <anup@brainfault.org>,
	Will Deacon <will@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Alexander Potapenko <glider@google.com>,
	kvmarm@lists.linux.dev,
	Keisuke Nishimura <keisuke.nishimura@inria.fr>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Atish Patra <atishp@atishpatra.org>,
	Joey Gouly <joey.gouly@arm.com>,
	x86@kernel.org, Sean Christopherson <seanjc@google.com>,
	Andre Przywara <andre.przywara@arm.com>,
	Kunkun Jiang <jiangkunkun@huawei.com>,
	linux-riscv@lists.infradead.org,
	Randy Dunlap <rdunlap@infradead.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Boqun Feng <boqun.feng@gmail.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Alexandre Ghiti <alex@ghiti.fr>,
	linux-kernel@vger.kernel.org,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Oliver Upton <oliver.upton@linux.dev>,
	kvm-riscv@lists.infradead.org, Ingo Molnar <mingo@redhat.com>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Albert Ou <aou@eecs.berkeley.edu>
Subject: Re: [PATCH v5 3/6] KVM: add kvm_lock_all_vcpus and kvm_trylock_all_vcpus
Date: Wed, 14 May 2025 10:33:50 +0100	[thread overview]
Message-ID: <86o6vvfse9.wl-maz@kernel.org> (raw)
In-Reply-To: <20250512180407.659015-4-mlevitsk@redhat.com>

On Mon, 12 May 2025 19:04:04 +0100,
Maxim Levitsky <mlevitsk@redhat.com> wrote:
> 
> In a few cases, usually in the initialization code, KVM locks all vCPUs
> of a VM to ensure that userspace doesn't do funny things while KVM performs
> an operation that affects the whole VM.
> 
> Until now, all these operations were implemented using custom code,
> and all of them share the same problem:
> 
> Lockdep can't cope with simultaneous locking of a large number of locks of
> the same class.
> 
> However if these locks are taken while another lock is already held,
> which is luckily the case, it is possible to take advantage of little known
> _nest_lock feature of lockdep which allows in this case to have an
> unlimited number of locks of same class to be taken.
> 
> To implement this, create two functions:
> kvm_lock_all_vcpus() and kvm_trylock_all_vcpus()
> 
> Both functions are needed because some code that will be replaced in
> the subsequent patches, uses mutex_trylock, instead of regular mutex_lock.
> 
> Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>

Acked-by: Marc Zyngier <maz@kernel.org>

	M.

-- 
Without deviation from the norm, progress is not possible.

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Maxim Levitsky <mlevitsk@redhat.com>
Cc: kvm@vger.kernel.org, Suzuki K Poulose <suzuki.poulose@arm.com>,
	Jing Zhang <jingzhangos@google.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Sebastian Ott <sebott@redhat.com>,
	Shusen Li <lishusen2@huawei.com>,
	Waiman Long <longman@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-arm-kernel@lists.infradead.org,
	Bjorn Helgaas <bhelgaas@google.com>,
	Borislav Petkov <bp@alien8.de>, Anup Patel <anup@brainfault.org>,
	Will Deacon <will@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Alexander Potapenko <glider@google.com>,
	kvmarm@lists.linux.dev,
	Keisuke Nishimura <keisuke.nishimura@inria.fr>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Atish Patra <atishp@atishpatra.org>,
	Joey Gouly <joey.gouly@arm.com>,
	x86@kernel.org, Sean Christopherson <seanjc@google.com>,
	Andre Przywara <andre.przywara@arm.com>,
	Kunkun Jiang <jiangkunkun@huawei.com>,
	linux-riscv@lists.infradead.org,
	Randy Dunlap <rdunlap@infradead.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Boqun Feng <boqun.feng@gmail.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Alexandre Ghiti <alex@ghiti.fr>,
	linux-kernel@vger.kernel.org,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Oliver Upton <oliver.upton@linux.dev>,
	kvm-riscv@lists.infradead.org, Ingo Molnar <mingo@redhat.com>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Albert Ou <aou@eecs.berkeley.edu>
Subject: Re: [PATCH v5 3/6] KVM: add kvm_lock_all_vcpus and kvm_trylock_all_vcpus
Date: Wed, 14 May 2025 10:33:50 +0100	[thread overview]
Message-ID: <86o6vvfse9.wl-maz@kernel.org> (raw)
In-Reply-To: <20250512180407.659015-4-mlevitsk@redhat.com>

On Mon, 12 May 2025 19:04:04 +0100,
Maxim Levitsky <mlevitsk@redhat.com> wrote:
> 
> In a few cases, usually in the initialization code, KVM locks all vCPUs
> of a VM to ensure that userspace doesn't do funny things while KVM performs
> an operation that affects the whole VM.
> 
> Until now, all these operations were implemented using custom code,
> and all of them share the same problem:
> 
> Lockdep can't cope with simultaneous locking of a large number of locks of
> the same class.
> 
> However if these locks are taken while another lock is already held,
> which is luckily the case, it is possible to take advantage of little known
> _nest_lock feature of lockdep which allows in this case to have an
> unlimited number of locks of same class to be taken.
> 
> To implement this, create two functions:
> kvm_lock_all_vcpus() and kvm_trylock_all_vcpus()
> 
> Both functions are needed because some code that will be replaced in
> the subsequent patches, uses mutex_trylock, instead of regular mutex_lock.
> 
> Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>

Acked-by: Marc Zyngier <maz@kernel.org>

	M.

-- 
Without deviation from the norm, progress is not possible.

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2025-05-14 12:18 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-12 18:04 [PATCH v5 0/6] KVM: lockdep improvements Maxim Levitsky
2025-05-12 18:04 ` Maxim Levitsky
2025-05-12 18:04 ` Maxim Levitsky
2025-05-12 18:04 ` [PATCH v5 1/6] locking/mutex: implement mutex_trylock_nested Maxim Levitsky
2025-05-12 18:04   ` Maxim Levitsky
2025-05-12 18:04   ` Maxim Levitsky
2025-05-12 18:04 ` [PATCH v5 2/6] locking/mutex: implement mutex_lock_killable_nest_lock Maxim Levitsky
2025-05-12 18:04   ` Maxim Levitsky
2025-05-12 18:04   ` Maxim Levitsky
2025-05-12 18:04 ` [PATCH v5 3/6] KVM: add kvm_lock_all_vcpus and kvm_trylock_all_vcpus Maxim Levitsky
2025-05-12 18:04   ` Maxim Levitsky
2025-05-12 18:04   ` Maxim Levitsky
2025-05-14  9:33   ` Marc Zyngier [this message]
2025-05-14  9:33     ` Marc Zyngier
2025-05-14  9:33     ` Marc Zyngier
2025-05-12 18:04 ` [PATCH v5 4/6] x86: KVM: SVM: use kvm_lock_all_vcpus instead of a custom implementation Maxim Levitsky
2025-05-12 18:04   ` Maxim Levitsky
2025-05-12 18:04   ` Maxim Levitsky
2025-05-12 18:04 ` [PATCH v5 5/6] KVM: arm64: use kvm_trylock_all_vcpus when locking all vCPUs Maxim Levitsky
2025-05-12 18:04   ` Maxim Levitsky
2025-05-12 18:04   ` Maxim Levitsky
2025-05-14  9:35   ` Marc Zyngier
2025-05-14  9:35     ` Marc Zyngier
2025-05-14  9:35     ` Marc Zyngier
2025-05-12 18:04 ` [PATCH v5 6/6] RISC-V: KVM: " Maxim Levitsky
2025-05-12 18:04   ` Maxim Levitsky
2025-05-12 18:04   ` Maxim Levitsky
2025-05-13 11:18   ` Anup Patel
2025-05-13 11:18     ` Anup Patel
2025-05-13 11:18     ` Anup Patel
2025-05-13 11:45 ` [PATCH v5 0/6] KVM: lockdep improvements Peter Zijlstra
2025-05-13 11:45   ` Peter Zijlstra
2025-05-13 11:45   ` Peter Zijlstra
2025-05-27 16:23 ` Paolo Bonzini
2025-06-10 16:28 ` patchwork-bot+linux-riscv
2025-06-10 16:28   ` patchwork-bot+linux-riscv
2025-06-10 16:28   ` patchwork-bot+linux-riscv
  -- strict thread matches above, loose matches on Subject: below --
2025-05-15 22:20 [PATCH v5 3/6] KVM: add kvm_lock_all_vcpus and kvm_trylock_all_vcpus kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86o6vvfse9.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=alex@ghiti.fr \
    --cc=andre.przywara@arm.com \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=atishp@atishpatra.org \
    --cc=bhelgaas@google.com \
    --cc=boqun.feng@gmail.com \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=glider@google.com \
    --cc=hpa@zytor.com \
    --cc=jiangkunkun@huawei.com \
    --cc=jingzhangos@google.com \
    --cc=joey.gouly@arm.com \
    --cc=keisuke.nishimura@inria.fr \
    --cc=kvm-riscv@lists.infradead.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=lishusen2@huawei.com \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=mlevitsk@redhat.com \
    --cc=oliver.upton@linux.dev \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rdunlap@infradead.org \
    --cc=seanjc@google.com \
    --cc=sebott@redhat.com \
    --cc=suzuki.poulose@arm.com \
    --cc=tglx@linutronix.de \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.