From: Oliver Upton <oupton@kernel.org>
To: Nathan Chen <nathanc@nvidia.com>
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: Tue, 24 Nov 2026 14:29:09 -0800 [thread overview]
Message-ID: <awYPtXVeY1NYeTla@kernel.org> (raw)
In-Reply-To: <20261124211218.2751086-1-nathanc@nvidia.com>
Hi Nathan,
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,
Oliver
prev parent reply other threads:[~2026-11-24 22:41 UTC|newest]
Thread overview: 8+ 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 ` Oliver Upton [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=awYPtXVeY1NYeTla@kernel.org \
--to=oupton@kernel.org \
--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=nathanc@nvidia.com \
--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