* [PATCH] KVM: x86/mmu: Respect user goal_nr_mmu_pages after zapping oldest pages
@ 2026-09-11 6:41 fuqiang wang
0 siblings, 0 replies; only message in thread
From: fuqiang wang @ 2026-09-11 6:41 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini, kvm, linux-kernel
Cc: fuqiang wang, yaowenchao1, dongxu zhang
When kvm_mmu_change_mmu_pages() shrinks the shadow page limit and the
current number of shadow pages exceeds the requested goal, it zaps the
oldest MMU pages and then updates n_max_mmu_pages.
Previously the new limit was set unconditionally to the current
mmu_shadow_pages value observed after zapping. However, zapping can
reduce mmu_shadow_pages below the user-requested goal_nr_mmu_pages,
since a single __kvm_mmu_prepare_zap_page() may reclaim more than one
MMU page (it also zaps unsync/child pages). This could then clamp the
limit below the user's intent.
Use max(mmu_shadow_pages, goal_nr_mmu_pages) so the user-requested goal
is honored even if zapping overshoots.
Signed-off-by: fuqiang wang <fuqiang.wng@gmail.com>
---
arch/x86/kvm/mmu/mmu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 064ecc33b926..efeba58936a6 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -2913,7 +2913,7 @@ void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned long goal_nr_mmu_pages)
kvm_mmu_zap_oldest_mmu_pages(kvm, kvm->stat.mmu_shadow_pages -
goal_nr_mmu_pages);
- goal_nr_mmu_pages = kvm->stat.mmu_shadow_pages;
+ goal_nr_mmu_pages = max(kvm->stat.mmu_shadow_pages, goal_nr_mmu_pages);
}
kvm->arch.n_max_mmu_pages = goal_nr_mmu_pages;
--
2.47.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-11 6:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-11 6:41 [PATCH] KVM: x86/mmu: Respect user goal_nr_mmu_pages after zapping oldest pages fuqiang wang
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®