mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Leonardo Bras <leo.bras@arm.com>
To: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
Cc: Leonardo Bras <leo.bras@arm.com>,
	Wei-Lin Chang <weilin.chang@arm.com>,
	Usama Arif <usama.arif@linux.dev>,
	maz@kernel.org, oupton@kernel.org, fuad.tabba@linux.dev,
	joey.gouly@arm.com, seiden@linux.ibm.com, suzuki.poulose@arm.com,
	yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org,
	mark.rutland@arm.com, kvmarm@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, riel@surriel.com,
	shakeel.butt@linux.dev, kernel-team@meta.com, rkeilty@meta.com,
	atish.patra@linux.dev, dgreid@meta.com
Subject: Re: [PATCH] KVM: arm64: Reduce the stage-2 page cache on 64 KiB hosts
Date: Thu, 26 Nov 2026 17:44:20 +0000	[thread overview]
Message-ID: <awhv9JeCtZxH3Y5x@LeoBrasDK> (raw)
In-Reply-To: <awhpQIWN3msQ2ruf@gremlin>

On Thu, Nov 26, 2026 at 05:18:00PM +0000, Lorenzo Stoakes (ARM) wrote:
> On Thu, Nov 26, 2026 at 05:07:21PM +0000, Leonardo Bras wrote:
> > On Thu, Nov 26, 2026 at 04:45:35PM +0000, Lorenzo Stoakes (ARM) wrote:
> > > The question is would going from 40 to 3 slow things down?
> > >
> > > At 40 you do 40 __get_free_page() calls on topup for the _first_ fault that hits
> > > it, which adds latency to a random s2 fault (not great).
> > >
> > > (If the fault doesn't in fact use a page table, this is only done once until a
> > > page table is next needed).
> > >
> > > And then as 37 page tables are mapped, those ones don't get allocations at 38
> > > you go again...
> > >
> > > With 3 in the cache you allocate up to 3 for each fault.
> > >
> > > So in both cases you allocate the same amount of pages but in the 40 case it's
> > > all bunched up on one s2 fault with a jump in latency, in the 3 case it's spread
> > > out.
> > >
> > > I'd say 3 is therefore the better choice.
> > >
> > > Also, as mentioned elsewhere, you end up leaking pages once the S2 page tables
> > > are setup until the vCPU is destroyed, as nothing clears down the cache
> > > AFAICT. With 40 that's way more than with 3.
> > >
> > > --
> > > Cheers, Lorenzo
> >
> > Hi Lorenzo,
> >
> > When I mention cache locality above, I mean the cpu cache. Running the same
> > routine 40 times in a row can be faster since all instructions are already
> > cached, and most of the data acessed by it could be local as well.
> >
> > If you run it more often, it could be that something else used the
> > cachelines and the cpu has to fetch them again from lower level caches or
> > memory.
> >
> > That being said, that's the only reason batch allocating 40 would be faster
> > than 4 in the long run. For capacity=4, the number of
> > mmu_memory_cache_alloc_obj() calls can be even smaller than capacity=40,
> > since we don't leave unused pages in the kvm_mmu_memory_cache.
> 
> Ah right I see what you mean, true that would be warmer, but I suspect that'd be
> lost in the noise vs. zeroing each page anyway, and additionally you can argue
> that, if you just zeroed a page before the walk uses it, there's locality
> advantages on that vs. batched too.

Ah, you are right! I was ignoring the zeroing for some reason.

> 
> But again I'd be very surprised if there was any impact on that either way,
> really.

Fully agree

> 
> In any case it seems we agree that a smaller capacity is the way to go :)
> 

Awesome! Thanks!
Leo

  reply	other threads:[~2026-11-26 17:44 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 15:28 Usama Arif
2026-11-25 17:14 ` Leonardo Bras
2026-11-25 17:55   ` Usama Arif
2026-11-25 18:25     ` Leonardo Bras
2026-11-25 21:42       ` Usama Arif
2026-11-26  8:06         ` Wei-Lin Chang
2026-11-26 15:19           ` Leonardo Bras
2026-11-26 15:34             ` Wei-Lin Chang
2026-11-26 15:55               ` Leonardo Bras
2026-11-26 16:45                 ` Lorenzo Stoakes (ARM)
2026-11-26 17:07                   ` Leonardo Bras
2026-11-26 17:18                     ` Lorenzo Stoakes (ARM)
2026-11-26 17:44                       ` Leonardo Bras [this message]
2026-11-26 16:30           ` Lorenzo Stoakes (ARM)
2026-11-26 16:53             ` Lorenzo Stoakes (ARM)
2026-11-26 18:25             ` Leonardo Bras
2026-11-26 12:56 ` Marc Zyngier
2026-11-26 14:32   ` Usama Arif
2026-11-26 15:58     ` Marc Zyngier
2026-11-26 16:52       ` Lorenzo Stoakes (ARM)

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=awhv9JeCtZxH3Y5x@LeoBrasDK \
    --to=leo.bras@arm.com \
    --cc=atish.patra@linux.dev \
    --cc=catalin.marinas@arm.com \
    --cc=dgreid@meta.com \
    --cc=fuad.tabba@linux.dev \
    --cc=joey.gouly@arm.com \
    --cc=kernel-team@meta.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ljs@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=riel@surriel.com \
    --cc=rkeilty@meta.com \
    --cc=seiden@linux.ibm.com \
    --cc=shakeel.butt@linux.dev \
    --cc=suzuki.poulose@arm.com \
    --cc=usama.arif@linux.dev \
    --cc=weilin.chang@arm.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

all inboxes | Powered by JetHome®