Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chen <nathanc@nvidia.com>
To: Oliver Upton <oupton@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
	linux-kernel@vger.kernel.org, Mark Rutland <mark.rutland@arm.com>,
	Will Deacon <will@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Steffen Eiden <seiden@linux.ibm.com>,
	Joey Gouly <joey.gouly@arm.com>,
	Fuad Tabba <fuad.tabba@linux.dev>, Marc Zyngier <maz@kernel.org>,
	Tom Matthias <tmatthias@nvidia.com>,
	Shameer Kolothum Thodi <skolothumtho@nvidia.com>,
	Jason Gunthorpe <jgg@nvidia.com>,
	Julian Miller <julianmiller@nvidia.com>
Subject: Re: [RFC PATCH 0/6] KVM: arm64: nv: Grow the shadow S2 MMU pool on demand
Date: Wed, 25 Nov 2026 14:36:49 -0800	[thread overview]
Message-ID: <6bed8c59-476b-442d-a8a5-158fa0d9d978@nvidia.com> (raw)
In-Reply-To: <awYPtXVeY1NYeTla@kernel.org>

Hi Oliver,

On 11/24/2026 2:29 PM, Oliver Upton wrote:
> On Tue, Nov 24, 2026 at 01:12:12PM -0800, Nathan Chen wrote:
>> A nested-capable VM gets 2 shadow stage-2 MMUs per vcpu. Once the guest
>> hypervisor runs more nested VMs than that, nearly every nested context
>> switch recycles a live MMU and spikes host CPU usage.
>>
>> This series lets KVM grow the shadow MMU pool on demand when the pool
>> is too small, up to a host-wide VMID budget. It also parks grown MMUs
>> on a guest TLBI ALLE1 and when a guest range invalidation leaves them
>> empty, in order to return unused capacity.
> Thanks for taking a look at the problem. There's no argument that we
> need to do something, the existing MMU allocation policy was good enough
> for doing nested development and would get replaced eventually.
> 
> With that said, I feel rather strongly that we should not invest further
> in the MMU array because it is quite inflexible. On top of that we need
> an actual eviction policy that selects cold MMUs as victims instead of
> the current round robin approach. I don't think you need to do anything
> special on the invalidation side with a good eviction policy.
> 
> I think this is what we need:
> 
>   - A VM-wide hashtable for storing stage-2 MMUs, keyed off of
>     {VTCR_EL2, VTTBR_EL2, HCR_EL2.VM} to align with how we handle TLB
>     match at stage-2. The hashtable can be dimensioned based on a
>     configurable VM limit for shadow stage-2 MMUs.
> 
>   - A state tracking mechanism for victim selection. An LRU list seems
>     like a reasonable starting point.
> 
>   - RCU replacement of the evicted MMU. I need to think about it a bit
>     more but you should be able to reuse the PGD in the new MMU context
>     as well since we know that no vCPU holds a reference on the victim.
>     That ought to be the goal anyway.
> 
> That should allow us to dynamically allocate MMUs while also improving
> upon the current behavior for constrained MMU allocations.

Thanks for the detailed direction, that makes sense. I'll drop the
array-based approach, including the invalidation-side parking, and
rework the series around the approach you mentioned above.

For the per-VM limit, should we keep it capped at
S2_MMU_PER_VCPU * nr_vcpus by default? And should it be overridable
via a module parameter or per-VM capability, or would you prefer no
per-VM cap at all, with the pool growing on demand and only evicting
when allocation fails?

Thanks,
Nathan


      reply	other threads:[~2026-11-25 22:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 21:12 [RFC PATCH 0/6] KVM: arm64: nv: Grow the shadow S2 MMU pool on demand Nathan Chen
2026-11-24 21:12 ` [RFC PATCH 1/6] KVM: arm64: nv: Allocate shadow S2 MMUs in blocks Nathan Chen
2026-11-24 21:12 ` [RFC PATCH 2/6] KVM: arm64: nv: Pick the shadow S2 MMU to recycle with a clock Nathan Chen
2026-11-24 21:12 ` [RFC PATCH 3/6] KVM: arm64: Add kvm_arm_vmid_nr_usable() Nathan Chen
2026-11-24 21:12 ` [RFC PATCH 4/6] KVM: arm64: nv: Grow the shadow S2 MMU pool on demand Nathan Chen
2026-11-24 21:12 ` [RFC PATCH 5/6] KVM: arm64: nv: Park grown MMUs on ALLE1 and reactivate them " Nathan Chen
2026-11-24 21:12 ` [RFC PATCH 6/6] KVM: arm64: nv: Park shadow S2 MMUs emptied by a guest range invalidation Nathan Chen
2026-11-24 22:29 ` [RFC PATCH 0/6] KVM: arm64: nv: Grow the shadow S2 MMU pool on demand Oliver Upton
2026-11-25 22:36   ` Nathan Chen [this message]

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=6bed8c59-476b-442d-a8a5-158fa0d9d978@nvidia.com \
    --to=nathanc@nvidia.com \
    --cc=catalin.marinas@arm.com \
    --cc=fuad.tabba@linux.dev \
    --cc=jgg@nvidia.com \
    --cc=joey.gouly@arm.com \
    --cc=julianmiller@nvidia.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=seiden@linux.ibm.com \
    --cc=skolothumtho@nvidia.com \
    --cc=suzuki.poulose@arm.com \
    --cc=tmatthias@nvidia.com \
    --cc=will@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox