From patchwork Tue Oct 5 13:14:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 232731 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o95DEcgY020819 for ; Tue, 5 Oct 2010 13:14:38 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752715Ab0JENOf (ORCPT ); Tue, 5 Oct 2010 09:14:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34065 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752699Ab0JENOe (ORCPT ); Tue, 5 Oct 2010 09:14:34 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o95DEYs5001541 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 5 Oct 2010 09:14:34 -0400 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o95DEWSq008221; Tue, 5 Oct 2010 09:14:33 -0400 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id 2DE5518D46C; Tue, 5 Oct 2010 15:14:32 +0200 (IST) Date: Tue, 5 Oct 2010 15:14:32 +0200 From: Gleb Natapov To: avi@redhat.com, mtosatti@redhat.com Cc: kvm@vger.kernel.org Subject: [PATCH] trace "exit to userspace" event Message-ID: <20101005131432.GO11145@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 05 Oct 2010 13:14:38 +0000 (UTC) diff --git a/include/trace/events/kvm.h b/include/trace/events/kvm.h index 6dd3a51..fb44da0 100644 --- a/include/trace/events/kvm.h +++ b/include/trace/events/kvm.h @@ -6,6 +6,31 @@ #undef TRACE_SYSTEM #define TRACE_SYSTEM kvm +#define ERSN(x) { KVM_EXIT_##x, "KVM_EXIT_" #x } + +#define kvm_trace_exit_reason \ + ERSN(UNKNOWN), ERSN(EXCEPTION), ERSN(IO), ERSN(HYPERCALL), \ + ERSN(DEBUG), ERSN(HLT), ERSN(MMIO), ERSN(IRQ_WINDOW_OPEN), \ + ERSN(SHUTDOWN), ERSN(FAIL_ENTRY), ERSN(INTR), ERSN(SET_TPR), \ + ERSN(TPR_ACCESS), ERSN(S390_SIEIC), ERSN(S390_RESET), ERSN(DCR),\ + ERSN(NMI), ERSN(INTERNAL_ERROR), ERSN(OSI) + +TRACE_EVENT(kvm_userspace_exit, + TP_PROTO(__u32 reason), + TP_ARGS(reason), + + TP_STRUCT__entry( + __field( __u32, reason ) + ), + + TP_fast_assign( + __entry->reason = reason; + ), + + TP_printk("reason %s", __print_symbolic(__entry->reason, + kvm_trace_exit_reason)) +); + #if defined(__KVM_HAVE_IOAPIC) TRACE_EVENT(kvm_set_irq, 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 b8499f5..8800713 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1458,6 +1458,8 @@ static long kvm_vcpu_ioctl(struct file *filp, if (arg) goto out; r = kvm_arch_vcpu_ioctl_run(vcpu, vcpu->run); + if (r >= 0) + trace_kvm_userspace_exit(vcpu->run->exit_reason); break; case KVM_GET_REGS: { struct kvm_regs *kvm_regs;