From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH] trace "exit to userspace" event Date: Fri, 8 Oct 2010 18:44:47 +0200 Message-ID: <20101008164447.GC393@redhat.com> References: <20101005131432.GO11145@redhat.com> <20101007161839.GA31784@amt.cnet> <20101007175655.GG2397@redhat.com> <20101008004917.GA11600@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: avi@redhat.com, kvm@vger.kernel.org To: Marcelo Tosatti Return-path: Received: from mx1.redhat.com ([209.132.183.28]:58360 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757124Ab0JHQot (ORCPT ); Fri, 8 Oct 2010 12:44:49 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o98GinSg006119 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 8 Oct 2010 12:44:49 -0400 Content-Disposition: inline In-Reply-To: <20101008004917.GA11600@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, Oct 07, 2010 at 09:49:17PM -0300, Marcelo Tosatti wrote: > On Thu, Oct 07, 2010 at 07:56:55PM +0200, Gleb Natapov wrote: > > > > 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; > > > > -- > > > > Gleb. > > > > > > Exit codes are also valid for r == -EINTR and -EAGAIN cases, eg > > > EXIT_INTR. Better print it out for all cases, and let the reader > > > decide whether exit_reason is valid. > > Are they? I see that userspace does not look into run->exit_reason in > > case of -EINTR and -EAGAIN. > > Not userspace, but for a human reader. Otherwise the trace information > is incomplete and confusing. But if we will always call trace_kvm_userspace_exit() here trace information will show erroneous info since on any error but -EINTR exit_reason contains stale info. What about changing r >= 0 to r >= 0 || r == -EINTR. -- Gleb.