aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGleb Natapov <gleb@redhat.com>2010-10-24 10:49:08 -0400
committerAvi Kivity <avi@redhat.com>2011-01-12 04:28:44 -0500
commit64be5007066173d11a4635eedd57d41a3b3a7027 (patch)
treed2d7e085b63a1f2160b04d1b6fcd5994592e5c80
parent612819c3c6e67bac8fceaa7cc402f13b1b63f7e4 (diff)
KVM: x86: trace "exit to userspace" event
Add tracepoint for userspace exit. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
-rw-r--r--include/trace/events/kvm.h30
-rw-r--r--virt/kvm/kvm_main.c1
2 files changed, 31 insertions, 0 deletions
diff --git a/include/trace/events/kvm.h b/include/trace/events/kvm.h
index 9c2cc6a96e82..c86f4e8e0bc9 100644
--- a/include/trace/events/kvm.h
+++ b/include/trace/events/kvm.h
@@ -6,6 +6,36 @@
6#undef TRACE_SYSTEM 6#undef TRACE_SYSTEM
7#define TRACE_SYSTEM kvm 7#define TRACE_SYSTEM kvm
8 8
9#define ERSN(x) { KVM_EXIT_##x, "KVM_EXIT_" #x }
10
11#define kvm_trace_exit_reason \
12 ERSN(UNKNOWN), ERSN(EXCEPTION), ERSN(IO), ERSN(HYPERCALL), \
13 ERSN(DEBUG), ERSN(HLT), ERSN(MMIO), ERSN(IRQ_WINDOW_OPEN), \
14 ERSN(SHUTDOWN), ERSN(FAIL_ENTRY), ERSN(INTR), ERSN(SET_TPR), \
15 ERSN(TPR_ACCESS), ERSN(S390_SIEIC), ERSN(S390_RESET), ERSN(DCR),\
16 ERSN(NMI), ERSN(INTERNAL_ERROR), ERSN(OSI)
17
18TRACE_EVENT(kvm_userspace_exit,
19 TP_PROTO(__u32 reason, int errno),
20 TP_ARGS(reason, errno),
21
22 TP_STRUCT__entry(
23 __field( __u32, reason )
24 __field( int, errno )
25 ),
26
27 TP_fast_assign(
28 __entry->reason = reason;
29 __entry->errno = errno;
30 ),
31
32 TP_printk("reason %s (%d)",
33 __entry->errno < 0 ?
34 (__entry->errno == -EINTR ? "restart" : "error") :
35 __print_symbolic(__entry->reason, kvm_trace_exit_reason),
36 __entry->errno < 0 ? -__entry->errno : __entry->reason)
37);
38
9#if defined(__KVM_HAVE_IOAPIC) 39#if defined(__KVM_HAVE_IOAPIC)
10TRACE_EVENT(kvm_set_irq, 40TRACE_EVENT(kvm_set_irq,
11 TP_PROTO(unsigned int gsi, int level, int irq_source_id), 41 TP_PROTO(unsigned int gsi, int level, int irq_source_id),
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 2803b4db2a38..880370caf9ed 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1562,6 +1562,7 @@ static long kvm_vcpu_ioctl(struct file *filp,
1562 if (arg) 1562 if (arg)
1563 goto out; 1563 goto out;
1564 r = kvm_arch_vcpu_ioctl_run(vcpu, vcpu->run); 1564 r = kvm_arch_vcpu_ioctl_run(vcpu, vcpu->run);
1565 trace_kvm_userspace_exit(vcpu->run->exit_reason, r);
1565 break; 1566 break;
1566 case KVM_GET_REGS: { 1567 case KVM_GET_REGS: {
1567 struct kvm_regs *kvm_regs; 1568 struct kvm_regs *kvm_regs;