Re: KVM PMU virtualization

Joerg Roedel
2010-02-25T17:34:25Z

On Thu, Feb 25, 2010 at 04:04:28PM +0100, Jes Sorensen wrote:

> 1) Add support to perf to allow it to monitor a KVM guest from the
> host.

This shouldn't be a big problem. The PMU of AMD Fam10 processors can be
configured to count only when in guest mode. Perf needs to be aware of
that and fetch the rip from a different place when monitoring a guest.

> 2) Allow guests access to the PMU (or an emulated PMU), making it
> possible to run perf on applications running within the guest.

The biggest problem I see here is teaching the guest about the available
events. The available event sets are dependent on the processor family
(at least on AMD).
A simple approach would be shadowing the perf msrs which is a simple
thing to do. More problematic is the reinjection of performance
interrupts and performance nmis.

I personally don't like a self-defined event-set as the only solution
because that would probably only work with linux and perf. I think we
should have a way (additionally to a soft-event interface) which allows
to expose the host pmu events to the guest.

Joerg