For some reason, I can't sample (perf record) hardware cache events:
# perf record -e L1-dcache-stores -a -c 100 -- sleep 5
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.607 MB perf.data (~26517 samples) ]
# perf script
but I can count them (perf stat):
# perf stat -e L1-dcache-stores -a -- sleep 5
  Performance counter stats for 'sleep 5':
     711,781 L1-dcache-stores                                            
     5.000842990 seconds time elapsed
I tried on different CPUs, OS versions (and kernel versions), perf versions but the result is the same. Is this an expected behaviour? What is the reason? Can't perf warn about this?
                        
There is a difference in
perf evlist -vvvoutput of three perf.data, one of cache event, second of software event, and last of hw cycles event:There are different types, and types are defined as
Perf script has a
outputtable which defines how to print event of every kind: http://lxr.free-electrons.com/source/tools/perf/builtin-script.c?v=3.16#L68So, there is no instructions of printing any of field from samples with type 3 - PERF_TYPE_HW_CACHE, and
perf scriptdoes not print them. We can try to register this type inoutputarray and even push the patch to kernel.