Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Upton <oupton@kernel.org>
To: Wei-Lin Chang <weilin.chang@arm.com>
Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
	linux-kernel@vger.kernel.org, Marc Zyngier <maz@kernel.org>,
	Fuad Tabba <tabba@google.com>, 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>,
	Itaru Kitayama <itaru.kitayama@fujitsu.com>,
	Sebastian Ene <sebastianene@google.com>
Subject: Re: [PATCH v4 3/6] KVM: arm64: nv: Add nested revmap broken tracepoint
Date: Wed, 15 Jul 2026 23:45:05 -0700	[thread overview]
Message-ID: <alh98Zz42OdWo-jp@kernel.org> (raw)
In-Reply-To: <20260714115926.2044757-4-weilin.chang@arm.com>

Hi Wei-Lin,

On Tue, Jul 14, 2026 at 12:59:22PM +0100, Wei-Lin Chang wrote:
> Add a tracepoint to track when a nested reverse map becomes broken. This
> makes it easier to detect NV performance degradation caused by full
> shadow stage-2 unmaps.
> 
> Signed-off-by: Wei-Lin Chang <weilin.chang@arm.com>

I'm not too excited about making a tracepoint out of this, especially
since a 'broken' reverse map is more of a KVM implementation detail
(that could change) than anything else.

BPF is quite popular at this point, do you think it's reasonable to
instead expect the curious KVM developer to attach a kprobe and inspect
the state of the nested MMU?

Thanks,
Oliver

> ---
>  arch/arm64/kvm/nested.c    |  7 ++++++-
>  arch/arm64/kvm/trace_arm.h | 27 +++++++++++++++++++++++++++
>  2 files changed, 33 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kvm/nested.c b/arch/arm64/kvm/nested.c
> index 065823e415ce..22f8a1daca93 100644
> --- a/arch/arm64/kvm/nested.c
> +++ b/arch/arm64/kvm/nested.c
> @@ -17,6 +17,7 @@
>  #include <asm/sysreg.h>
>  
>  #include "sys_regs.h"
> +#include "trace.h"
>  
>  struct vncr_tlb {
>  	/* The guest's VNCR_EL2 */
> @@ -916,8 +917,12 @@ void kvm_record_nested_revmap(gpa_t canonical_ipa, struct kvm_s2_mmu *mmu,
>  
>  	mas_set_range(&mas_rmap, canonical_ipa, canonical_ipa_end);
>  	if (mas_store_gfp(&mas_rmap, xa_mk_value(new_entry),
> -			  GFP_NOWAIT | __GFP_ACCOUNT))
> +			  GFP_NOWAIT | __GFP_ACCOUNT)) {
> +		trace_kvm_nested_revmap_broken(mmu - mmu->arch->nested_mmus,
> +					       canonical_ipa, canonical_ipa_end,
> +					       nested_ipa, new_entry);
>  		mmu->nested_revmap_broken = true;
> +	}
>  unlock:
>  	mtree_unlock(revmap_mt);
>  }
> diff --git a/arch/arm64/kvm/trace_arm.h b/arch/arm64/kvm/trace_arm.h
> index 9c60f6465c78..0db90068ff63 100644
> --- a/arch/arm64/kvm/trace_arm.h
> +++ b/arch/arm64/kvm/trace_arm.h
> @@ -415,6 +415,33 @@ TRACE_EVENT(kvm_forward_sysreg_trap,
>  		      sys_reg_Op2(__entry->sysreg))
>  );
>  
> +TRACE_EVENT(kvm_nested_revmap_broken,
> +	    TP_PROTO(int mmu_idx, unsigned long canonical_ipa,
> +		     unsigned long canonical_ipa_end, unsigned long nested_ipa,
> +		     unsigned long revmap_entry),
> +	    TP_ARGS(mmu_idx, canonical_ipa, canonical_ipa_end, nested_ipa, revmap_entry),
> +
> +	    TP_STRUCT__entry(
> +		__field(int,			mmu_idx)
> +		__field(unsigned long,		canonical_ipa)
> +		__field(unsigned long,		nested_ipa)
> +		__field(size_t,			size)
> +		__field(unsigned long,		revmap_entry)
> +	    ),
> +
> +	    TP_fast_assign(
> +		__entry->mmu_idx = mmu_idx;
> +		__entry->canonical_ipa = canonical_ipa;
> +		__entry->nested_ipa = nested_ipa;
> +		__entry->size = canonical_ipa_end - canonical_ipa + 1;
> +		__entry->revmap_entry = revmap_entry;
> +	    ),
> +
> +	    TP_printk("mmu idx: %d, cipa: 0x%016lx, nipa: 0x%016lx, size: 0x%016lx, entry: %016lx",
> +		      __entry->mmu_idx, __entry->canonical_ipa, __entry->nested_ipa,
> +		      __entry->size, __entry->revmap_entry)
> +);
> +
>  #endif /* _TRACE_ARM_ARM64_KVM_H */
>  
>  #undef TRACE_INCLUDE_PATH
> -- 
> 2.43.0
> 


  reply	other threads:[~2026-07-16  6:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-14 11:59 [PATCH v4 0/6] KVM: arm64: nv: Implement nested stage-2 reverse map Wei-Lin Chang
2026-07-14 11:59 ` [PATCH v4 1/6] KVM: arm64: Use a variable for the canonical GPA in kvm_s2_fault_map() Wei-Lin Chang
2026-07-14 11:59 ` [PATCH v4 2/6] KVM: arm64: nv: Avoid full shadow s2 unmap Wei-Lin Chang
2026-07-16  7:05   ` Oliver Upton
2026-07-14 11:59 ` [PATCH v4 3/6] KVM: arm64: nv: Add nested revmap broken tracepoint Wei-Lin Chang
2026-07-16  6:45   ` Oliver Upton [this message]
2026-07-16  8:56     ` Marc Zyngier
2026-07-14 11:59 ` [PATCH v4 4/6] KVM: arm64: Refactor kvm_unmap_gfn_range() with common variables Wei-Lin Chang
2026-07-14 11:59 ` [PATCH v4 5/6] KVM: arm64: nv: Remove reverse map entries during TLBI handling Wei-Lin Chang
2026-07-14 11:59 ` [PATCH v4 6/6] KVM: arm64: nv: Create nested IPA direct map to speed up reverse map removal Wei-Lin Chang

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=alh98Zz42OdWo-jp@kernel.org \
    --to=oupton@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=itaru.kitayama@fujitsu.com \
    --cc=joey.gouly@arm.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=sebastianene@google.com \
    --cc=seiden@linux.ibm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=tabba@google.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