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 <linux/bitops.h>
10 #include <perf/cpumap.h>
11 #include <stdbool.h>
12 #ifdef HAVE_AIO_SUPPORT
13 #include <aio.h>
14 #endif
15 #include "auxtrace.h"
16 #include "event.h"
17 #include "util/compress.h"
18 
19 struct aiocb;
20 
21 struct mmap_cpu_mask {
22 	unsigned long *bits;
23 	size_t nbits;
24 };
25 
26 #define MMAP_CPU_MASK_BYTES(m) \
27 	(BITS_TO_LONGS(((struct mmap_cpu_mask *)m)->nbits) * sizeof(unsigned long))
28 
29 /**
30  * struct mmap - perf's ring buffer mmap details
31  *
32  * @refcnt - e.g. code using PERF_EVENT_IOC_SET_OUTPUT to share this
33  */
34 struct mmap {
35 	struct perf_mmap	core;
36 	struct auxtrace_mmap auxtrace_mmap;
37 #ifdef HAVE_AIO_SUPPORT
38 	struct {
39 		void		 **data;
40 		struct aiocb	 *cblocks;
41 		struct aiocb	 **aiocb;
42 		int		 nr_cblocks;
43 	} aio;
44 #endif
45 	struct mmap_cpu_mask	affinity_mask;
46 	void		*data;
47 	int		comp_level;
48 	struct perf_data_file *file;
49 	struct zstd_data      zstd_data;
50 };
51 
52 struct mmap_params {
53 	struct perf_mmap_param core;
54 	int nr_cblocks, affinity, flush, comp_level;
55 	struct auxtrace_mmap_params auxtrace_mp;
56 };
57 
58 int mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, struct perf_cpu cpu);
59 void mmap__munmap(struct mmap *map);
60 
61 union perf_event *perf_mmap__read_forward(struct mmap *map);
62 
63 int perf_mmap__push(struct mmap *md, void *to,
64 		    int push(struct mmap *map, void *to, void *buf, size_t size));
65 
66 size_t mmap__mmap_len(struct mmap *map);
67 
68 void mmap_cpu_mask__scnprintf(struct mmap_cpu_mask *mask, const char *tag);
69 
70 int mmap_cpu_mask__duplicate(struct mmap_cpu_mask *original,
71 				struct mmap_cpu_mask *clone);
72 
73 #endif /*__PERF_MMAP_H */
74