Linux perf events profiling in Google Compute Engine not working

雨燕双飞 提交于 2020-06-12 09:07:23

问题


I'm new to using Google Compute Engine. I'd like to use the Linux perf tool to do some various perf events measurements of my application and eventually sample profiling. I've installed the linux perf tool on my Ubuntu 16.04 LTS VM. However even basic events like cycles show up as "not supported". I'm guessing that the underlying KVM hypervisor does not have virtual PMU support enabled, although I believe KVM does support this with a non-default flag setting. Is there any way to get this working?

# perf stat -e cycles -a sleep 10

Performance counter stats for 'system wide':

<not supported>      cycles                   

  10.000598339 seconds time elapsed

回答1:


Linux perf tool by default tries to use hardware performance monitoring counters. When your OS is virtualized, you have no direct access to all counters; several virtualization solutions may allow access to some basic counters, if configured.

In your case it seems that GCE virtualization give no such access. (Ask support of your GCE? If it was disabled outside of your VM, you cant change this.)

You may use perf with some software events, for example -e task-clock to get basic profiling. Check perf stat output for supported events and perf list for Software events.

perf stat -e task-clock ...
perf record -e task-clock ...


来源:https://stackoverflow.com/questions/40180636/linux-perf-events-profiling-in-google-compute-engine-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!