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#ifdef HAVE_AIO_SUPPORT
10#include <aio.h>
11#endif
12#include "auxtrace.h"
13#include "event.h"
14
15struct aiocb;
16
17
18
19
20
21struct perf_mmap {
22 void *base;
23 int mask;
24 int fd;
25 int cpu;
26 refcount_t refcnt;
27 u64 prev;
28 u64 start;
29 u64 end;
30 bool overwrite;
31 struct auxtrace_mmap auxtrace_mmap;
32 char event_copy[PERF_SAMPLE_MAX_SIZE] __aligned(8);
33#ifdef HAVE_AIO_SUPPORT
34 struct {
35 void **data;
36 struct aiocb *cblocks;
37 struct aiocb **aiocb;
38 int nr_cblocks;
39 } aio;
40#endif
41 cpu_set_t affinity_mask;
42 u64 flush;
43 void *data;
44 int comp_level;
45};
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68enum bkw_mmap_state {
69 BKW_MMAP_NOTREADY,
70 BKW_MMAP_RUNNING,
71 BKW_MMAP_DATA_PENDING,
72 BKW_MMAP_EMPTY,
73};
74
75struct mmap_params {
76 int prot, mask, nr_cblocks, affinity, flush, comp_level;
77 struct auxtrace_mmap_params auxtrace_mp;
78};
79
80int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd, int cpu);
81void perf_mmap__munmap(struct perf_mmap *map);
82
83void perf_mmap__get(struct perf_mmap *map);
84void perf_mmap__put(struct perf_mmap *map);
85
86void perf_mmap__consume(struct perf_mmap *map);
87
88static inline u64 perf_mmap__read_head(struct perf_mmap *mm)
89{
90 return ring_buffer_read_head(mm->base);
91}
92
93static inline void perf_mmap__write_tail(struct perf_mmap *md, u64 tail)
94{
95 ring_buffer_write_tail(md->base, tail);
96}
97
98union perf_event *perf_mmap__read_forward(struct perf_mmap *map);
99
100union perf_event *perf_mmap__read_event(struct perf_mmap *map);
101
102int perf_mmap__push(struct perf_mmap *md, void *to,
103 int push(struct perf_mmap *map, void *to, void *buf, size_t size));
104
105size_t perf_mmap__mmap_len(struct perf_mmap *map);
106
107int perf_mmap__read_init(struct perf_mmap *md);
108void perf_mmap__read_done(struct perf_mmap *map);
109#endif
110