6

My professor has asked me to run:

perf stat -e mem-loads,mem-stores ./test

In order for me to find the memory loads and stores for a C file. I'm doing this from within a VirtualBox Linux guest and problem is that perf is saying this is an invalid or unsupported event, can anyone advise as to what I'm doing wrong here?

invalid or unsupported event: 'mem-loads,'
Run 'perf list' for a list of valid events

 Usage: perf stat [<options>] [<command>]

    -e, --event <event>   event selector. use 'perf list' to list available events

Are perf hardware events available from within a VirtualBox guest?

Rachid K.
  • 4,490
  • 3
  • 11
  • 30
Jason
  • 105
  • 1
  • 8

1 Answers1

8

With a few exceptions (that don't include VirtualBox), you cannot use hardware PMU events in perf from within a virtual machine guest on Linux.

Perhaps there are lab computers that have native Linux installations, or you could use a bootable Linux flash drive to do you test. If your professor was the one who suggested a virtual machine in the first place, you could raise the issue with them.

BeeOnRope
  • 60,350
  • 16
  • 207
  • 386
  • Is this still the case? I am unable to get stats regarding branch misprediction or cycles. "Not supported" I assume it's because the VM running in virtualbox doesn't have access? – Tony Tannous Nov 15 '20 at 19:42
  • @Tony – could be, I am not up to date on VirtualBox support for PMU counters. – BeeOnRope Nov 15 '20 at 20:07