You have virtualized Ubuntu and hardware counters (PMU/PMC MSR registers) were not virtualized. Xen (or other virtualization software) should know how to work with PMC registers, emulate them for guest and forward requests to real hardware. I don't know is it done in Xen. But for Amazon AWS EC2 it took years to implement only basic hardware events (and only on dedicated instances), they were done only in May 2017: http://www.brendangregg.com/blog/2017-05-04/the-pmcs-of-ec2.html "The PMCs of EC2: Measuring IPC" by Brendan Gregg:
Performance Monitoring Counters (PMCs) are now publicly available from dedicated host types in the AWS EC2 cloud. PMC nerds worldwide rejoice! (All six of us.) ...
In this post I'll summarize the PMCs available in EC2, which are for dedicated hosts only (eg, m4.16xl, i3.16xl), and I'll demonstrate measuring IPC. Note that PMCs are also known as HPCs (hardware performance counters), and other names as well.
He also explains about Xen and why they are enabled in rare cases:
How is this even possible in the cloud?
You might be wondering how cloud guests can read PMCs at all. It works
like this: PMCs are managed via the privileged instructions RDMSR and
WRMSR for configuration (which I wrote about in The MSRs of EC2), and
RDPMC for reading. A privileged instruction causes a guest exit, which
is handled by the hypervisor. The hypervisor can then run its own
code, and configure PMCs if the actual hardware allows, and save and
restore their state whenever it context switches between guests.
Mainstream Xen supported this years ago, with its virtual Performance
Monitoring Unit (vPMU). It is configured using vpmu=on
in the Xen boot
line. However, it is rarely turned on. Why?
There are hundreds of PMCs, and they are all exposed with vpmu=on.
Could some pose a security risk? A number of papers have been
published showing PMC side-channel attacks, whereby measuring certain
PMCs while sending input to a known target program can eventually leak
bits of the target's state. While these are unlikely in practice, and
such attacks aren't limited to PMCs (eg, there's also timing attacks),
you can understand a paranoid security policy not wanting to enable
all PMCs by default.
So, the solutions:
- Run perf on not-virtualized (native, host) Linux (Ubuntu or any other).
- Use Xen with
vpmu=on
boot option enabled (only if you don't give virtual guests of this PC to untrusted users)
- Use other virtualization solution with virtualizated PMU. Some basic events may be enabled in Vmware according to VirtualBox page: https://gist.github.com/dannas/1fa2cfb0d3d108282955 "Notes about performance counters for Virtualbox" pmu_notes.txt by dannas (good review). Some are emulated for guests by KVM: https://stackoverflow.com/a/43460663
PS: old perf list
did not check anything, it just printed all known events, even not supported / not implemented hw events. And it did not print real set of CPU events. libpfm4 has tables and there is Intel-specific perf wrapper ocperf.py of github.com/andikleen/pmu-tools to use Intel-specific names.