Skip to contentSkip to conversation

Oprofile doesn't work well in Guest with VPMU

DISCUSSION Wang Hui 1 participant 1 message Mar 30, 2014 KVM

lore
Share & tools
lore

Wang Hui

author
#0 lore raw

Hi

I was using oprofile to measuring hardware events in Guest, I have turn on the cpu host-passthrough mode, but it seems that oprofile can get only one sample.I added some debug info and found that problem is with the perf_event's sample_period.

host's workflow is:

set counter MSR: set sample_period
|
create perf_event (first time, sample_period is right)
|
overflow
|
release perf_event
|
create perf_event (sample_period not reset)
|
set counter MSR: set sample_period (this should be done before create perf_event)

I think this is because oprofile doesn't disable pmu and then enable it, it only reset PMU counter MSR, while this will not reprogram perf_event. After add the code below to ppro_check_ctrs, oprofile works in guest.

wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, 0);

{
    ......
    // reset counter msr
    ......
}

wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL, 0x70000000f);

But I think the better way is to change VPMU mechanism. When set counter msr, it was needed to reprogram counter as well.

Signature · 2 lines
Thanks
Wang Hui