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