1 #ifndef __PERF_MMAP_H 2 #define __PERF_MMAP_H 1 3 4 #include <linux/compiler.h> 5 #include <linux/refcount.h> 6 #include <linux/types.h> 7 #include <linux/ring_buffer.h> 8 #include <stdbool.h> 9 #include <pthread.h> // for cpu_set_t 10 #ifdef HAVE_AIO_SUPPORT 11 #include <aio.h> 12 #endif 13 #include "auxtrace.h" 14 #include "event.h" 15 16 struct aiocb; 17 /** 18 * struct mmap - perf's ring buffer mmap details 19 * 20 * @refcnt - e.g. code using PERF_EVENT_IOC_SET_OUTPUT to share this 21 */ 22 struct mmap { 23 void *base; 24 int mask; 25 int fd; 26 int cpu; 27 refcount_t refcnt; 28 u64 prev; 29 u64 start; 30 u64 end; 31 bool overwrite; 32 struct auxtrace_mmap auxtrace_mmap; 33 char event_copy[PERF_SAMPLE_MAX_SIZE] __aligned(8); 34 #ifdef HAVE_AIO_SUPPORT 35 struct { 36 void **data; 37 struct aiocb *cblocks; 38 struct aiocb **aiocb; 39 int nr_cblocks; 40 } aio; 41 #endif 42 cpu_set_t affinity_mask; 43 u64 flush; 44 void *data; 45 int comp_level; 46 }; 47 48 struct mmap_params { 49 int prot, mask, nr_cblocks, affinity, flush, comp_level; 50 struct auxtrace_mmap_params auxtrace_mp; 51 }; 52 53 int perf_mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, int cpu); 54 void perf_mmap__munmap(struct mmap *map); 55 56 void perf_mmap__get(struct mmap *map); 57 void perf_mmap__put(struct mmap *map); 58 59 void perf_mmap__consume(struct mmap *map); 60 61 static inline u64 perf_mmap__read_head(struct mmap *mm) 62 { 63 return ring_buffer_read_head(mm->base); 64 } 65 66 static inline void perf_mmap__write_tail(struct mmap *md, u64 tail) 67 { 68 ring_buffer_write_tail(md->base, tail); 69 } 70 71 union perf_event *perf_mmap__read_forward(struct mmap *map); 72 73 union perf_event *perf_mmap__read_event(struct mmap *map); 74 75 int perf_mmap__push(struct mmap *md, void *to, 76 int push(struct mmap *map, void *to, void *buf, size_t size)); 77 78 size_t perf_mmap__mmap_len(struct mmap *map); 79 80 int perf_mmap__read_init(struct mmap *md); 81 void perf_mmap__read_done(struct mmap *map); 82 #endif /*__PERF_MMAP_H */ 83