On Wed, Jul 09, 2014 at 10:05:55AM -0400, Vince Weaver wrote: > Not really sure by what you mean by "real-time", but you can theoretically > set up the perf_event mmap buffer with a low threshold, and have it > configured to send a signal to your program whenever an event comes in. > In theory you can get the PEBS-like info out that way. It's going to have > fairly high overhead though, especially if you set the sample rate high.
On Wed, Jul 09, 2014 at 03:54:18PM +0200, Jiri Olsa wrote: > hi, > you could use perf_event_create_kernel_counter interface, > check the lockup watchdog in kernel/watchdog.c Vince and Jiri, Thank you very much for your replies. I re-read my email and I'm not sure I was clear, so just in case I didn't made myself clear, here's a high-level example of what I'm looking for. /*******************/ /* Gets called whenever my program generates a cache-miss */ void my_func() { unsigned long addr = get_ip_that_generated_event(); printf("A cache-miss occurred at IP: %x!\n", addr); } int main() { struct perf_event_attr pe; pe.type = PERF_TYPE_HARDWARE. pe.config = PERF_COUNT_HW_CACHE_MISSES; ... register_handler(&pe, my_func); // code to be monitored unregister_handler(); return 0; } /*******************/ Every time an event occurs (a cache-miss in my example), my_func should get called. The get_ip_that_generated_event() function should return the Instruction Pointer that generated the event. My impression is that this could be done with a low overhead (other then that introduced by what I do in my_func), because "perf record -e cache-misses ./a.out" can pinpoint with little overhead how many times the event was caused by each instruction. But maybe I'm just missing something. Vince: I'm unsure how to configure the mmap buffer you mentioned, and I couldn't find any examples online. Could you please point me to some reference, or maybe provide a little example? Jiri: I'm under the impression I'd have to be in a kernel module (or in kernel mode in general) to use perf_event_create_kernel_counter(). Is that correct? Thank you once again, -Martin
pgpTpBAyguFza.pgp
Description: PGP signature