16

I am using perf 3.0.4 on ubuntu 11.10. Its record command works well and displays on terminal 256 samples collected. But when I make use of perf report , it gives me the following error:

perf.data file has no samples

I searched a lot for the solution but no success yet.

Xara
  • 7,568
  • 14
  • 47
  • 79
  • please give us the command your using to record events. – Manuel Selva Jan 17 '14 at 12:09
  • 2
    have you solved your issue ? – Manuel Selva Feb 11 '14 at 14:59
  • Just to give another reason the error might be happening: it might be [because events requested are not enabled in kernel](https://bugzilla.kernel.org/show_bug.cgi?id=207297#c1). Like for example, if you record one of `sched:` events, you gotta set `sudo sysctl kernel.sched_schedstats=1`. – Hi-Angel Apr 16 '20 at 11:36

3 Answers3

14

This thread has some useful information: http://www.spinics.net/lists/linux-perf-users/msg01436.html

It seems that if you are running in a VM that does not expose the PMU to the guest, the default collection (-e cycles) won't work. Try running with -e cpu-clock. According to that thread, the OP had the same problem also in a real host running Ubuntu 10.04, so it might solve it for you too...

Martina Ferrari
  • 341
  • 2
  • 6
  • 1
    Thank you! This helped me troubleshoot an issue with flamegraphs (which rely on `perf`). Hopefully my mentioning flamegraphs this comment will help others find this topic. – John Hart Mar 13 '17 at 23:46
  • That did not help me, but thank you for pointing out the problem might be that it's running in the VM! – lucidbrot Dec 19 '20 at 15:10
5

The number of samples reported by the perf record command is an approximation and not the correct number of events (see perf wiki here).

To get the accurate number of events, dump the raw file and use wc -l to count then number of results:

perf report -D -i perf.data | grep RECORD_SAMPLE | wc -l

This command should report 0 in your case where perf report says it can't find events.

Let us know more information about how you use perf record, which event are you sampling, which hardware, which program.

EDIT: you can try first to increase the sampling period or frequency with the -c or -F options

Manuel Selva
  • 16,987
  • 21
  • 76
  • 127
3

Whenever I run into this on a machine where perf record has worked in the past, it is because I have left something else running that uses the performance counters, e.g., I have perf top running in another terminal tab.

In this case, it seems that perf record simply doesn't record any PMU related samples.

BeeOnRope
  • 51,419
  • 13
  • 149
  • 309