From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Subject: Re: KVM PMU virtualization Date: Wed, 03 Mar 2010 11:13:11 +0100 Message-ID: <1267611191.25158.85.camel@laptop> 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> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" 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: "Zhang, Yanmin" Return-path: Received: from bombadil.infradead.org ([18.85.46.34]:40813 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751715Ab0CCKNP (ORCPT ); Wed, 3 Mar 2010 05:13:15 -0500 Received: from e35131.upc-e.chello.nl ([213.93.35.131] helo=dyad.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.69 #1 (Red Hat Linux)) id 1NmlZq-0004K6-EZ for kvm@vger.kernel.org; Wed, 03 Mar 2010 10:13:14 +0000 In-Reply-To: <1267608432.1726.182.camel@localhost> Sender: kvm-owner@vger.kernel.org List-ID: 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.