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; |
Rob Herring | 47d01e7 | 2021-04-14 11:07:39 -0500 | [diff] [blame^] | 14 | struct perf_counts_values; |
Jiri Olsa | 80e53d1 | 2019-10-07 14:53:15 +0200 | [diff] [blame] | 15 | |
| 16 | typedef void (*libperf_unmap_cb_t)(struct perf_mmap *map); |
| 17 | |
Jiri Olsa | 547740f | 2019-07-27 22:07:44 +0200 | [diff] [blame] | 18 | /** |
| 19 | * struct perf_mmap - perf's ring buffer mmap details |
| 20 | * |
| 21 | * @refcnt - e.g. code using PERF_EVENT_IOC_SET_OUTPUT to share this |
| 22 | */ |
| 23 | struct perf_mmap { |
Jiri Olsa | 80e53d1 | 2019-10-07 14:53:15 +0200 | [diff] [blame] | 24 | void *base; |
| 25 | int mask; |
| 26 | int fd; |
| 27 | int cpu; |
| 28 | refcount_t refcnt; |
| 29 | u64 prev; |
| 30 | u64 start; |
| 31 | u64 end; |
| 32 | bool overwrite; |
| 33 | u64 flush; |
| 34 | libperf_unmap_cb_t unmap_cb; |
| 35 | char event_copy[PERF_SAMPLE_MAX_SIZE] __aligned(8); |
Jiri Olsa | 6eb65f7 | 2019-10-17 12:59:09 +0200 | [diff] [blame] | 36 | struct perf_mmap *next; |
Jiri Olsa | 547740f | 2019-07-27 22:07:44 +0200 | [diff] [blame] | 37 | }; |
| 38 | |
Jiri Olsa | e440979 | 2019-10-07 14:53:10 +0200 | [diff] [blame] | 39 | struct perf_mmap_param { |
| 40 | int prot; |
| 41 | int mask; |
| 42 | }; |
| 43 | |
Jiri Olsa | bf59b30 | 2019-10-07 14:53:11 +0200 | [diff] [blame] | 44 | size_t perf_mmap__mmap_len(struct perf_mmap *map); |
| 45 | |
Jiri Olsa | 6eb65f7 | 2019-10-17 12:59:09 +0200 | [diff] [blame] | 46 | void perf_mmap__init(struct perf_mmap *map, struct perf_mmap *prev, |
| 47 | bool overwrite, libperf_unmap_cb_t unmap_cb); |
Jiri Olsa | 32c261c | 2019-10-07 14:53:12 +0200 | [diff] [blame] | 48 | int perf_mmap__mmap(struct perf_mmap *map, struct perf_mmap_param *mp, |
| 49 | int fd, int cpu); |
Jiri Olsa | 59d7ea62 | 2019-10-07 14:53:14 +0200 | [diff] [blame] | 50 | void perf_mmap__munmap(struct perf_mmap *map); |
Jiri Olsa | e75710f | 2019-10-07 14:53:13 +0200 | [diff] [blame] | 51 | void perf_mmap__get(struct perf_mmap *map); |
Jiri Olsa | 80e53d1 | 2019-10-07 14:53:15 +0200 | [diff] [blame] | 52 | void perf_mmap__put(struct perf_mmap *map); |
Jiri Olsa | 353120b | 2019-10-07 14:53:09 +0200 | [diff] [blame] | 53 | |
Jiri Olsa | 7728fa0 | 2019-10-07 14:53:17 +0200 | [diff] [blame] | 54 | u64 perf_mmap__read_head(struct perf_mmap *map); |
| 55 | |
Rob Herring | 47d01e7 | 2021-04-14 11:07:39 -0500 | [diff] [blame^] | 56 | int perf_mmap__read_self(struct perf_mmap *map, struct perf_counts_values *count); |
| 57 | |
Jiri Olsa | 547740f | 2019-07-27 22:07:44 +0200 | [diff] [blame] | 58 | #endif /* __LIBPERF_INTERNAL_MMAP_H */ |