Using linux performance counters from within application
I'm interested in using the new performance counter functionality from kernel 2.6.32. I've built the perf tool, and it seems like exactly what I want, but I'm wondering if there is a good way of embedding this functionality in an application.
Specifically, my goal is to profile only a portion of code, and trigger the beginning and end of the measurement from calls within the code. It seems that the perf tool is really just a wrapper for calling the sys_perf_event_open system call, so I assume that I probably want to call this directly from my code, but I haven't been able to find any decent documentation on that particular system call.
Does anyone know where I can find some documentation? Or is there perhaps a better way to go about this? The particular event counters I want (to start with at least) are the instruction count, cache miss counts, tlb misses, branch mispredictions, and malloc calls.