Re: KVM PMU virtualization

Ingo Molnar
2010-02-26T08:46:02Z

* Zhang, Yanmin <yanmin_zhang@linux.intel.com> wrote:

> On Thu, 2010-02-25 at 17:26 +0100, Ingo Molnar wrote:
> > * Jan Kiszka <jan.kiszka@siemens.com> wrote:
> >
> > > Jes Sorensen wrote:
> > > > Hi,
> > > >
> > > > It looks like several of us have been looking at how to use the PMU
> > > > for virtualization. Rather than continuing to have discussions in
> > > > smaller groups, I think it is a good idea we move it to the mailing
> > > > lists to see what we can share and avoid duplicate efforts.
> > > >
> > > > There are really two separate things to handle:
> > > >
> > > > 1) Add support to perf to allow it to monitor a KVM guest from the
> > > > host.
> > > >
> > > > 2) Allow guests access to the PMU (or an emulated PMU), making it
> > > > possible to run perf on applications running within the guest.
> > > >
> > > > I know some of you have been looking at 1) and I am currently working
> > > > on 2). I have been looking at various approaches, including whether it
> > > > is feasible to share the PMU between the host and multiple guests. For
> > > > now I am going to focus on allowing one guest to take control of the
> > > > PMU, then later hopefully adding support for multiplexing it between
> > > > multiple guests.
> > >
> > > Given that perf can apply the PMU to individual host tasks, I don't see
> > > fundamental problems multiplexing it between individual guests (which can
> > > then internally multiplex it again).
> >
> > In terms of how to expose it to guests, a 'soft PMU' might be a usable
> > approach. Although to Linux guests you could expose much more
> > functionality and an non-PMU-limited number of instrumentation events, via
> > a more intelligent interface.
> >
> > But note that in terms of handling it on the host side the PMU approach is
> > not acceptable: instead it should map to proper perf_events, not try to
> > muck with the PMU itself.
>
>
> > That, besides integrating properly with perf usage on the host, will also
> > allow interesting 'PMU' features on guests: you could set up the host side
> > to trace block IO requests (or VM exits) for example, and expose that as
> > 'PMC
> > #0' on the guest side.
>
> So virtualization becomes non-transparent to guest os? I know virtio is an
> optimization on guest side.

The 'soft PMU' is transparent. The 'count IO events' kind of feature could be
transparent too: you could re-configure (on the host) a given 'hardware' event
to really count some software event.

That would make it compatible with whatever guest side tooling (without having
to change that tooling) - while still allowing interesting new things to be
measured.

Thanks,

Ingo