Re: KVM PMU virtualization

Ingo Molnar
2010-02-25T16:26:54Z

* 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.

That's a neat feature: the guest profiling tools would immediately (and
transparently) be able to measure VM exits or IO heaviness, on a per guest
basis, as seen on the host side.

More would be possible too.

Thanks,

Ingo