Jiri Olsa | 547740f | 2019-07-27 22:07:44 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | #ifndef __LIBPERF_INTERNAL_MMAP_H |
| 3 | #define __LIBPERF_INTERNAL_MMAP_H |
| 4 | |
Jiri Olsa | 4443e6d | 2019-07-27 22:47:58 +0200 | [diff] [blame] | 5 | #include <linux/compiler.h> |
Jiri Olsa | e03edfe | 2019-07-27 22:35:35 +0200 | [diff] [blame] | 6 | #include <linux/refcount.h> |
Jiri Olsa | ebe4d72 | 2019-07-27 22:39:53 +0200 | [diff] [blame] | 7 | #include <linux/types.h> |
Jiri Olsa | 8df7a86 | 2019-07-27 22:42:56 +0200 | [diff] [blame] | 8 | #include <stdbool.h> |
Jiri Olsa | e03edfe | 2019-07-27 22:35:35 +0200 | [diff] [blame] | 9 | |
Jiri Olsa | 4443e6d | 2019-07-27 22:47:58 +0200 | [diff] [blame] | 10 | /* perf sample has 16 bits size limit */ |
| 11 | #define PERF_SAMPLE_MAX_SIZE (1 << 16) |
| 12 | |
Jiri Olsa | 80e53d1 | 2019-10-07 14:53:15 +0200 | [diff] [blame] | 13 | struct perf_mmap; |
| 14 | |
| 15 | typedef void (*libperf_unmap_cb_t)(struct perf_mmap *map); |
| 16 | |
Jiri Olsa | 547740f | 2019-07-27 22:07:44 +0200 | [diff] [blame] | 17 | /** |
| 18 | * struct perf_mmap - perf's ring buffer mmap details |
| 19 | * |
| 20 | * @refcnt - e.g. code using PERF_EVENT_IOC_SET_OUTPUT to share this |
| 21 | */ |
| 22 | struct perf_mmap { |
Jiri Olsa | 80e53d1 | 2019-10-07 14:53:15 +0200 | [diff] [blame] | 23 | void *base; |
| 24 | int mask; |
| 25 | int fd; |
| 26 | int cpu; |
| 27 | refcount_t refcnt; |
| 28 | u64 prev; |
| 29 | u64 start; |
| 30 | u64 end; |
| 31 | bool overwrite; |
| 32 | u64 flush; |
| 33 | libperf_unmap_cb_t unmap_cb; |
| 34 | char event_copy[PERF_SAMPLE_MAX_SIZE] __aligned(8); |
Jiri Olsa | 547740f | 2019-07-27 22:07:44 +0200 | [diff] [blame] | 35 | }; |
| 36 | |
Jiri Olsa | e440979 | 2019-10-07 14:53:10 +0200 | [diff] [blame] | 37 | struct perf_mmap_param { |
| 38 | int prot; |
| 39 | int mask; |
| 40 | }; |
| 41 | |
Jiri Olsa | bf59b30 | 2019-10-07 14:53:11 +0200 | [diff] [blame] | 42 | size_t perf_mmap__mmap_len(struct perf_mmap *map); |
| 43 | |
Jiri Olsa | 80e53d1 | 2019-10-07 14:53:15 +0200 | [diff] [blame] | 44 | void perf_mmap__init(struct perf_mmap *map, bool overwrite, |
| 45 | libperf_unmap_cb_t unmap_cb); |
Jiri Olsa | 32c261c | 2019-10-07 14:53:12 +0200 | [diff] [blame] | 46 | int perf_mmap__mmap(struct perf_mmap *map, struct perf_mmap_param *mp, |
| 47 | int fd, int cpu); |
Jiri Olsa | 59d7ea62 | 2019-10-07 14:53:14 +0200 | [diff] [blame] | 48 | void perf_mmap__munmap(struct perf_mmap *map); |
Jiri Olsa | e75710f | 2019-10-07 14:53:13 +0200 | [diff] [blame] | 49 | void perf_mmap__get(struct perf_mmap *map); |
Jiri Olsa | 80e53d1 | 2019-10-07 14:53:15 +0200 | [diff] [blame] | 50 | void perf_mmap__put(struct perf_mmap *map); |
Jiri Olsa | 353120b | 2019-10-07 14:53:09 +0200 | [diff] [blame] | 51 | |
Jiri Olsa | 7728fa0 | 2019-10-07 14:53:17 +0200 | [diff] [blame] | 52 | u64 perf_mmap__read_head(struct perf_mmap *map); |
| 53 | |
Jiri Olsa | 547740f | 2019-07-27 22:07:44 +0200 | [diff] [blame] | 54 | #endif /* __LIBPERF_INTERNAL_MMAP_H */ |