* [PATCH] KVM: arm64: Count pKVM stage-2 usage in secondary pagetable stats
@ 2025-02-28 12:13 Vincent Donnefort
2025-03-03 21:18 ` Oliver Upton
0 siblings, 1 reply; 3+ messages in thread
From: Vincent Donnefort @ 2025-02-28 12:13 UTC (permalink / raw)
To: maz, oliver.upton, joey.gouly, suzuki.poulose, yuzenghui,
catalin.marinas, will
Cc: qperret, linux-arm-kernel, kvmarm, linux-kernel, kernel-team,
Vincent Donnefort
Count the pages used by pKVM for the guest stage-2 in memory stats under
secondary pagetable stats, similarly to what the VHE mode does.
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
index 1f55b0c7b11d..c2e022c41313 100644
--- a/arch/arm64/kvm/mmu.c
+++ b/arch/arm64/kvm/mmu.c
@@ -1088,12 +1088,18 @@ void kvm_free_stage2_pgd(struct kvm_s2_mmu *mmu)
static void hyp_mc_free_fn(void *addr, void *unused)
{
+ kvm_account_pgtable_pages(addr, -1);
free_page((unsigned long)addr);
}
static void *hyp_mc_alloc_fn(void *unused)
{
- return (void *)__get_free_page(GFP_KERNEL_ACCOUNT);
+ void *addr = (void *)__get_free_page(GFP_KERNEL_ACCOUNT);
+
+ if (addr)
+ kvm_account_pgtable_pages(addr, 1);
+
+ return addr;
}
void free_hyp_memcache(struct kvm_hyp_memcache *mc)
base-commit: d082ecbc71e9e0bf49883ee4afd435a77a5101b6
--
2.48.1.711.g2feabab25a-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] KVM: arm64: Count pKVM stage-2 usage in secondary pagetable stats
2025-02-28 12:13 [PATCH] KVM: arm64: Count pKVM stage-2 usage in secondary pagetable stats Vincent Donnefort
@ 2025-03-03 21:18 ` Oliver Upton
2025-03-04 9:03 ` Vincent Donnefort
0 siblings, 1 reply; 3+ messages in thread
From: Oliver Upton @ 2025-03-03 21:18 UTC (permalink / raw)
To: Vincent Donnefort
Cc: maz, joey.gouly, suzuki.poulose, yuzenghui, catalin.marinas, will,
qperret, linux-arm-kernel, kvmarm, linux-kernel, kernel-team
On Fri, Feb 28, 2025 at 12:13:55PM +0000, Vincent Donnefort wrote:
> Count the pages used by pKVM for the guest stage-2 in memory stats under
> secondary pagetable stats, similarly to what the VHE mode does.
>
> Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
>
> diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
> index 1f55b0c7b11d..c2e022c41313 100644
> --- a/arch/arm64/kvm/mmu.c
> +++ b/arch/arm64/kvm/mmu.c
> @@ -1088,12 +1088,18 @@ void kvm_free_stage2_pgd(struct kvm_s2_mmu *mmu)
>
> static void hyp_mc_free_fn(void *addr, void *unused)
> {
> + kvm_account_pgtable_pages(addr, -1);
> free_page((unsigned long)addr);
> }
Don't we drain more than just stage-2 page tables into the teardown_mc
(e.g. vcpu structs)?
Thanks,
Oliver
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] KVM: arm64: Count pKVM stage-2 usage in secondary pagetable stats
2025-03-03 21:18 ` Oliver Upton
@ 2025-03-04 9:03 ` Vincent Donnefort
0 siblings, 0 replies; 3+ messages in thread
From: Vincent Donnefort @ 2025-03-04 9:03 UTC (permalink / raw)
To: Oliver Upton
Cc: maz, joey.gouly, suzuki.poulose, yuzenghui, catalin.marinas, will,
qperret, linux-arm-kernel, kvmarm, linux-kernel, kernel-team
On Mon, Mar 03, 2025 at 01:18:35PM -0800, Oliver Upton wrote:
> On Fri, Feb 28, 2025 at 12:13:55PM +0000, Vincent Donnefort wrote:
> > Count the pages used by pKVM for the guest stage-2 in memory stats under
> > secondary pagetable stats, similarly to what the VHE mode does.
> >
> > Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
> >
> > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
> > index 1f55b0c7b11d..c2e022c41313 100644
> > --- a/arch/arm64/kvm/mmu.c
> > +++ b/arch/arm64/kvm/mmu.c
> > @@ -1088,12 +1088,18 @@ void kvm_free_stage2_pgd(struct kvm_s2_mmu *mmu)
> >
> > static void hyp_mc_free_fn(void *addr, void *unused)
> > {
> > + kvm_account_pgtable_pages(addr, -1);
> > free_page((unsigned long)addr);
> > }
>
> Don't we drain more than just stage-2 page tables into the teardown_mc
> (e.g. vcpu structs)?
Sigh, yes we do. I've left behind some changes we have in our Android branches.
Let me respin a proper version :-\
>
> Thanks,
> Oliver
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-04 9:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-28 12:13 [PATCH] KVM: arm64: Count pKVM stage-2 usage in secondary pagetable stats Vincent Donnefort
2025-03-03 21:18 ` Oliver Upton
2025-03-04 9:03 ` Vincent Donnefort
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).