In the KVM-based machine, each VM is a process, with several threads running concurrently. You can use ps -eLf to display all the VM threads. When measuring the performance of the VM, you should also specify the thread ids in the perf_event_open function.
Tianwei On Apr 10, 2015, at 12:17 PM, Jueyuan Zhu <[email protected]> wrote: > Hi Chris, > > Thanks for your suggestions. Since I am using the perf_event_open in the host > OS, not in the guest OS. So does it need the support of PMU virtualization? I > used the perf command below to measure the VM, and it can give correct > results. So I am wondering how to use perf_event_open to get the same results > as the perf user command? > > #perf stat -e instructions -p VM_id sleep 1 > > Thank you! > > -Jueyuan > > On Apr 10, 2015, at 11:39 AM, Christopher Covington <[email protected]> > wrote: > >> Hi Jueyuan, >> >> On 04/09/2015 11:46 PM, Jueyuan Zhu wrote: >>> Hello, >>> >>> I am trying to use the perf-event to measure the events for one specified >>> VM in KVM platform. Since each VM is just a process in the host OS, so I >>> thought >>> we could just set the process id of this VM in the perf-event_open API to >>> count the events. The following is my code (based on the example from >>> perf_event_open linux manual). >> >>> However, this program’s output keeps constant whenever this VM is idle, or >>> running different benchmarks. So it seems the event counting is incorrect. >>> Can >>> anyone tell me how to set the flags or perf_event_attr to correctly count >>> the >>> VM events using perf_event_open? >> >> You may want to check that the QEMU or kvmtool you're using correctly >> virtualizes or emulates the PMU for your architecture. Information about this >> might be in the documentation or release notes or if not you could try asking >> on the QEMU or kvmtool mailing list tool. >> >> Chris >> >> -- >> Qualcomm Innovation Center, Inc. >> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, >> a Linux Foundation Collaborative Project > > -- > To unsubscribe from this list: send the line "unsubscribe linux-perf-users" in > the body of a message to [email protected] > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-perf-users" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
