public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: shashank rachamalla <shashank.rachamalla@gmail.com>
Cc: kvm@vger.kernel.org
Subject: Re: Questing regarding KVM Guest PMU
Date: Wed, 4 Apr 2012 13:29:32 +0300	[thread overview]
Message-ID: <20120404102932.GA11918@redhat.com> (raw)
In-Reply-To: <CAMONAZ6ikoOdO88tewG7fEQbUFwSrvgCH2_Wmfbfut5e=shTAA@mail.gmail.com>

On Wed, Apr 04, 2012 at 03:49:42PM +0530, shashank rachamalla wrote:
> tatus: RO
> Content-Length: 2989
> Lines: 79
> 
> On Wed, Apr 4, 2012 at 12:34 PM, Gleb Natapov <gleb@redhat.com> wrote:
> > On Wed, Apr 04, 2012 at 12:24:17AM +0530, shashank rachamalla wrote:
> >> On Wed, Apr 4, 2012 at 12:13 AM, shashank rachamalla
> >> <shashank.rachamalla@gmail.com> wrote:
> >> > On Tue, Apr 3, 2012 at 10:28 PM, Gleb Natapov <gleb@redhat.com> wrote:
> >> >> On Tue, Apr 03, 2012 at 07:20:04PM +0530, shashank rachamalla wrote:
> >> >>> On Mon, Mar 19, 2012 at 12:37 PM, Gleb Natapov <gleb@redhat.com> wrote:
> >> >>> > On Mon, Mar 19, 2012 at 12:20:30PM +0530, shashank rachamalla wrote:
> >> >>> >> On Sun, Mar 18, 2012 at 10:21 PM, Gleb Natapov <gleb@redhat.com> wrote:
> >> >>> >> > On Sun, Mar 18, 2012 at 09:47:55PM +0530, shashank rachamalla wrote:
> >> >>> >> >> >> I guess things are working fine with perf. But why not with oprofile ?
> >> >>> >> >> >>
> >> >>> >> >> > Looks like it. I never tried oprofile. Will try to reproduce your
> >> >>> >> >> > problem and see what oprofile is doing.
> >> >>> >> >>
> >> >>> >> >> I am using ubuntu 10.04 with 2.6.32-21-generic kernel as guest and
> >> >>> >> >> oprofile 0.9.6.
> >> >>> >> >> Also, I have tried to capture kvm-events ( perf patch ) in host while
> >> >>> >> >> running oprofile and perf in guest.
> >> >>> >> >> Please see the attachment. I have run the tests in three cases for the
> >> >>> >> >> around 5 secs.
> >> >>> >> >>
> >> >>> >> >> There are more number of MSR reads and writes in case of perf which I
> >> >>> >> >> think is normal. However, there are very few MSR reads and writes with
> >> >>> >> >> oprofile. Also, the number of NMI exceptions are too high in case of
> >> >>> >> >> oprofile.
> >> >>> >> >>
> >> >>> >> > Which host kernel are you using? Try latest kvm.git and check if you see
> >> >>> >> > something unusual in dmesg.
> >> >>> >>
> >> >>> >> Currenly running 3.3.0-rc5. will try with the latest source from kvm
> >> >>> >> git and let you know.
> >> >>> >>
> >> >>> >>
> >> >>> > Thanks, there were some fixes that didn't make it into 3.3. rdpmc
> >> >>> > instruction emulation fix is one of them. If oprofile uses it this can
> >> >>> > explain the problem.
> >> >>> >
> >> >>> I have tried with latest kvm source from git and also with 3.0 guest
> >> >>> kernel but oprofile fails to collect any samples on guest. I am using
> >> >>> a core2duo processor which is considered by oprofile as pentium pro
> >> >>> model.
> >> >>>
> >> >> core2duo on the host or the guest? What is your qemu command line?
> >> >>
> >> > both. qemu command line below.
> >> > sudo /usr/local/bin/qemu-system-x86_64 -drive
> >> > file=vdisk1.img,if=virtio -cpu host -m 2000 -net nic,model=virtio -net
> >> > user
> >> >
> >>
> >> please find more info ( /proc/cpuinfo and uname of both host and guest
> >> ) in attached files.
> >>
> > oprofile does not work for me even on the host. After trying to use it I can
> > see why perf was written in the first place.
> >
> 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.

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)

--
			Gleb.

  reply	other threads:[~2012-04-04 10:29 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-18 10:18 Questing regarding KVM Guest PMU shashank rachamalla
2012-03-18 10:30 ` Gleb Natapov
2012-03-18 12:57   ` shashank rachamalla
2012-03-18 14:50     ` Avi Kivity
2012-03-18 14:50     ` Gleb Natapov
2012-03-18 16:17       ` shashank rachamalla
2012-03-18 16:51         ` Gleb Natapov
2012-03-19  6:50           ` shashank rachamalla
2012-03-19  7:07             ` Gleb Natapov
2012-04-03 13:50               ` shashank rachamalla
2012-04-03 16:58                 ` Gleb Natapov
2012-04-03 18:43                   ` shashank rachamalla
2012-04-03 18:54                     ` shashank rachamalla
2012-04-04  7:04                       ` Gleb Natapov
2012-04-04 10:19                         ` shashank rachamalla
2012-04-04 10:29                           ` Gleb Natapov [this message]
2012-04-05  2:37                             ` shashank rachamalla
2012-04-05 12:27                             ` Avi Kivity
2012-04-05 12:37                               ` Gleb Natapov
2012-04-05 12:48                                 ` Avi Kivity
2012-04-05 13:26                                   ` Gleb Natapov
2012-04-05 13:28                                     ` Avi Kivity
2012-04-05 13:48                                       ` Gleb Natapov
2012-04-05 13:57                                         ` Gleb Natapov
2012-04-05 14:38                                           ` Avi Kivity
2012-04-05 14:41                                             ` Gleb Natapov
2012-04-06  5:13                                               ` shashank rachamalla
2012-04-06  6:50                                                 ` Gleb Natapov
2012-04-08 15:27                                                   ` Gleb Natapov
2012-04-09  9:26                                                     ` Gleb Natapov
2012-04-10  3:18                                                       ` shashank rachamalla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120404102932.GA11918@redhat.com \
    --to=gleb@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=shashank.rachamalla@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox