]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: X86: Add per-vm stat for max rmap list size
authorPeter Xu <peterx@redhat.com>
Fri, 25 Jun 2021 15:32:06 +0000 (11:32 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 2 Aug 2021 13:36:37 +0000 (09:36 -0400)
Add a new statistic max_mmu_rmap_size, which stores the maximum size of rmap
for the vm.

Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <20210625153214.43106-2-peterx@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/mmu/mmu.c
arch/x86/kvm/x86.c

index 974cbfb1eefe362dcb894b000236b9e007556886..d798650ad793add5897d01e4ba49e7dbb5887b49 100644 (file)
@@ -1209,6 +1209,7 @@ struct kvm_vm_stat {
        u64 lpages;
        u64 nx_lpage_splits;
        u64 max_mmu_page_hash_collisions;
+       u64 max_mmu_rmap_size;
 };
 
 struct kvm_vcpu_stat {
index d9e3ac6dda0547e000e56977af00866e809e6729..0b2954b5fbc6c14dcb41a56d6e287d29ed2f827a 100644 (file)
@@ -2698,6 +2698,8 @@ static int mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
        if (is_shadow_present_pte(*sptep)) {
                if (!was_rmapped) {
                        rmap_count = rmap_add(vcpu, sptep, gfn);
+                       if (rmap_count > vcpu->kvm->stat.max_mmu_rmap_size)
+                               vcpu->kvm->stat.max_mmu_rmap_size = rmap_count;
                        if (rmap_count > RMAP_RECYCLE_THRESHOLD)
                                rmap_recycle(vcpu, sptep, gfn);
                }
index e906c05e530e74c1203e1f719c355b18efcd0972..ab200f2cb1f0ebfee630bd41f9b28464309732ac 100644 (file)
@@ -235,6 +235,7 @@ const struct _kvm_stats_desc kvm_vm_stats_desc[] = {
        STATS_DESC_ICOUNTER(VM, mmu_unsync),
        STATS_DESC_ICOUNTER(VM, lpages),
        STATS_DESC_ICOUNTER(VM, nx_lpage_splits),
+       STATS_DESC_PCOUNTER(VM, max_mmu_rmap_size),
        STATS_DESC_PCOUNTER(VM, max_mmu_page_hash_collisions)
 };
 static_assert(ARRAY_SIZE(kvm_vm_stats_desc) ==