lkml.org 
[lkml]   [2011]   [Nov]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCHv2 2/9] KVM: Expose a version 2 architectural PMU to a guests
On Mon, Nov 07, 2011 at 03:36:49PM +0100, Peter Zijlstra wrote:
> On Thu, 2011-11-03 at 14:33 +0200, Gleb Natapov wrote:
> > +static u64 read_pmc(struct kvm_pmc *pmc)
> > +{
> > + u64 counter, enabled, running;
> > +
> > + counter = pmc->counter;
> > +
> > + if (pmc->perf_event)
> > + counter += perf_event_read_value(pmc->perf_event,
> > + &enabled, &running);
> > +
> > + /* FIXME: Scaling needed? */
>
> Since the below programming doesn't use perf_event_attr::pinned, yes.
>
Yes, that is on todo :). Actually I do want to place all guest perf
counters into the same event group and make it pinned. But currently perf
event groups are not very flexible. In our usage scenario we can't have
one event as a group leader since events are created and destroyed very
dynamically. What I would like is to have something like meta event that
will group all other real event.

> > + return counter & pmc_bitmask(pmc);
> > +}
>
> > +static void reprogram_counter(struct kvm_pmc *pmc, u32 type,
> > + unsigned config, bool exclude_user, bool exclude_kernel,
> > + bool intr)
> > +{
> > + struct perf_event *event;
> > + struct perf_event_attr attr = {
> > + .type = type,
> > + .size = sizeof(attr),
> > + .exclude_idle = true,
> > + .exclude_host = 1,
> > + .exclude_user = exclude_user,
> > + .exclude_kernel = exclude_kernel,
> > + .sample_period = (-pmc->counter) & pmc_bitmask(pmc),
> > + .config = config,
> > + };
> > +
> > + event = perf_event_create_kernel_counter(&attr, -1, current,
> > + intr ? kvm_perf_overflow_intr :
> > + kvm_perf_overflow, pmc);
> > + if (IS_ERR(event)) {
> > + printk_once("kvm: pmu event creation failed %ld\n",
> > + PTR_ERR(event));
> > + return;
> > + }
> > +
> > + pmc->perf_event = event;
> > + clear_bit(pmc->idx, (unsigned long*)&pmc->vcpu->arch.pmu.reprogram_pmi);
> > +}

--
Gleb.


\
 
 \ /
  Last update: 2011-11-07 16:29    [W:0.110 / U:77.164 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site