From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wang Hui Subject: Oprofile doesn't work well in Guest with VPMU Date: Sun, 30 Mar 2014 09:37:02 +0800 Message-ID: <5337753E.6040807@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit To: Gleb Natapov , kvm Return-path: Received: from mail-pa0-f47.google.com ([209.85.220.47]:34342 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752583AbaC3BhH (ORCPT ); Sat, 29 Mar 2014 21:37:07 -0400 Received: by mail-pa0-f47.google.com with SMTP id lj1so6575725pab.6 for ; Sat, 29 Mar 2014 18:37:06 -0700 (PDT) Sender: kvm-owner@vger.kernel.org List-ID: 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. -- Thanks Wang Hui