]> err.no Git - linux-2.6/commitdiff
KVM: Add instruction emulation statistics
authorAvi Kivity <avi@qumranet.com>
Sun, 18 Nov 2007 13:17:51 +0000 (15:17 +0200)
committerAvi Kivity <avi@qumranet.com>
Wed, 30 Jan 2008 15:53:04 +0000 (17:53 +0200)
drivers/kvm/kvm.h
drivers/kvm/x86.c

index a85c5903591f2fa87e3ee09a50fd91205e248fc1..5a8a9af3593a8e2d592fde91efa7cc1ed76d3fad 100644 (file)
@@ -249,6 +249,8 @@ struct kvm_stat {
        u32 host_state_reload;
        u32 efer_reload;
        u32 fpu_reload;
+       u32 insn_emulation;
+       u32 insn_emulation_fail;
 };
 
 struct kvm_io_device {
index c1211e125b4387bc06ef14067149f75f5912572b..a46b95b3651c7898b6626172c0d077c815af7cee 100644 (file)
@@ -63,6 +63,8 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
        { "host_state_reload", STAT_OFFSET(host_state_reload) },
        { "efer_reload", STAT_OFFSET(efer_reload) },
        { "fpu_reload", STAT_OFFSET(fpu_reload) },
+       { "insn_emulation", STAT_OFFSET(insn_emulation) },
+       { "insn_emulation_fail", STAT_OFFSET(insn_emulation_fail) },
        { NULL }
 };
 
@@ -1381,7 +1383,9 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
                                        get_segment_base(vcpu, VCPU_SREG_FS);
 
                r = x86_decode_insn(&vcpu->emulate_ctxt, &emulate_ops);
+               ++vcpu->stat.insn_emulation;
                if (r)  {
+                       ++vcpu->stat.insn_emulation_fail;
                        if (kvm_mmu_unprotect_page_virt(vcpu, cr2))
                                return EMULATE_DONE;
                        return EMULATE_FAIL;