[PATCH 6/7] KVM: arm64: Add stage2_unmap_vm counter for kvm_stat
Yoan Picchi
yoan.picchi at arm.com
Fri Mar 19 16:17:10 GMT 2021
Add a counter for when the one want to unmap all the ram of a VM.
This mostly happens when one restart a VM so we make sure to clear
the ram and free the memory for other VMs.
Signed-off-by: Yoan Picchi <yoan.picchi at arm.com>
---
arch/arm64/include/asm/kvm_host.h | 1 +
arch/arm64/kvm/guest.c | 1 +
arch/arm64/kvm/mmu.c | 2 ++
3 files changed, 4 insertions(+)
diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 76c81aa79..fa59b669c 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -549,6 +549,7 @@ struct kvm_vm_stat {
ulong remote_tlb_flush;
ulong flush_all_cache_lines;
ulong memory_slot_unmaped;
+ ulong stage2_unmap_vm;
ulong cached_page_invalidated;
};
diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c
index cd227136e..129c0d53d 100644
--- a/arch/arm64/kvm/guest.c
+++ b/arch/arm64/kvm/guest.c
@@ -43,6 +43,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
VM_STAT("remote_tlb_flush", remote_tlb_flush),
VM_STAT("flush_all_cache_lines", flush_all_cache_lines),
VM_STAT("memory_slot_unmaped", memory_slot_unmaped),
+ VM_STAT("stage2_unmap_vm", stage2_unmap_vm),
VM_STAT("cached_page_invalidated", cached_page_invalidated),
VCPU_STAT("exits", exits),
VCPU_STAT("halt_poll_success_ns", halt_poll_success_ns),
diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
index 1e8aeafc2..6d150a785 100644
--- a/arch/arm64/kvm/mmu.c
+++ b/arch/arm64/kvm/mmu.c
@@ -471,6 +471,8 @@ void stage2_unmap_vm(struct kvm *kvm)
mmap_read_lock(current->mm);
spin_lock(&kvm->mmu_lock);
+ kvm->stat.stage2_unmap_vm++;
+
slots = kvm_memslots(kvm);
kvm_for_each_memslot(memslot, slots)
stage2_unmap_memslot(kvm, memslot);
--
2.17.1
More information about the linux-arm-kernel
mailing list