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!