Re: [PATCH] KVM: arm64: Reduce the stage-2 page cache on 64 KiB hosts

From: Lorenzo Stoakes (ARM)

Date: Thu Nov 26 2026 - 11:53:00 EST


On Thu, Nov 26, 2026 at 03:58:11PM +0000, Marc Zyngier wrote:
> On Thu, 26 Nov 2026 14:32:04 +0000,
> Usama Arif <usama.arif@xxxxxxxxx> wrote:
>
> [nonsense deleted]
>
> > > Now, to the patch itself: I see no reason to special-case this. If
> > > kvm_mmu_cache_min_pages() is an indication of what is needed, then
> > > this macro should be driven by it, or the whole allocator take it into
> > > account. And then you adjust it by whatever fudge factor seems
> > > appropriate.
> > >
> >
> > Completely agree! [1] does that: no page-size special case, and
> > a capacity of KVM_PGTABLE_LAST_LEVEL - KVM_PGTABLE_FIRST_LEVEL for every
> > page size. It can't track kvm_mmu_cache_min_pages()
> > at runtime: the vCPU's cache is shared by the canonical and NV shadow
> > MMUs, and its capacity must stay fixed. So it has to cover the largest
> > minimum, which stage-2 caps at 3, and 4 is that plus one page of fudge.
>
> Of course it can. That's not exactly rock science to add, rather than
> relying on another set of bad heuristics. And this must cover more
> than a single mapping per top-up, because that has a ripple effect on
> the speed at which we can split large blocks (funnily enough, people
> care about that stuff).

Hmm is splitting a factor here re: the cache?

In kvm_mmu_split_huge_pages() it is using kvm->arch.mmu.split_page_cache which
is a separate cache altogether right?

And splitting on fault is via e.g. kvm_vm_mem_abort() -> user_mem_abort() which
tops up anyway? (Minus an NV case which is a bug I think, I can send that as a
patch separately? I mention in another reply.)

Maybe I missed a case?

Re: the speed, having bigger cache size doesn't speed anything up as the refill
refills to the max each time, so you're doing the same # of allocations, just
maybe with a much bigger latency on one fault (seems bad to me)?


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

--
Cheers, Lorenzo