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> |
Riccardo Mancini | 5d4da30 | 2021-08-21 11:19:11 +0200 | [diff] [blame] | 9 | #include <linux/bitops.h> |
Ian Rogers | 6d18804 | 2022-01-04 22:13:51 -0800 | [diff] [blame] | 10 | #include <perf/cpumap.h> |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 11 | #include <stdbool.h> |
Arnaldo Carvalho de Melo | f2a39fe | 2019-08-30 14:45:20 -0300 | [diff] [blame] | 12 | #include <pthread.h> // for cpu_set_t |
Alexey Budankov | 0b77383 | 2018-11-06 12:03:35 +0300 | [diff] [blame] | 13 | #ifdef HAVE_AIO_SUPPORT |
| 14 | #include <aio.h> |
| 15 | #endif |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 16 | #include "auxtrace.h" |
| 17 | #include "event.h" |
| 18 | |
Alexey Budankov | d3d1af6 | 2018-11-06 12:04:58 +0300 | [diff] [blame] | 19 | struct aiocb; |
Alexey Budankov | 9c080c0 | 2019-12-03 14:44:18 +0300 | [diff] [blame] | 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 | |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 29 | /** |
Jiri Olsa | a583053 | 2019-07-27 20:30:53 +0200 | [diff] [blame] | 30 | * struct mmap - perf's ring buffer mmap details |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 31 | * |
| 32 | * @refcnt - e.g. code using PERF_EVENT_IOC_SET_OUTPUT to share this |
| 33 | */ |
Jiri Olsa | a583053 | 2019-07-27 20:30:53 +0200 | [diff] [blame] | 34 | struct mmap { |
Jiri Olsa | 547740f | 2019-07-27 22:07:44 +0200 | [diff] [blame] | 35 | struct perf_mmap core; |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 36 | struct auxtrace_mmap auxtrace_mmap; |
Alexey Budankov | 0b77383 | 2018-11-06 12:03:35 +0300 | [diff] [blame] | 37 | #ifdef HAVE_AIO_SUPPORT |
| 38 | struct { |
Alexey Budankov | 93f20c0 | 2018-11-06 12:07:19 +0300 | [diff] [blame] | 39 | void **data; |
| 40 | struct aiocb *cblocks; |
| 41 | struct aiocb **aiocb; |
Alexey Budankov | d3d1af6 | 2018-11-06 12:04:58 +0300 | [diff] [blame] | 42 | int nr_cblocks; |
Alexey Budankov | 0b77383 | 2018-11-06 12:03:35 +0300 | [diff] [blame] | 43 | } aio; |
| 44 | #endif |
Alexey Budankov | 8384a26 | 2019-12-03 14:45:27 +0300 | [diff] [blame] | 45 | struct mmap_cpu_mask affinity_mask; |
Alexey Budankov | 51255a8 | 2019-03-18 20:42:19 +0300 | [diff] [blame] | 46 | void *data; |
| 47 | int comp_level; |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 48 | }; |
| 49 | |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 50 | struct mmap_params { |
Jiri Olsa | e440979 | 2019-10-07 14:53:10 +0200 | [diff] [blame] | 51 | struct perf_mmap_param core; |
| 52 | int nr_cblocks, affinity, flush, comp_level; |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 53 | struct auxtrace_mmap_params auxtrace_mp; |
| 54 | }; |
| 55 | |
Ian Rogers | 6d18804 | 2022-01-04 22:13:51 -0800 | [diff] [blame] | 56 | int mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, struct perf_cpu cpu); |
Jiri Olsa | 59d7ea62 | 2019-10-07 14:53:14 +0200 | [diff] [blame] | 57 | void mmap__munmap(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 | union perf_event *perf_mmap__read_forward(struct mmap *map); |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 60 | |
Jiri Olsa | a583053 | 2019-07-27 20:30:53 +0200 | [diff] [blame] | 61 | int perf_mmap__push(struct mmap *md, void *to, |
| 62 | 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] | 63 | |
Jiri Olsa | bf59b30 | 2019-10-07 14:53:11 +0200 | [diff] [blame] | 64 | size_t mmap__mmap_len(struct mmap *map); |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 65 | |
Alexey Budankov | 9c080c0 | 2019-12-03 14:44:18 +0300 | [diff] [blame] | 66 | void mmap_cpu_mask__scnprintf(struct mmap_cpu_mask *mask, const char *tag); |
| 67 | |
Riccardo Mancini | 6bd006c | 2021-08-21 11:19:10 +0200 | [diff] [blame] | 68 | int mmap_cpu_mask__duplicate(struct mmap_cpu_mask *original, |
| 69 | struct mmap_cpu_mask *clone); |
| 70 | |
Arnaldo Carvalho de Melo | 1695849 | 2017-10-06 10:31:47 -0300 | [diff] [blame] | 71 | #endif /*__PERF_MMAP_H */ |