According to perf tutorials, perf stat
is supposed to report cache misses using hardware counters. However, on my system (up-to-date Arch Linux), it doesn't:
[joel@panda goog]$ perf stat ./hash
Performance counter stats for './hash':
869.447863 task-clock # 0.997 CPUs utilized
92 context-switches # 0.106 K/sec
4 cpu-migrations # 0.005 K/sec
1,041 page-faults # 0.001 M/sec
2,628,646,296 cycles # 3.023 GHz
819,269,992 stalled-cycles-frontend # 31.17% frontend cycles idle
132,355,435 stalled-cycles-backend # 5.04% backend cycles idle
4,515,152,198 instructions # 1.72 insns per cycle
# 0.18 stalled cycles per insn
1,060,739,808 branches # 1220.015 M/sec
2,653,157 branch-misses # 0.25% of all branches
0.871766141 seconds time elapsed
What am I missing? I already searched the man page and the web, but didn't find anything obvious.
Edit: my CPU is an Intel i5 2300K, if that matters.
perf
, but I've usedPAPI
(icl.cs.utk.edu/PAPI) and it's possible to check the available hardware counters to find out what can you get from your CPU.perf stat -d
- it will report some cache events. Check also newperf mem
tool for record/report memory events - documented in linuxtag.org/2013/fileadmin/www.linuxtag.org/slides/… slide 10 and man7.org/linux/man-pages/man1/perf-mem.1.htmlperf stat -d
will turn on event multiplexing, which sometimes may report incorrect rates. It is better to manually select no more than 5-7 hw events per run; and use perf stat -d only to get names of such events. Other way for Intel - try toplev.py from github.com/andikleen/pmu-tools