From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: Questing regarding KVM Guest PMU Date: Thu, 05 Apr 2012 15:27:18 +0300 Message-ID: <4F7D8FA6.3030402@redhat.com> References: <20120318165120.GF27306@redhat.com> <20120319070728.GI27306@redhat.com> <20120403165850.GA20155@redhat.com> <20120404070435.GA10069@redhat.com> <20120404102932.GA11918@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: shashank rachamalla , kvm@vger.kernel.org To: Gleb Natapov Return-path: Received: from mx1.redhat.com ([209.132.183.28]:45301 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751582Ab2DEM1V (ORCPT ); Thu, 5 Apr 2012 08:27:21 -0400 In-Reply-To: <20120404102932.GA11918@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 04/04/2012 01:29 PM, Gleb Natapov wrote: > > > > > ok. seems to be. will move over to perf as its working fine inside guest. > > > Good riddance IMO. I managed to run it on a guest (but not on my > host!). The thing is buggy. It does not use global ctrl MSR to enable > counters and kvm has all of them disabled by default. I didn't find what > value this MSR should have after reset, so this may be either kvm bug or > real BIOSes enable all counters in global ctrl MSR for PMUv1 > compatibility. Doing "wrmsr 0x38f 0x70000000f" solves this problem. The > second problem is that oprofile reprogram PMU counters without > disabling them first and this is explicitly prohibited by Intel SDM. > The patch below solve that, but oprofile is the one who should be fixed. Both should be fixed, there may be other profilers affected. > > diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c > index a73f0c1..be05028 100644 > --- a/arch/x86/kvm/pmu.c > +++ b/arch/x86/kvm/pmu.c > @@ -396,6 +396,7 @@ int kvm_pmu_set_msr(struct kvm_vcpu *vcpu, u32 index, u64 data) > (pmc = get_fixed_pmc(pmu, index))) { > data = (s64)(s32)data; > pmc->counter += data - read_pmc(pmc); > + reprogram_gp_counter(pmc, pmc->eventsel); > return 0; > } else if ((pmc = get_gp_pmc(pmu, index, MSR_P6_EVNTSEL0))) { > if (data == pmc->eventsel) > -- error compiling committee.c: too many arguments to function