From: Gleb Natapov <gleb@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: shashank rachamalla <shashank.rachamalla@gmail.com>, kvm@vger.kernel.org
Subject: Re: Questing regarding KVM Guest PMU
Date: Thu, 5 Apr 2012 16:26:53 +0300 [thread overview]
Message-ID: <20120405132653.GJ11204@redhat.com> (raw)
In-Reply-To: <4F7D94B3.8090300@redhat.com>
On Thu, Apr 05, 2012 at 03:48:51PM +0300, Avi Kivity wrote:
> On 04/05/2012 03:37 PM, Gleb Natapov wrote:
> > On Thu, Apr 05, 2012 at 03:27:18PM +0300, Avi Kivity wrote:
> > > 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.
> > >
> > Global ctrl msr issue I need to investigate further, but second one is
> > bug that should be fixed in oprofile. Intel spec clearly says:
> >
> > EN (Enable Counters) Flag (bit 22) — When set, performance counting
> > is enabled in the corresponding performance-monitoring counter; when
> > clear, the corresponding counter is disabled. The event logic unit
> > for a UMASK must be disabled by setting IA32_PERFEVTSELx[bit 22] = 0,
> > before writing to IA32_PMCx.
> >
> > I suspect that on real HW they got wrong result too. It simply subtly
> > wrong, so it is not as noticeable as with kvm.
> >
>
> First, there is the standard Linus rant to never break userspace (and
We broke nothing. Oprofile is broken and never could have worked
according to Intel spec. (It didn't manage to get any result from it on
real CPU, but may be this is unrelated).
> for us a guest kernel is userspace). Second, the Intel rule may have
> been added later (as preparation for a change in behaviour), so it may
> actually work correctly on older hardware.
>
May be (the rule is specified for MPUv1 BTW), but we emulate newer HW,
the one that spec describes and we report this in cpuid leaf 10. I
highly doubt Intel would change CPU in a way that may make old software
to work incorrectly on newer cpus.
--
Gleb.
next prev parent reply other threads:[~2012-04-05 13:26 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
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 [this message]
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=20120405132653.GJ11204@redhat.com \
--to=gleb@redhat.com \
--cc=avi@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