Commit 0193cc90 authored by Jing Zhang's avatar Jing Zhang Committed by Paolo Bonzini

KVM: stats: Separate generic stats from architecture specific ones

Generic KVM stats are those collected in architecture independent code
or those supported by all architectures; put all generic statistics in
a separate structure.  This ensures that they are defined the same way
in the statistics API which is being added, removing duplication among
different architectures in the declaration of the descriptors.

No functional change intended.
Reviewed-by: default avatarDavid Matlack <dmatlack@google.com>
Reviewed-by: default avatarRicardo Koller <ricarkol@google.com>
Reviewed-by: default avatarKrish Sadhukhan <krish.sadhukhan@oracle.com>
Signed-off-by: default avatarJing Zhang <jingzhangos@google.com>
Message-Id: <20210618222709.1858088-2-jingzhangos@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 6c6e166b
...@@ -556,16 +556,11 @@ static inline bool __vcpu_write_sys_reg_to_cpu(u64 val, int reg) ...@@ -556,16 +556,11 @@ static inline bool __vcpu_write_sys_reg_to_cpu(u64 val, int reg)
} }
struct kvm_vm_stat { struct kvm_vm_stat {
u64 remote_tlb_flush; struct kvm_vm_stat_generic generic;
}; };
struct kvm_vcpu_stat { struct kvm_vcpu_stat {
u64 halt_successful_poll; struct kvm_vcpu_stat_generic generic;
u64 halt_attempted_poll;
u64 halt_poll_success_ns;
u64 halt_poll_fail_ns;
u64 halt_poll_invalid;
u64 halt_wakeup;
u64 hvc_exit_stat; u64 hvc_exit_stat;
u64 wfe_exit_stat; u64 wfe_exit_stat;
u64 wfi_exit_stat; u64 wfi_exit_stat;
......
...@@ -29,18 +29,18 @@ ...@@ -29,18 +29,18 @@
#include "trace.h" #include "trace.h"
struct kvm_stats_debugfs_item debugfs_entries[] = { struct kvm_stats_debugfs_item debugfs_entries[] = {
VCPU_STAT("halt_successful_poll", halt_successful_poll), VCPU_STAT("halt_successful_poll", generic.halt_successful_poll),
VCPU_STAT("halt_attempted_poll", halt_attempted_poll), VCPU_STAT("halt_attempted_poll", generic.halt_attempted_poll),
VCPU_STAT("halt_poll_invalid", halt_poll_invalid), VCPU_STAT("halt_poll_invalid", generic.halt_poll_invalid),
VCPU_STAT("halt_wakeup", halt_wakeup), VCPU_STAT("halt_wakeup", generic.halt_wakeup),
VCPU_STAT("hvc_exit_stat", hvc_exit_stat), VCPU_STAT("hvc_exit_stat", hvc_exit_stat),
VCPU_STAT("wfe_exit_stat", wfe_exit_stat), VCPU_STAT("wfe_exit_stat", wfe_exit_stat),
VCPU_STAT("wfi_exit_stat", wfi_exit_stat), VCPU_STAT("wfi_exit_stat", wfi_exit_stat),
VCPU_STAT("mmio_exit_user", mmio_exit_user), VCPU_STAT("mmio_exit_user", mmio_exit_user),
VCPU_STAT("mmio_exit_kernel", mmio_exit_kernel), VCPU_STAT("mmio_exit_kernel", mmio_exit_kernel),
VCPU_STAT("exits", exits), VCPU_STAT("exits", exits),
VCPU_STAT("halt_poll_success_ns", halt_poll_success_ns), VCPU_STAT("halt_poll_success_ns", generic.halt_poll_success_ns),
VCPU_STAT("halt_poll_fail_ns", halt_poll_fail_ns), VCPU_STAT("halt_poll_fail_ns", generic.halt_poll_fail_ns),
{ NULL } { NULL }
}; };
......
...@@ -109,10 +109,11 @@ static inline bool kvm_is_error_hva(unsigned long addr) ...@@ -109,10 +109,11 @@ static inline bool kvm_is_error_hva(unsigned long addr)
} }
struct kvm_vm_stat { struct kvm_vm_stat {
u64 remote_tlb_flush; struct kvm_vm_stat_generic generic;
}; };
struct kvm_vcpu_stat { struct kvm_vcpu_stat {
struct kvm_vcpu_stat_generic generic;
u64 wait_exits; u64 wait_exits;
u64 cache_exits; u64 cache_exits;
u64 signal_exits; u64 signal_exits;
...@@ -142,12 +143,6 @@ struct kvm_vcpu_stat { ...@@ -142,12 +143,6 @@ struct kvm_vcpu_stat {
#ifdef CONFIG_CPU_LOONGSON64 #ifdef CONFIG_CPU_LOONGSON64
u64 vz_cpucfg_exits; u64 vz_cpucfg_exits;
#endif #endif
u64 halt_successful_poll;
u64 halt_attempted_poll;
u64 halt_poll_success_ns;
u64 halt_poll_fail_ns;
u64 halt_poll_invalid;
u64 halt_wakeup;
}; };
struct kvm_arch_memory_slot { struct kvm_arch_memory_slot {
......
...@@ -68,12 +68,12 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { ...@@ -68,12 +68,12 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
#ifdef CONFIG_CPU_LOONGSON64 #ifdef CONFIG_CPU_LOONGSON64
VCPU_STAT("vz_cpucfg", vz_cpucfg_exits), VCPU_STAT("vz_cpucfg", vz_cpucfg_exits),
#endif #endif
VCPU_STAT("halt_successful_poll", halt_successful_poll), VCPU_STAT("halt_successful_poll", generic.halt_successful_poll),
VCPU_STAT("halt_attempted_poll", halt_attempted_poll), VCPU_STAT("halt_attempted_poll", generic.halt_attempted_poll),
VCPU_STAT("halt_poll_invalid", halt_poll_invalid), VCPU_STAT("halt_poll_invalid", generic.halt_poll_invalid),
VCPU_STAT("halt_wakeup", halt_wakeup), VCPU_STAT("halt_wakeup", generic.halt_wakeup),
VCPU_STAT("halt_poll_success_ns", halt_poll_success_ns), VCPU_STAT("halt_poll_success_ns", generic.halt_poll_success_ns),
VCPU_STAT("halt_poll_fail_ns", halt_poll_fail_ns), VCPU_STAT("halt_poll_fail_ns", generic.halt_poll_fail_ns),
{NULL} {NULL}
}; };
......
...@@ -81,12 +81,13 @@ struct kvmppc_book3s_shadow_vcpu; ...@@ -81,12 +81,13 @@ struct kvmppc_book3s_shadow_vcpu;
struct kvm_nested_guest; struct kvm_nested_guest;
struct kvm_vm_stat { struct kvm_vm_stat {
u64 remote_tlb_flush; struct kvm_vm_stat_generic generic;
u64 num_2M_pages; u64 num_2M_pages;
u64 num_1G_pages; u64 num_1G_pages;
}; };
struct kvm_vcpu_stat { struct kvm_vcpu_stat {
struct kvm_vcpu_stat_generic generic;
u64 sum_exits; u64 sum_exits;
u64 mmio_exits; u64 mmio_exits;
u64 signal_exits; u64 signal_exits;
...@@ -102,14 +103,8 @@ struct kvm_vcpu_stat { ...@@ -102,14 +103,8 @@ struct kvm_vcpu_stat {
u64 emulated_inst_exits; u64 emulated_inst_exits;
u64 dec_exits; u64 dec_exits;
u64 ext_intr_exits; u64 ext_intr_exits;
u64 halt_poll_success_ns;
u64 halt_poll_fail_ns;
u64 halt_wait_ns; u64 halt_wait_ns;
u64 halt_successful_poll;
u64 halt_attempted_poll;
u64 halt_successful_wait; u64 halt_successful_wait;
u64 halt_poll_invalid;
u64 halt_wakeup;
u64 dbell_exits; u64 dbell_exits;
u64 gdbell_exits; u64 gdbell_exits;
u64 ld; u64 ld;
......
...@@ -47,14 +47,14 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { ...@@ -47,14 +47,14 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
VCPU_STAT("dec", dec_exits), VCPU_STAT("dec", dec_exits),
VCPU_STAT("ext_intr", ext_intr_exits), VCPU_STAT("ext_intr", ext_intr_exits),
VCPU_STAT("queue_intr", queue_intr), VCPU_STAT("queue_intr", queue_intr),
VCPU_STAT("halt_poll_success_ns", halt_poll_success_ns), VCPU_STAT("halt_poll_success_ns", generic.halt_poll_success_ns),
VCPU_STAT("halt_poll_fail_ns", halt_poll_fail_ns), VCPU_STAT("halt_poll_fail_ns", generic.halt_poll_fail_ns),
VCPU_STAT("halt_wait_ns", halt_wait_ns), VCPU_STAT("halt_wait_ns", halt_wait_ns),
VCPU_STAT("halt_successful_poll", halt_successful_poll), VCPU_STAT("halt_successful_poll", generic.halt_successful_poll),
VCPU_STAT("halt_attempted_poll", halt_attempted_poll), VCPU_STAT("halt_attempted_poll", generic.halt_attempted_poll),
VCPU_STAT("halt_successful_wait", halt_successful_wait), VCPU_STAT("halt_successful_wait", halt_successful_wait),
VCPU_STAT("halt_poll_invalid", halt_poll_invalid), VCPU_STAT("halt_poll_invalid", generic.halt_poll_invalid),
VCPU_STAT("halt_wakeup", halt_wakeup), VCPU_STAT("halt_wakeup", generic.halt_wakeup),
VCPU_STAT("pf_storage", pf_storage), VCPU_STAT("pf_storage", pf_storage),
VCPU_STAT("sp_storage", sp_storage), VCPU_STAT("sp_storage", sp_storage),
VCPU_STAT("pf_instruc", pf_instruc), VCPU_STAT("pf_instruc", pf_instruc),
......
...@@ -230,7 +230,7 @@ static void kvmppc_fast_vcpu_kick_hv(struct kvm_vcpu *vcpu) ...@@ -230,7 +230,7 @@ static void kvmppc_fast_vcpu_kick_hv(struct kvm_vcpu *vcpu)
waitp = kvm_arch_vcpu_get_wait(vcpu); waitp = kvm_arch_vcpu_get_wait(vcpu);
if (rcuwait_wake_up(waitp)) if (rcuwait_wake_up(waitp))
++vcpu->stat.halt_wakeup; ++vcpu->stat.generic.halt_wakeup;
cpu = READ_ONCE(vcpu->arch.thread_cpu); cpu = READ_ONCE(vcpu->arch.thread_cpu);
if (cpu >= 0 && kvmppc_ipi_thread(cpu)) if (cpu >= 0 && kvmppc_ipi_thread(cpu))
...@@ -4092,7 +4092,7 @@ static void kvmppc_vcore_blocked(struct kvmppc_vcore *vc) ...@@ -4092,7 +4092,7 @@ static void kvmppc_vcore_blocked(struct kvmppc_vcore *vc)
cur = start_poll = ktime_get(); cur = start_poll = ktime_get();
if (vc->halt_poll_ns) { if (vc->halt_poll_ns) {
ktime_t stop = ktime_add_ns(start_poll, vc->halt_poll_ns); ktime_t stop = ktime_add_ns(start_poll, vc->halt_poll_ns);
++vc->runner->stat.halt_attempted_poll; ++vc->runner->stat.generic.halt_attempted_poll;
vc->vcore_state = VCORE_POLLING; vc->vcore_state = VCORE_POLLING;
spin_unlock(&vc->lock); spin_unlock(&vc->lock);
...@@ -4109,7 +4109,7 @@ static void kvmppc_vcore_blocked(struct kvmppc_vcore *vc) ...@@ -4109,7 +4109,7 @@ static void kvmppc_vcore_blocked(struct kvmppc_vcore *vc)
vc->vcore_state = VCORE_INACTIVE; vc->vcore_state = VCORE_INACTIVE;
if (!do_sleep) { if (!do_sleep) {
++vc->runner->stat.halt_successful_poll; ++vc->runner->stat.generic.halt_successful_poll;
goto out; goto out;
} }
} }
...@@ -4121,7 +4121,7 @@ static void kvmppc_vcore_blocked(struct kvmppc_vcore *vc) ...@@ -4121,7 +4121,7 @@ static void kvmppc_vcore_blocked(struct kvmppc_vcore *vc)
do_sleep = 0; do_sleep = 0;
/* If we polled, count this as a successful poll */ /* If we polled, count this as a successful poll */
if (vc->halt_poll_ns) if (vc->halt_poll_ns)
++vc->runner->stat.halt_successful_poll; ++vc->runner->stat.generic.halt_successful_poll;
goto out; goto out;
} }
...@@ -4148,13 +4148,13 @@ static void kvmppc_vcore_blocked(struct kvmppc_vcore *vc) ...@@ -4148,13 +4148,13 @@ static void kvmppc_vcore_blocked(struct kvmppc_vcore *vc)
ktime_to_ns(cur) - ktime_to_ns(start_wait); ktime_to_ns(cur) - ktime_to_ns(start_wait);
/* Attribute failed poll time */ /* Attribute failed poll time */
if (vc->halt_poll_ns) if (vc->halt_poll_ns)
vc->runner->stat.halt_poll_fail_ns += vc->runner->stat.generic.halt_poll_fail_ns +=
ktime_to_ns(start_wait) - ktime_to_ns(start_wait) -
ktime_to_ns(start_poll); ktime_to_ns(start_poll);
} else { } else {
/* Attribute successful poll time */ /* Attribute successful poll time */
if (vc->halt_poll_ns) if (vc->halt_poll_ns)
vc->runner->stat.halt_poll_success_ns += vc->runner->stat.generic.halt_poll_success_ns +=
ktime_to_ns(cur) - ktime_to_ns(cur) -
ktime_to_ns(start_poll); ktime_to_ns(start_poll);
} }
......
...@@ -493,7 +493,7 @@ static void kvmppc_set_msr_pr(struct kvm_vcpu *vcpu, u64 msr) ...@@ -493,7 +493,7 @@ static void kvmppc_set_msr_pr(struct kvm_vcpu *vcpu, u64 msr)
if (!vcpu->arch.pending_exceptions) { if (!vcpu->arch.pending_exceptions) {
kvm_vcpu_block(vcpu); kvm_vcpu_block(vcpu);
kvm_clear_request(KVM_REQ_UNHALT, vcpu); kvm_clear_request(KVM_REQ_UNHALT, vcpu);
vcpu->stat.halt_wakeup++; vcpu->stat.generic.halt_wakeup++;
/* Unset POW bit after we woke up */ /* Unset POW bit after we woke up */
msr &= ~MSR_POW; msr &= ~MSR_POW;
......
...@@ -378,7 +378,7 @@ int kvmppc_h_pr(struct kvm_vcpu *vcpu, unsigned long cmd) ...@@ -378,7 +378,7 @@ int kvmppc_h_pr(struct kvm_vcpu *vcpu, unsigned long cmd)
kvmppc_set_msr_fast(vcpu, kvmppc_get_msr(vcpu) | MSR_EE); kvmppc_set_msr_fast(vcpu, kvmppc_get_msr(vcpu) | MSR_EE);
kvm_vcpu_block(vcpu); kvm_vcpu_block(vcpu);
kvm_clear_request(KVM_REQ_UNHALT, vcpu); kvm_clear_request(KVM_REQ_UNHALT, vcpu);
vcpu->stat.halt_wakeup++; vcpu->stat.generic.halt_wakeup++;
return EMULATE_DONE; return EMULATE_DONE;
case H_LOGICAL_CI_LOAD: case H_LOGICAL_CI_LOAD:
return kvmppc_h_pr_logical_ci_load(vcpu); return kvmppc_h_pr_logical_ci_load(vcpu);
......
...@@ -49,15 +49,15 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { ...@@ -49,15 +49,15 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
VCPU_STAT("inst_emu", emulated_inst_exits), VCPU_STAT("inst_emu", emulated_inst_exits),
VCPU_STAT("dec", dec_exits), VCPU_STAT("dec", dec_exits),
VCPU_STAT("ext_intr", ext_intr_exits), VCPU_STAT("ext_intr", ext_intr_exits),
VCPU_STAT("halt_successful_poll", halt_successful_poll), VCPU_STAT("halt_successful_poll", generic.halt_successful_poll),
VCPU_STAT("halt_attempted_poll", halt_attempted_poll), VCPU_STAT("halt_attempted_poll", generic.halt_attempted_poll),
VCPU_STAT("halt_poll_invalid", halt_poll_invalid), VCPU_STAT("halt_poll_invalid", generic.halt_poll_invalid),
VCPU_STAT("halt_wakeup", halt_wakeup), VCPU_STAT("halt_wakeup", generic.halt_wakeup),
VCPU_STAT("doorbell", dbell_exits), VCPU_STAT("doorbell", dbell_exits),
VCPU_STAT("guest doorbell", gdbell_exits), VCPU_STAT("guest doorbell", gdbell_exits),
VCPU_STAT("halt_poll_success_ns", halt_poll_success_ns), VCPU_STAT("halt_poll_success_ns", generic.halt_poll_success_ns),
VCPU_STAT("halt_poll_fail_ns", halt_poll_fail_ns), VCPU_STAT("halt_poll_fail_ns", generic.halt_poll_fail_ns),
VM_STAT("remote_tlb_flush", remote_tlb_flush), VM_STAT("remote_tlb_flush", generic.remote_tlb_flush),
{ NULL } { NULL }
}; };
......
...@@ -361,6 +361,7 @@ struct sie_page { ...@@ -361,6 +361,7 @@ struct sie_page {
}; };
struct kvm_vcpu_stat { struct kvm_vcpu_stat {
struct kvm_vcpu_stat_generic generic;
u64 exit_userspace; u64 exit_userspace;
u64 exit_null; u64 exit_null;
u64 exit_external_request; u64 exit_external_request;
...@@ -370,13 +371,7 @@ struct kvm_vcpu_stat { ...@@ -370,13 +371,7 @@ struct kvm_vcpu_stat {
u64 exit_validity; u64 exit_validity;
u64 exit_instruction; u64 exit_instruction;
u64 exit_pei; u64 exit_pei;
u64 halt_successful_poll;
u64 halt_attempted_poll;
u64 halt_poll_invalid;
u64 halt_no_poll_steal; u64 halt_no_poll_steal;
u64 halt_wakeup;
u64 halt_poll_success_ns;
u64 halt_poll_fail_ns;
u64 instruction_lctl; u64 instruction_lctl;
u64 instruction_lctlg; u64 instruction_lctlg;
u64 instruction_stctl; u64 instruction_stctl;
...@@ -755,12 +750,12 @@ struct kvm_vcpu_arch { ...@@ -755,12 +750,12 @@ struct kvm_vcpu_arch {
}; };
struct kvm_vm_stat { struct kvm_vm_stat {
struct kvm_vm_stat_generic generic;
u64 inject_io; u64 inject_io;
u64 inject_float_mchk; u64 inject_float_mchk;
u64 inject_pfault_done; u64 inject_pfault_done;
u64 inject_service_signal; u64 inject_service_signal;
u64 inject_virtio; u64 inject_virtio;
u64 remote_tlb_flush;
}; };
struct kvm_arch_memory_slot { struct kvm_arch_memory_slot {
......
...@@ -72,13 +72,13 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { ...@@ -72,13 +72,13 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
VCPU_STAT("exit_program_interruption", exit_program_interruption), VCPU_STAT("exit_program_interruption", exit_program_interruption),
VCPU_STAT("exit_instr_and_program_int", exit_instr_and_program), VCPU_STAT("exit_instr_and_program_int", exit_instr_and_program),
VCPU_STAT("exit_operation_exception", exit_operation_exception), VCPU_STAT("exit_operation_exception", exit_operation_exception),
VCPU_STAT("halt_successful_poll", halt_successful_poll), VCPU_STAT("halt_successful_poll", generic.halt_successful_poll),
VCPU_STAT("halt_attempted_poll", halt_attempted_poll), VCPU_STAT("halt_attempted_poll", generic.halt_attempted_poll),
VCPU_STAT("halt_poll_invalid", halt_poll_invalid), VCPU_STAT("halt_poll_invalid", generic.halt_poll_invalid),
VCPU_STAT("halt_no_poll_steal", halt_no_poll_steal), VCPU_STAT("halt_no_poll_steal", halt_no_poll_steal),
VCPU_STAT("halt_wakeup", halt_wakeup), VCPU_STAT("halt_wakeup", generic.halt_wakeup),
VCPU_STAT("halt_poll_success_ns", halt_poll_success_ns), VCPU_STAT("halt_poll_success_ns", generic.halt_poll_success_ns),
VCPU_STAT("halt_poll_fail_ns", halt_poll_fail_ns), VCPU_STAT("halt_poll_fail_ns", generic.halt_poll_fail_ns),
VCPU_STAT("instruction_lctlg", instruction_lctlg), VCPU_STAT("instruction_lctlg", instruction_lctlg),
VCPU_STAT("instruction_lctl", instruction_lctl), VCPU_STAT("instruction_lctl", instruction_lctl),
VCPU_STAT("instruction_stctl", instruction_stctl), VCPU_STAT("instruction_stctl", instruction_stctl),
......
...@@ -1160,6 +1160,7 @@ struct kvm_arch { ...@@ -1160,6 +1160,7 @@ struct kvm_arch {
}; };
struct kvm_vm_stat { struct kvm_vm_stat {
struct kvm_vm_stat_generic generic;
u64 mmu_shadow_zapped; u64 mmu_shadow_zapped;
u64 mmu_pte_write; u64 mmu_pte_write;
u64 mmu_pde_zapped; u64 mmu_pde_zapped;
...@@ -1167,13 +1168,13 @@ struct kvm_vm_stat { ...@@ -1167,13 +1168,13 @@ struct kvm_vm_stat {
u64 mmu_recycled; u64 mmu_recycled;
u64 mmu_cache_miss; u64 mmu_cache_miss;
u64 mmu_unsync; u64 mmu_unsync;
u64 remote_tlb_flush;
u64 lpages; u64 lpages;
u64 nx_lpage_splits; u64 nx_lpage_splits;
u64 max_mmu_page_hash_collisions; u64 max_mmu_page_hash_collisions;
}; };
struct kvm_vcpu_stat { struct kvm_vcpu_stat {
struct kvm_vcpu_stat_generic generic;
u64 pf_fixed; u64 pf_fixed;
u64 pf_guest; u64 pf_guest;
u64 tlb_flush; u64 tlb_flush;
...@@ -1187,10 +1188,6 @@ struct kvm_vcpu_stat { ...@@ -1187,10 +1188,6 @@ struct kvm_vcpu_stat {
u64 nmi_window_exits; u64 nmi_window_exits;
u64 l1d_flush; u64 l1d_flush;
u64 halt_exits; u64 halt_exits;
u64 halt_successful_poll;
u64 halt_attempted_poll;
u64 halt_poll_invalid;
u64 halt_wakeup;
u64 request_irq_exits; u64 request_irq_exits;
u64 irq_exits; u64 irq_exits;
u64 host_state_reload; u64 host_state_reload;
...@@ -1201,8 +1198,6 @@ struct kvm_vcpu_stat { ...@@ -1201,8 +1198,6 @@ struct kvm_vcpu_stat {
u64 irq_injections; u64 irq_injections;
u64 nmi_injections; u64 nmi_injections;
u64 req_event; u64 req_event;
u64 halt_poll_success_ns;
u64 halt_poll_fail_ns;
u64 nested_run; u64 nested_run;
u64 directed_yield_attempted; u64 directed_yield_attempted;
u64 directed_yield_successful; u64 directed_yield_successful;
......
...@@ -235,10 +235,10 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { ...@@ -235,10 +235,10 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
VCPU_STAT("irq_window", irq_window_exits), VCPU_STAT("irq_window", irq_window_exits),
VCPU_STAT("nmi_window", nmi_window_exits), VCPU_STAT("nmi_window", nmi_window_exits),
VCPU_STAT("halt_exits", halt_exits), VCPU_STAT("halt_exits", halt_exits),
VCPU_STAT("halt_successful_poll", halt_successful_poll), VCPU_STAT("halt_successful_poll", generic.halt_successful_poll),
VCPU_STAT("halt_attempted_poll", halt_attempted_poll), VCPU_STAT("halt_attempted_poll", generic.halt_attempted_poll),
VCPU_STAT("halt_poll_invalid", halt_poll_invalid), VCPU_STAT("halt_poll_invalid", generic.halt_poll_invalid),
VCPU_STAT("halt_wakeup", halt_wakeup), VCPU_STAT("halt_wakeup", generic.halt_wakeup),
VCPU_STAT("hypercalls", hypercalls), VCPU_STAT("hypercalls", hypercalls),
VCPU_STAT("request_irq", request_irq_exits), VCPU_STAT("request_irq", request_irq_exits),
VCPU_STAT("irq_exits", irq_exits), VCPU_STAT("irq_exits", irq_exits),
...@@ -250,8 +250,8 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { ...@@ -250,8 +250,8 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
VCPU_STAT("nmi_injections", nmi_injections), VCPU_STAT("nmi_injections", nmi_injections),
VCPU_STAT("req_event", req_event), VCPU_STAT("req_event", req_event),
VCPU_STAT("l1d_flush", l1d_flush), VCPU_STAT("l1d_flush", l1d_flush),
VCPU_STAT("halt_poll_success_ns", halt_poll_success_ns), VCPU_STAT("halt_poll_success_ns", generic.halt_poll_success_ns),
VCPU_STAT("halt_poll_fail_ns", halt_poll_fail_ns), VCPU_STAT("halt_poll_fail_ns", generic.halt_poll_fail_ns),
VCPU_STAT("nested_run", nested_run), VCPU_STAT("nested_run", nested_run),
VCPU_STAT("directed_yield_attempted", directed_yield_attempted), VCPU_STAT("directed_yield_attempted", directed_yield_attempted),
VCPU_STAT("directed_yield_successful", directed_yield_successful), VCPU_STAT("directed_yield_successful", directed_yield_successful),
...@@ -263,7 +263,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { ...@@ -263,7 +263,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
VM_STAT("mmu_recycled", mmu_recycled), VM_STAT("mmu_recycled", mmu_recycled),
VM_STAT("mmu_cache_miss", mmu_cache_miss), VM_STAT("mmu_cache_miss", mmu_cache_miss),
VM_STAT("mmu_unsync", mmu_unsync), VM_STAT("mmu_unsync", mmu_unsync),
VM_STAT("remote_tlb_flush", remote_tlb_flush), VM_STAT("remote_tlb_flush", generic.remote_tlb_flush),
VM_STAT("largepages", lpages, .mode = 0444), VM_STAT("largepages", lpages, .mode = 0444),
VM_STAT("nx_largepages_splitted", nx_lpage_splits, .mode = 0444), VM_STAT("nx_largepages_splitted", nx_lpage_splits, .mode = 0444),
VM_STAT("max_mmu_page_hash_collisions", max_mmu_page_hash_collisions), VM_STAT("max_mmu_page_hash_collisions", max_mmu_page_hash_collisions),
......
...@@ -76,5 +76,17 @@ struct kvm_mmu_memory_cache { ...@@ -76,5 +76,17 @@ struct kvm_mmu_memory_cache {
}; };
#endif #endif
struct kvm_vm_stat_generic {
u64 remote_tlb_flush;
};
struct kvm_vcpu_stat_generic {
u64 halt_successful_poll;
u64 halt_attempted_poll;
u64 halt_poll_invalid;
u64 halt_wakeup;
u64 halt_poll_success_ns;
u64 halt_poll_fail_ns;
};
#endif /* __KVM_TYPES_H__ */ #endif /* __KVM_TYPES_H__ */
...@@ -332,7 +332,7 @@ void kvm_flush_remote_tlbs(struct kvm *kvm) ...@@ -332,7 +332,7 @@ void kvm_flush_remote_tlbs(struct kvm *kvm)
*/ */
if (!kvm_arch_flush_remote_tlb(kvm) if (!kvm_arch_flush_remote_tlb(kvm)
|| kvm_make_all_cpus_request(kvm, KVM_REQ_TLB_FLUSH)) || kvm_make_all_cpus_request(kvm, KVM_REQ_TLB_FLUSH))
++kvm->stat.remote_tlb_flush; ++kvm->stat.generic.remote_tlb_flush;
cmpxchg(&kvm->tlbs_dirty, dirty_count, 0); cmpxchg(&kvm->tlbs_dirty, dirty_count, 0);
} }
EXPORT_SYMBOL_GPL(kvm_flush_remote_tlbs); EXPORT_SYMBOL_GPL(kvm_flush_remote_tlbs);
...@@ -3029,9 +3029,9 @@ static inline void ...@@ -3029,9 +3029,9 @@ static inline void
update_halt_poll_stats(struct kvm_vcpu *vcpu, u64 poll_ns, bool waited) update_halt_poll_stats(struct kvm_vcpu *vcpu, u64 poll_ns, bool waited)
{ {
if (waited) if (waited)
vcpu->stat.halt_poll_fail_ns += poll_ns; vcpu->stat.generic.halt_poll_fail_ns += poll_ns;
else else
vcpu->stat.halt_poll_success_ns += poll_ns; vcpu->stat.generic.halt_poll_success_ns += poll_ns;
} }
/* /*
...@@ -3049,16 +3049,16 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu) ...@@ -3049,16 +3049,16 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
if (vcpu->halt_poll_ns && !kvm_arch_no_poll(vcpu)) { if (vcpu->halt_poll_ns && !kvm_arch_no_poll(vcpu)) {
ktime_t stop = ktime_add_ns(ktime_get(), vcpu->halt_poll_ns); ktime_t stop = ktime_add_ns(ktime_get(), vcpu->halt_poll_ns);
++vcpu->stat.halt_attempted_poll; ++vcpu->stat.generic.halt_attempted_poll;
do { do {
/* /*
* This sets KVM_REQ_UNHALT if an interrupt * This sets KVM_REQ_UNHALT if an interrupt
* arrives. * arrives.
*/ */
if (kvm_vcpu_check_block(vcpu) < 0) { if (kvm_vcpu_check_block(vcpu) < 0) {
++vcpu->stat.halt_successful_poll; ++vcpu->stat.generic.halt_successful_poll;
if (!vcpu_valid_wakeup(vcpu)) if (!vcpu_valid_wakeup(vcpu))
++vcpu->stat.halt_poll_invalid; ++vcpu->stat.generic.halt_poll_invalid;
goto out; goto out;
} }
poll_end = cur = ktime_get(); poll_end = cur = ktime_get();
...@@ -3115,7 +3115,7 @@ bool kvm_vcpu_wake_up(struct kvm_vcpu *vcpu) ...@@ -3115,7 +3115,7 @@ bool kvm_vcpu_wake_up(struct kvm_vcpu *vcpu)
waitp = kvm_arch_vcpu_get_wait(vcpu); waitp = kvm_arch_vcpu_get_wait(vcpu);
if (rcuwait_wake_up(waitp)) { if (rcuwait_wake_up(waitp)) {
WRITE_ONCE(vcpu->ready, true); WRITE_ONCE(vcpu->ready, true);
++vcpu->stat.halt_wakeup; ++vcpu->stat.generic.halt_wakeup;
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment