MIPS: KVM: Clean up kvm_exit trace event
authorJames Hogan <james.hogan@imgtec.com>
Tue, 14 Jun 2016 08:40:12 +0000 (09:40 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 14 Jun 2016 09:16:23 +0000 (11:16 +0200)
Clean up the MIPS kvm_exit trace event so that the exit reasons are
specified in a trace friendly way (via __print_symbolic), and so that
the exit reasons that derive straight from Cause.ExcCode values map
directly, allowing a single trace_kvm_exit() call to replace a bunch of
individual ones.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: kvm@vger.kernel.org
Cc: linux-mips@linux-mips.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/mips/include/asm/kvm_host.h
arch/mips/kvm/emulate.c
arch/mips/kvm/mips.c
arch/mips/kvm/stats.c
arch/mips/kvm/trace.h

index e6273850bab69d3f39e0946ca54c3be533690e9f..b8cb7427074616efa8566085c5baff4e69fb2a25 100644 (file)
@@ -125,28 +125,6 @@ struct kvm_vcpu_stat {
        u32 halt_wakeup;
 };
 
-enum kvm_mips_exit_types {
-       WAIT_EXITS,
-       CACHE_EXITS,
-       SIGNAL_EXITS,
-       INT_EXITS,
-       COP_UNUSABLE_EXITS,
-       TLBMOD_EXITS,
-       TLBMISS_LD_EXITS,
-       TLBMISS_ST_EXITS,
-       ADDRERR_ST_EXITS,
-       ADDRERR_LD_EXITS,
-       SYSCALL_EXITS,
-       RESVD_INST_EXITS,
-       BREAK_INST_EXITS,
-       TRAP_INST_EXITS,
-       MSA_FPE_EXITS,
-       FPE_EXITS,
-       MSA_DISABLED_EXITS,
-       FLUSH_DCACHE_EXITS,
-       MAX_KVM_MIPS_EXIT_TYPES
-};
-
 struct kvm_arch_memory_slot {
 };
 
index 8647bd97b934ad62f20bda0682ba126577569be9..fce08bda9ebccc4197032573adc5638c807f3065 100644 (file)
@@ -775,7 +775,7 @@ enum emulation_result kvm_mips_emul_wait(struct kvm_vcpu *vcpu)
                  vcpu->arch.pending_exceptions);
 
        ++vcpu->stat.wait_exits;
-       trace_kvm_exit(vcpu, WAIT_EXITS);
+       trace_kvm_exit(vcpu, KVM_TRACE_EXIT_WAIT);
        if (!vcpu->arch.pending_exceptions) {
                vcpu->arch.wait = 1;
                kvm_vcpu_block(vcpu);
@@ -1718,7 +1718,7 @@ enum emulation_result kvm_mips_emulate_inst(u32 cause, u32 *opc,
 
        case cache_op:
                ++vcpu->stat.cache_exits;
-               trace_kvm_exit(vcpu, CACHE_EXITS);
+               trace_kvm_exit(vcpu, KVM_TRACE_EXIT_CACHE);
                er = kvm_mips_emulate_cache(inst, opc, cause, run, vcpu);
                break;
 
index c0e8f8640f2bbff9a7ffe566c7d39a50b6751ce1..e9e40b9dd9be3d1d77ef8df84a4aaca4669fe6e0 100644 (file)
@@ -1257,6 +1257,7 @@ int kvm_mips_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
 
        kvm_debug("kvm_mips_handle_exit: cause: %#x, PC: %p, kvm_run: %p, kvm_vcpu: %p\n",
                        cause, opc, run, vcpu);
+       trace_kvm_exit(vcpu, exccode);
 
        /*
         * Do a privilege check, if in UM most of these exit conditions end up
@@ -1276,7 +1277,6 @@ int kvm_mips_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
                kvm_debug("[%d]EXCCODE_INT @ %p\n", vcpu->vcpu_id, opc);
 
                ++vcpu->stat.int_exits;
-               trace_kvm_exit(vcpu, INT_EXITS);
 
                if (need_resched())
                        cond_resched();
@@ -1288,7 +1288,6 @@ int kvm_mips_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
                kvm_debug("EXCCODE_CPU: @ PC: %p\n", opc);
 
                ++vcpu->stat.cop_unusable_exits;
-               trace_kvm_exit(vcpu, COP_UNUSABLE_EXITS);
                ret = kvm_mips_callbacks->handle_cop_unusable(vcpu);
                /* XXXKYMA: Might need to return to user space */
                if (run->exit_reason == KVM_EXIT_IRQ_WINDOW_OPEN)
@@ -1297,7 +1296,6 @@ int kvm_mips_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
 
        case EXCCODE_MOD:
                ++vcpu->stat.tlbmod_exits;
-               trace_kvm_exit(vcpu, TLBMOD_EXITS);
                ret = kvm_mips_callbacks->handle_tlb_mod(vcpu);
                break;
 
@@ -1307,7 +1305,6 @@ int kvm_mips_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
                          badvaddr);
 
                ++vcpu->stat.tlbmiss_st_exits;
-               trace_kvm_exit(vcpu, TLBMISS_ST_EXITS);
                ret = kvm_mips_callbacks->handle_tlb_st_miss(vcpu);
                break;
 
@@ -1316,61 +1313,51 @@ int kvm_mips_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
                          cause, opc, badvaddr);
 
                ++vcpu->stat.tlbmiss_ld_exits;
-               trace_kvm_exit(vcpu, TLBMISS_LD_EXITS);
                ret = kvm_mips_callbacks->handle_tlb_ld_miss(vcpu);
                break;
 
        case EXCCODE_ADES:
                ++vcpu->stat.addrerr_st_exits;
-               trace_kvm_exit(vcpu, ADDRERR_ST_EXITS);
                ret = kvm_mips_callbacks->handle_addr_err_st(vcpu);
                break;
 
        case EXCCODE_ADEL:
                ++vcpu->stat.addrerr_ld_exits;
-               trace_kvm_exit(vcpu, ADDRERR_LD_EXITS);
                ret = kvm_mips_callbacks->handle_addr_err_ld(vcpu);
                break;
 
        case EXCCODE_SYS:
                ++vcpu->stat.syscall_exits;
-               trace_kvm_exit(vcpu, SYSCALL_EXITS);
                ret = kvm_mips_callbacks->handle_syscall(vcpu);
                break;
 
        case EXCCODE_RI:
                ++vcpu->stat.resvd_inst_exits;
-               trace_kvm_exit(vcpu, RESVD_INST_EXITS);
                ret = kvm_mips_callbacks->handle_res_inst(vcpu);
                break;
 
        case EXCCODE_BP:
                ++vcpu->stat.break_inst_exits;
-               trace_kvm_exit(vcpu, BREAK_INST_EXITS);
                ret = kvm_mips_callbacks->handle_break(vcpu);
                break;
 
        case EXCCODE_TR:
                ++vcpu->stat.trap_inst_exits;
-               trace_kvm_exit(vcpu, TRAP_INST_EXITS);
                ret = kvm_mips_callbacks->handle_trap(vcpu);
                break;
 
        case EXCCODE_MSAFPE:
                ++vcpu->stat.msa_fpe_exits;
-               trace_kvm_exit(vcpu, MSA_FPE_EXITS);
                ret = kvm_mips_callbacks->handle_msa_fpe(vcpu);
                break;
 
        case EXCCODE_FPE:
                ++vcpu->stat.fpe_exits;
-               trace_kvm_exit(vcpu, FPE_EXITS);
                ret = kvm_mips_callbacks->handle_fpe(vcpu);
                break;
 
        case EXCCODE_MSADIS:
                ++vcpu->stat.msa_disabled_exits;
-               trace_kvm_exit(vcpu, MSA_DISABLED_EXITS);
                ret = kvm_mips_callbacks->handle_msa_disabled(vcpu);
                break;
 
@@ -1397,7 +1384,7 @@ skip_emul:
                        run->exit_reason = KVM_EXIT_INTR;
                        ret = (-EINTR << 2) | RESUME_HOST;
                        ++vcpu->stat.signal_exits;
-                       trace_kvm_exit(vcpu, SIGNAL_EXITS);
+                       trace_kvm_exit(vcpu, KVM_TRACE_EXIT_SIGNAL);
                }
        }
 
index 888bb67070ac6d1139a7f06f5958e180680511ef..53f851a615542ae049383a252af326218bff412a 100644 (file)
 
 #include <linux/kvm_host.h>
 
-char *kvm_mips_exit_types_str[MAX_KVM_MIPS_EXIT_TYPES] = {
-       "WAIT",
-       "CACHE",
-       "Signal",
-       "Interrupt",
-       "COP0/1 Unusable",
-       "TLB Mod",
-       "TLB Miss (LD)",
-       "TLB Miss (ST)",
-       "Address Err (ST)",
-       "Address Error (LD)",
-       "System Call",
-       "Reserved Inst",
-       "Break Inst",
-       "Trap Inst",
-       "MSA FPE",
-       "FPE",
-       "MSA Disabled",
-       "D-Cache Flushes",
-};
-
 char *kvm_cop0_str[N_MIPS_COPROC_REGS] = {
        "Index",
        "Random",
index f3ada591ca2538006dfc907bbc6109f0da4cce89..ffa6ee8f20250acd9f19cbaca295cadf412aad31 100644 (file)
 #define TRACE_INCLUDE_PATH .
 #define TRACE_INCLUDE_FILE trace
 
-/* Tracepoints for VM eists */
-extern char *kvm_mips_exit_types_str[MAX_KVM_MIPS_EXIT_TYPES];
+/* The first 32 exit reasons correspond to Cause.ExcCode */
+#define KVM_TRACE_EXIT_INT              0
+#define KVM_TRACE_EXIT_TLBMOD           1
+#define KVM_TRACE_EXIT_TLBMISS_LD       2
+#define KVM_TRACE_EXIT_TLBMISS_ST       3
+#define KVM_TRACE_EXIT_ADDRERR_LD       4
+#define KVM_TRACE_EXIT_ADDRERR_ST       5
+#define KVM_TRACE_EXIT_SYSCALL          8
+#define KVM_TRACE_EXIT_BREAK_INST       9
+#define KVM_TRACE_EXIT_RESVD_INST      10
+#define KVM_TRACE_EXIT_COP_UNUSABLE    11
+#define KVM_TRACE_EXIT_TRAP_INST       13
+#define KVM_TRACE_EXIT_MSA_FPE         14
+#define KVM_TRACE_EXIT_FPE             15
+#define KVM_TRACE_EXIT_MSA_DISABLED    21
+/* Further exit reasons */
+#define KVM_TRACE_EXIT_WAIT            32
+#define KVM_TRACE_EXIT_CACHE           33
+#define KVM_TRACE_EXIT_SIGNAL          34
+
+/* Tracepoints for VM exits */
+#define kvm_trace_symbol_exit_types                            \
+       { KVM_TRACE_EXIT_INT,           "Interrupt" },          \
+       { KVM_TRACE_EXIT_TLBMOD,        "TLB Mod" },            \
+       { KVM_TRACE_EXIT_TLBMISS_LD,    "TLB Miss (LD)" },      \
+       { KVM_TRACE_EXIT_TLBMISS_ST,    "TLB Miss (ST)" },      \
+       { KVM_TRACE_EXIT_ADDRERR_LD,    "Address Error (LD)" }, \
+       { KVM_TRACE_EXIT_ADDRERR_ST,    "Address Err (ST)" },   \
+       { KVM_TRACE_EXIT_SYSCALL,       "System Call" },        \
+       { KVM_TRACE_EXIT_BREAK_INST,    "Break Inst" },         \
+       { KVM_TRACE_EXIT_RESVD_INST,    "Reserved Inst" },      \
+       { KVM_TRACE_EXIT_COP_UNUSABLE,  "COP0/1 Unusable" },    \
+       { KVM_TRACE_EXIT_TRAP_INST,     "Trap Inst" },          \
+       { KVM_TRACE_EXIT_MSA_FPE,       "MSA FPE" },            \
+       { KVM_TRACE_EXIT_FPE,           "FPE" },                \
+       { KVM_TRACE_EXIT_MSA_DISABLED,  "MSA Disabled" },       \
+       { KVM_TRACE_EXIT_WAIT,          "WAIT" },               \
+       { KVM_TRACE_EXIT_CACHE,         "CACHE" },              \
+       { KVM_TRACE_EXIT_SIGNAL,        "Signal" }
 
 TRACE_EVENT(kvm_exit,
            TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
@@ -34,7 +71,8 @@ TRACE_EVENT(kvm_exit,
            ),
 
            TP_printk("[%s]PC: 0x%08lx",
-                     kvm_mips_exit_types_str[__entry->reason],
+                     __print_symbolic(__entry->reason,
+                                      kvm_trace_symbol_exit_types),
                      __entry->pc)
 );