Skip to content

Commit 3cc4e14

Browse files
jingzhangosbonzini
authored andcommitted
KVM: stats: Add VM stat for remote tlb flush requests
Add a new stat that counts the number of times a remote TLB flush is requested, regardless of whether it kicks vCPUs out of guest mode. This allows us to look at how often flushes are initiated. Unlike remote_tlb_flush, this one applies to ARM's instruction-set-based TLB flush implementation, so apply it there too. Original-by: David Matlack <[email protected]> Signed-off-by: Jing Zhang <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent fdde13c commit 3cc4e14

File tree

4 files changed

+5
-1
lines changed

4 files changed

+5
-1
lines changed

arch/arm64/kvm/mmu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ static bool memslot_is_logging(struct kvm_memory_slot *memslot)
8080
*/
8181
void kvm_flush_remote_tlbs(struct kvm *kvm)
8282
{
83+
++kvm->stat.generic.remote_tlb_flush_requests;
8384
kvm_call_hyp(__kvm_tlb_flush_vmid, &kvm->arch.mmu);
8485
}
8586

include/linux/kvm_host.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1444,7 +1444,8 @@ struct _kvm_stats_desc {
14441444
KVM_STATS_BASE_POW10, -9, sz)
14451445

14461446
#define KVM_GENERIC_VM_STATS() \
1447-
STATS_DESC_COUNTER(VM_GENERIC, remote_tlb_flush)
1447+
STATS_DESC_COUNTER(VM_GENERIC, remote_tlb_flush), \
1448+
STATS_DESC_COUNTER(VM_GENERIC, remote_tlb_flush_requests)
14481449

14491450
#define KVM_GENERIC_VCPU_STATS() \
14501451
STATS_DESC_COUNTER(VCPU_GENERIC, halt_successful_poll), \

include/linux/kvm_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ struct kvm_mmu_memory_cache {
8080

8181
struct kvm_vm_stat_generic {
8282
u64 remote_tlb_flush;
83+
u64 remote_tlb_flush_requests;
8384
};
8485

8586
struct kvm_vcpu_stat_generic {

virt/kvm/kvm_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ void kvm_flush_remote_tlbs(struct kvm *kvm)
318318
*/
319319
long dirty_count = smp_load_acquire(&kvm->tlbs_dirty);
320320

321+
++kvm->stat.generic.remote_tlb_flush_requests;
321322
/*
322323
* We want to publish modifications to the page tables before reading
323324
* mode. Pairs with a memory barrier in arch-specific code.

0 commit comments

Comments
 (0)