Linux kernel -stable discussions
 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>, Marc Zyngier <maz@kernel.org>,
	Oliver Upton <oupton@kernel.org>,
	Fuad Tabba <fuad.tabba@linux.dev>,
	Joey Gouly <joey.gouly@arm.com>,
	Steffen Eiden <seiden@linux.ibm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Christoffer Dall <christoffer.dall@linaro.org>,
	Jintack Lim <jintack.lim@linaro.org>,
	Wei-Lin Chang <weilin.chang@arm.com>,
	Yanan Wang <wangyanan55@huawei.com>,
	linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
	linux-kernel@vger.kernel.org, Usama Arif <usama.arif@linux.dev>,
	stable@vger.kernel.org
Subject: Re: [PATCH v2] KVM: arm64: Unconditionally top up the mmu memcache on user fault
Date: Fri,  4 Dec 2026 13:39:59 +0000	[thread overview]
Message-ID: <axLCr45WLAFKntvh@LeoBrasDK> (raw)
In-Reply-To: <20261203-fix-nv-cache-topup-v2-1-afc8fc1f87a2@kernel.org>

On Thu, Dec 03, 2026 at 06:45:24PM +0000, Lorenzo Stoakes (ARM) wrote:
> The S2 user fault path tops up the MMU memcache (used for page table
> pre-allocation as the point at which page tables are installed may not
> allocate) except when:
> 
> * It's a permission fault AND
> * dirty page logging is disabled AND
> * pKVM is disabled
> 
> At which point it is assumed no page table will be allocated.
> 
> However this is not safe - if the mapping size differs from that at which
> the permission fault was taken, we must install a new mapping, which may
> require a page table. This can happen when:
> 
> * A guest hypervisor replaces a block in its own S2 with a table without
>   issuing a TLBI (likely due to a bug) - the shadow S2 mapping size is
>   clamped to that of the guest's S2, so the shadow block has to be
>   collapsed.
> 
> * A guest hypervisor does issue the TLBI, but races with another vCPU
>   which has already taken a permission fault on the shadow block.
> 
> * Nested virtualisation isn't in use at all, but the VMM replaces a THP
>   with 64K hugetlb pages while a permission fault on it is in flight.
> 
> With the memcache empty, kvm_mmu_memory_cache_alloc() hits its
> guest-triggerable WARN_ON(!nobjs) and falls back to a GFP_ATOMIC allocation
> under mmu_lock, with a BUG_ON() if that fails.
> 
> Therefore, top up the memcache unconditionally. This is cheap, as the top
> up does nothing if the cache already holds enough objects.
> 
> Note that dirty logging had a similar issue, addressed in
> commit 56fd1fc526e6 ("KVM: arm64: Top up stage-2 memcache for dirty
> logging faults").
> 
> Local testing with dirty logging disabled indicated no performance
> impact.
> 
> kvm_page_table_test was modified to take 65,536 permission faults with
> dirty logging disabled, and run on an Apple M2 with the kernel under test
> running as an NV guest. The median time across ~70 runs was 1.059s without
> this patch and 1.062s with it.

Cool!
I wonder how that will impact with Usama's patch prepended.

Thanks!
Leo

  reply	other threads:[~2026-12-04 13:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 18:45 [PATCH v2] KVM: arm64: Unconditionally top up the mmu memcache on user fault Lorenzo Stoakes (ARM)
2026-12-04 13:39 ` Leonardo Bras [this message]
2026-12-04 14:22 ` Usama Arif

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=axLCr45WLAFKntvh@LeoBrasDK \
    --to=leo.bras@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=christoffer.dall@linaro.org \
    --cc=fuad.tabba@linux.dev \
    --cc=jintack.lim@linaro.org \
    --cc=joey.gouly@arm.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=seiden@linux.ibm.com \
    --cc=stable@vger.kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=usama.arif@linux.dev \
    --cc=wangyanan55@huawei.com \
    --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