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