Re: KVM PMU virtualization

Peter Zijlstra
2010-03-01T18:17:44Z

On Mon, 2010-03-01 at 12:11 +0100, Joerg Roedel wrote:
>
> 1. Enhance perf to count pmu events only when cpu is in guest mode.

No enhancements needed, only hardware support for Intel doesn't provide
this iirc.

> 2. For every emulated performance counter the guest activates kvm
> allocates a perf_event and configures it for the guest (we may allow
> kvm to specify the counter index, the guest would be able to use
> rdpmc unintercepted then). Event filtering is also done in this step.

rdpmc can never be used unintercepted, for perf might be multiplexing
the actual hw.

> 3. Before vmrun the guest activates all its counters,

Right, this is could be used to approximate the guest only counting. I'm
not sure how the OS and USR bits interact with guest stuff - if the PMU
isn't aware of the virtualized priv levels then those will not work as
expected.

> this can fail if
> the host uses them or the requested pmc index is not available for some
> reason.

perf doesn't know about pmc indexes at the interface level, nor is that
needed I think.

> 4. Some additional magic to reinject pmu events into the guest

Right, that is needed, and might be 'interesting' since we get them from
NMI context.