简体   繁体   English

如何在KVM guest虚拟机中启用PMU

[英]how to enable PMU in KVM guest

I am running KVM/QEMU in my Lenovo X1 laptop. 我在Lenovo X1笔记本电脑中运行KVM / QEMU。

The guest OS is Ubuntu 15.04 x86_64. 来宾操作系统是Ubuntu 15.04 x86_64。

Now, I want to run 'perf' command in guest OS, but I found followings in guest OS in dmesg. 现在,我想在来宾操作系统中运行“ perf”命令,但是我在dmesg的来宾操作系统中发现了以下内容。

... ...

[ 0.055442] smpboot: CPU0: Intel Xeon E3-12xx v2 (Ivy Bridge) (fam: 06, model: 3a, stepping: 09) [0.055442] smpboot:CPU0:Intel Xeon E3-12xx v2(Ivy Bridge)(家族:06,型号:3a,步进:09)

[ 0.056000] Performance Events: unsupported p6 CPU model 58 no PMU driver, software events only. [0.056000]性能事件:不支持的p6 CPU型号58无PMU驱动程序,仅软件事件。

[ 0.057602] x86: Booting SMP configuration: [0.057602] x86:引导SMP配置:

[ 0.058686] .... node #0, CPUs: #1 [0.058686] ....节点#0,CPU:#1

[ 0.008000] kvm-clock: cpu 1, msr 0:1ffd6041, secondary cpu clock [0.008000] kvm-clock:cpu 1,msr 0:1ffd6041,辅助cpu时钟

... So, the perf command could NOT work hardware PMU event in guest OS. ...因此,perf命令无法在来宾OS中运行硬件PMU事件。

How could I enable hardware PMU from my host to the Ubuntu guest? 如何启用从主机到Ubuntu guest虚拟机的硬件PMU?

Thanks, 谢谢,

-Tao -Tao

Page https://github.com/mozilla/rr/wiki/Building-And-Installing gives some hints how to enable guest PMU: 页面https://github.com/mozilla/rr/wiki/Building-And-Installing提供了有关如何启用来宾PMU的一些提示:

Qemu: On QEMU command line use Qemu:在QEMU命令行上使用

  -cpu host 

Libvirt/KVM: Specify CPU passthrough in domain XML definition: Libvirt / KVM:在域XML定义中指定CPU直通:

  <cpu mode='host-passthrough'/> 

Same advice in https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/virtualization_tuning_and_optimization_guide/sect-virtualization_tuning_optimization_guide-monitoring_tools-vpmu https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/virtualization_tuning_and_optimization_guide/sect-virtualization_tuning_optimization_guide-monitoring_tools-vpmu中的相同建议

I edit <cpu mode='host-passthrough'/> line into /etc/libvirt/qemu/my_vm_name.xml file instead of <cpu>...</cpu> block. 我将<cpu mode='host-passthrough'/>行编辑到/etc/libvirt/qemu/my_vm_name.xml文件而不是<cpu>...</cpu>块中。

(In virt-manager use "host-passthrough" as CPU "Model:" field - http://blog.wikichoon.com/2016/01/using-cpu-host-passthrough-with-virt.html ) (在virt-manager中,将“ host-passthrough”用作CPU“ Model:”字段-http : //blog.wikichoon.com/2016/01/using-cpu-host-passthrough-with-virt.html

Now PMU works, tested with perf stat echo inside the VM, there are "arch_perfmon" in /proc/cpuinfo and PMUs are enabled in dmesg|grep PMU . 现在,PMU可以正常工作了,并在VM内部进行了perf stat echo测试,在/proc/cpuinfo有“ arch_perfmon”,并且在dmesg|grep PMU PMU中启用了dmesg|grep PMU

-cpu host option of Qemu was used according to /var/log/libvirt/qemu/vm_name.log: 根据/var/log/libvirt/qemu/vm_name.log使用Qemu的-cpu host选项:

/usr/bin/kvm-spice ... -machine ...,accel=kvm,... -cpu host ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM