On Sun, Mar 10, 2013 at 06:03:55PM +0200, Abel Gordon wrote: > Add new counters to measure how many vmread/vmwrite/vmlaunch/vmresume/vmclear > instructions were trapped and emulated by L0 > stat counters are deprecated in favor of trace points. Adding kvmnested trace system is very welcome though. > Signed-off-by: Abel Gordon <abelg@xxxxxxxxxx> > --- > arch/x86/include/asm/kvm_host.h | 6 ++++++ > arch/x86/kvm/vmx.c | 7 +++++++ > arch/x86/kvm/x86.c | 6 ++++++ > 3 files changed, 19 insertions(+) > > --- .before/arch/x86/include/asm/kvm_host.h 2013-03-10 18:00:54.000000000 +0200 > +++ .after/arch/x86/include/asm/kvm_host.h 2013-03-10 18:00:54.000000000 +0200 > @@ -619,6 +619,12 @@ struct kvm_vcpu_stat { > u32 hypercalls; > u32 irq_injections; > u32 nmi_injections; > + u32 nvmx_vmreads; > + u32 nvmx_vmwrites; > + u32 nvmx_vmptrlds; > + u32 nvmx_vmlaunchs; > + u32 nvmx_vmresumes; > + u32 nvmx_vmclears; > }; > > struct x86_instruction_info; > --- .before/arch/x86/kvm/vmx.c 2013-03-10 18:00:54.000000000 +0200 > +++ .after/arch/x86/kvm/vmx.c 2013-03-10 18:00:54.000000000 +0200 > @@ -5545,6 +5545,7 @@ static int handle_vmclear(struct kvm_vcp > struct vmcs12 *vmcs12; > struct page *page; > struct x86_exception e; > + ++vcpu->stat.nvmx_vmclears; > > if (!nested_vmx_check_permission(vcpu)) > return 1; > @@ -5601,12 +5602,14 @@ static int nested_vmx_run(struct kvm_vcp > /* Emulate the VMLAUNCH instruction */ > static int handle_vmlaunch(struct kvm_vcpu *vcpu) > { > + ++vcpu->stat.nvmx_vmlaunchs; > return nested_vmx_run(vcpu, true); > } > > /* Emulate the VMRESUME instruction */ > static int handle_vmresume(struct kvm_vcpu *vcpu) > { > + ++vcpu->stat.nvmx_vmresumes; > > return nested_vmx_run(vcpu, false); > } > @@ -5689,6 +5692,7 @@ static int handle_vmread(struct kvm_vcpu > u32 vmx_instruction_info = vmcs_read32(VMX_INSTRUCTION_INFO); > gva_t gva = 0; > > + ++vcpu->stat.nvmx_vmreads; > if (!nested_vmx_check_permission(vcpu) || > !nested_vmx_check_vmcs12(vcpu)) > return 1; > @@ -5741,6 +5745,8 @@ static int handle_vmwrite(struct kvm_vcp > u64 field_value = 0; > struct x86_exception e; > > + ++vcpu->stat.nvmx_vmwrites; > + > if (!nested_vmx_check_permission(vcpu) || > !nested_vmx_check_vmcs12(vcpu)) > return 1; > @@ -5807,6 +5813,7 @@ static int handle_vmptrld(struct kvm_vcp > gva_t gva; > gpa_t vmptr; > struct x86_exception e; > + ++vcpu->stat.nvmx_vmptrlds; > > if (!nested_vmx_check_permission(vcpu)) > return 1; > --- .before/arch/x86/kvm/x86.c 2013-03-10 18:00:54.000000000 +0200 > +++ .after/arch/x86/kvm/x86.c 2013-03-10 18:00:54.000000000 +0200 > @@ -145,6 +145,12 @@ struct kvm_stats_debugfs_item debugfs_en > { "insn_emulation_fail", VCPU_STAT(insn_emulation_fail) }, > { "irq_injections", VCPU_STAT(irq_injections) }, > { "nmi_injections", VCPU_STAT(nmi_injections) }, > + { "nvmx_vmreads", VCPU_STAT(nvmx_vmreads) }, > + { "nvmx_vmwrites", VCPU_STAT(nvmx_vmwrites) }, > + { "nvmx_vmptrlds", VCPU_STAT(nvmx_vmptrlds) }, > + { "nvmx_vmlaunchs", VCPU_STAT(nvmx_vmlaunchs) }, > + { "nvmx_vmresumes", VCPU_STAT(nvmx_vmresumes) }, > + { "nvmx_vmclears", VCPU_STAT(nvmx_vmclears) }, > { "mmu_shadow_zapped", VM_STAT(mmu_shadow_zapped) }, > { "mmu_pte_write", VM_STAT(mmu_pte_write) }, > { "mmu_pte_updated", VM_STAT(mmu_pte_updated) }, > > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Gleb. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html