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