Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 1 | #ifndef __PERF_MMAP_H |
| 2 | #define __PERF_MMAP_H 1 |
| 3 | |
Jiri Olsa | 547740f | 2019-07-27 22:07:44 +0200 | [diff] [blame] | 4 | #include <internal/mmap.h> |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 5 | #include <linux/compiler.h> |
| 6 | #include <linux/refcount.h> |
| 7 | #include <linux/types.h> |
Daniel Borkmann | 09d62154 | 2018-10-19 15:51:02 +0200 | [diff] [blame] | 8 | #include <linux/ring_buffer.h> |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 9 | #include <stdbool.h> |
Arnaldo Carvalho de Melo | f2a39fe | 2019-08-30 14:45:20 -0300 | [diff] [blame] | 10 | #include <pthread.h> // for cpu_set_t |
Alexey Budankov | 0b77383 | 2018-11-06 12:03:35 +0300 | [diff] [blame] | 11 | #ifdef HAVE_AIO_SUPPORT |
| 12 | #include <aio.h> |
| 13 | #endif |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 14 | #include "auxtrace.h" |
| 15 | #include "event.h" |
| 16 | |
Alexey Budankov | d3d1af6 | 2018-11-06 12:04:58 +0300 | [diff] [blame] | 17 | struct aiocb; |
Alexey Budankov | 9c080c0 | 2019-12-03 14:44:18 +0300 | [diff] [blame] | 18 | |
| 19 | struct mmap_cpu_mask { |
| 20 | unsigned long *bits; |
| 21 | size_t nbits; |
| 22 | }; |
| 23 | |
| 24 | #define MMAP_CPU_MASK_BYTES(m) \ |
| 25 | (BITS_TO_LONGS(((struct mmap_cpu_mask *)m)->nbits) * sizeof(unsigned long)) |
| 26 | |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 27 | /** |
Jiri Olsa | a583053 | 2019-07-27 20:30:53 +0200 | [diff] [blame] | 28 | * struct mmap - perf's ring buffer mmap details |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 29 | * |
| 30 | * @refcnt - e.g. code using PERF_EVENT_IOC_SET_OUTPUT to share this |
| 31 | */ |
Jiri Olsa | a583053 | 2019-07-27 20:30:53 +0200 | [diff] [blame] | 32 | struct mmap { |
Jiri Olsa | 547740f | 2019-07-27 22:07:44 +0200 | [diff] [blame] | 33 | struct perf_mmap core; |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 34 | struct auxtrace_mmap auxtrace_mmap; |
Alexey Budankov | 0b77383 | 2018-11-06 12:03:35 +0300 | [diff] [blame] | 35 | #ifdef HAVE_AIO_SUPPORT |
| 36 | struct { |
Alexey Budankov | 93f20c0 | 2018-11-06 12:07:19 +0300 | [diff] [blame] | 37 | void **data; |
| 38 | struct aiocb *cblocks; |
| 39 | struct aiocb **aiocb; |
Alexey Budankov | d3d1af6 | 2018-11-06 12:04:58 +0300 | [diff] [blame] | 40 | int nr_cblocks; |
Alexey Budankov | 0b77383 | 2018-11-06 12:03:35 +0300 | [diff] [blame] | 41 | } aio; |
| 42 | #endif |
Alexey Budankov | 8384a26 | 2019-12-03 14:45:27 +0300 | [diff] [blame^] | 43 | struct mmap_cpu_mask affinity_mask; |
Alexey Budankov | 51255a8 | 2019-03-18 20:42:19 +0300 | [diff] [blame] | 44 | void *data; |
| 45 | int comp_level; |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 46 | }; |
| 47 | |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 48 | struct mmap_params { |
Jiri Olsa | e440979 | 2019-10-07 14:53:10 +0200 | [diff] [blame] | 49 | struct perf_mmap_param core; |
| 50 | int nr_cblocks, affinity, flush, comp_level; |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 51 | struct auxtrace_mmap_params auxtrace_mp; |
| 52 | }; |
| 53 | |
Jiri Olsa | 32c261c | 2019-10-07 14:53:12 +0200 | [diff] [blame] | 54 | int mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, int cpu); |
Jiri Olsa | 59d7ea62 | 2019-10-07 14:53:14 +0200 | [diff] [blame] | 55 | void mmap__munmap(struct mmap *map); |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 56 | |
Jiri Olsa | a583053 | 2019-07-27 20:30:53 +0200 | [diff] [blame] | 57 | union perf_event *perf_mmap__read_forward(struct mmap *map); |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 58 | |
Jiri Olsa | a583053 | 2019-07-27 20:30:53 +0200 | [diff] [blame] | 59 | int perf_mmap__push(struct mmap *md, void *to, |
| 60 | int push(struct mmap *map, void *to, void *buf, size_t size)); |
Arnaldo Carvalho de Melo | 73c17d8 | 2017-10-06 10:46:01 -0300 | [diff] [blame] | 61 | |
Jiri Olsa | bf59b30 | 2019-10-07 14:53:11 +0200 | [diff] [blame] | 62 | size_t mmap__mmap_len(struct mmap *map); |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 63 | |
Alexey Budankov | 9c080c0 | 2019-12-03 14:44:18 +0300 | [diff] [blame] | 64 | void mmap_cpu_mask__scnprintf(struct mmap_cpu_mask *mask, const char *tag); |
| 65 | |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 66 | #endif /*__PERF_MMAP_H */ |