3

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
David Yeager
  • 596
  • 5
  • 9

1 Answers1

5

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 ...
osgx
  • 90,338
  • 53
  • 357
  • 513
  • some docs about KVM and PMU: http://www.linux-kvm.org/page/Guest_PMU 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.html "is disabled by default." - to get PMU there should be support "`cat /proc/cpuinfo|grep arch_perfmon`, `virsh dumpxml guest_name |grep "cpu mode"`" – osgx Nov 04 '16 at 16:56