How to do it...

The interface introduces a sys_perf_event_open() syscall, with the counters being started and stopped using ioctls, and read either with read() calls or mmapping samples into circular buffers. The perf_event_open() syscall is defined as follows:

#include <linux/perf_event.h> 
#include <linux/hw_breakpoint.h> 
 
int perf_event_open(struct perf_event_attr *attr, 
                    pid_t pid, int cpu, int group_fd, 
                    unsigned long flags); 

There is no C library wrapper for it, so it needs to be called using syscall().

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset