7

recently I am digging things around performance counter. And I googled up the perfmon2 and libpfm4 http://perfmon2.sourceforge.net/ and I also found perf command https://perf.wiki.kernel.org/index.php/Main_Page and shipped out with linux's kernel source code. the perf source code link I played both libpfm4 and perf command, and libpfm4 seems can only provide cpu's cycles count or instructions count.

I can't found any example code or runnable example of how to retrieve information like L1-dcache-loads which seems obtainable by using perf, I looked it up on stackoverflow and found articles discussing the relationship between perf command and libpfm4 :Using Hardware Performance Counters in Linux People said the author of libpfm4 was angry with one of the perf command's contributor Ingo but later on he actually helping review the perf's code.

So can some one explain what's relationship between perfmon2 or libpfm4 with perf command. And can I retrieve information like L1-dcache using libpfm4 just like use perf command. Thank you very much!

Community
  • 1
  • 1
dotcomXY
  • 1,586
  • 1
  • 15
  • 18

1 Answers1

8

The perf command provides a subset of common performance counter events to measure such as processor clock cycles, instructions counts, and cache event metrics. However, most processors provide many other implementation specific hardware events such a floating point operations and microarchitecture events (such as stalls due to hardware resource limits). To access those implementation specific events one needs to use the raw event in perf (http://lxr.linux.no/#linux+v3.6/tools/perf/Documentation/perf-record.txt#L33), which can be tedious. libpfm4 provides a mapping mechanism to refer to those implementation specific hardware events by name. libpfm is used by papi. You might take a look to see how papi uses libpfm to access those implementation specific events (http://icl.cs.utk.edu/projects/papi/)

dotcomXY
  • 1,586
  • 1
  • 15
  • 18
  • There is a webpage [link](http://www.hpl.hp.com/research/linux/perfmon/perfmon.php4) gives the overview of the perfmon kernel interface. But it says that papi is based on PerfCtr Interface and none of these interfaces were even part of the official kernel source tree. So I didn't dig into it. I just looked at the papi home page, it seems that papi has improved a lot. However, perf command is under the official kernel source tree and it indeed provide powerful function. And after exploring its source code, it seems in deed somehow complex to extract specific function out. Thanks man! – dotcomXY Oct 02 '12 at 20:22