From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Zhang, Yanmin" Subject: Re: KVM PMU virtualization Date: Thu, 04 Mar 2010 08:52:38 +0800 Message-ID: <1267663958.1726.190.camel@localhost> References: <4B86917C.4070102@redhat.com> <20100225173423.GB4246@8bytes.org> <1267152917.1726.82.camel@localhost> <20100226085105.GC4246@8bytes.org> <20100226091732.GI15885@elte.hu> <1267513746.1726.104.camel@localhost> <20100302093629.GB8591@elte.hu> <1267587152.1726.171.camel@localhost> <1267608432.1726.182.camel@localhost> <1267611191.25158.85.camel@laptop> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Cc: Ingo Molnar , Joerg Roedel , Jes Sorensen , KVM General , Avi Kivity , Zachary Amsden , Gleb Natapov , ming.m.lin@intel.com To: Peter Zijlstra Return-path: Received: from mga05.intel.com ([192.55.52.89]:35033 "EHLO fmsmga101.fm.intel.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753670Ab0CDAuU (ORCPT ); Wed, 3 Mar 2010 19:50:20 -0500 In-Reply-To: <1267611191.25158.85.camel@laptop> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, 2010-03-03 at 11:13 +0100, Peter Zijlstra wrote: > On Wed, 2010-03-03 at 17:27 +0800, Zhang, Yanmin wrote: > > +static inline u64 perf_instruction_pointer(struct pt_regs *regs) > > +{ > > + u64 ip; > > + ip = percpu_read(perf_virt_ip.ip); > > + if (!ip) > > + ip = instruction_pointer(regs); > > + else > > + perf_reset_virt_ip(); > > + return ip; > > +} > > + > > +static inline unsigned int perf_misc_flags(struct pt_regs *regs) > > +{ > > + if (percpu_read(perf_virt_ip.ip)) { > > + return percpu_read(perf_virt_ip.user_mode) ? > > + PERF_RECORD_MISC_GUEST_USER : > > + PERF_RECORD_MISC_GUEST_KERNEL; > > + } else > > + return user_mode(regs) ? PERF_RECORD_MISC_USER : > > + PERF_RECORD_MISC_KERNEL; > > +} > > This codes in the assumption that perf_misc_flags() must only be called > before perf_instruction_pointer(), which is currently true, but you > might want to put a comment near to remind us of this. I will change the logic with a clear reset operation in caller.