blob: e25890de6a55d6ba81aa7974e66ac828e0c49718 [file] [log] [blame]
Jiri Olsa547740f2019-07-27 22:07:44 +02001/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef __LIBPERF_INTERNAL_MMAP_H
3#define __LIBPERF_INTERNAL_MMAP_H
4
Jiri Olsa4443e6d2019-07-27 22:47:58 +02005#include <linux/compiler.h>
Jiri Olsae03edfe2019-07-27 22:35:35 +02006#include <linux/refcount.h>
Jiri Olsaebe4d722019-07-27 22:39:53 +02007#include <linux/types.h>
Jiri Olsa8df7a862019-07-27 22:42:56 +02008#include <stdbool.h>
Jiri Olsae03edfe2019-07-27 22:35:35 +02009
Jiri Olsa4443e6d2019-07-27 22:47:58 +020010/* perf sample has 16 bits size limit */
11#define PERF_SAMPLE_MAX_SIZE (1 << 16)
12
Jiri Olsa547740f2019-07-27 22:07:44 +020013/**
14 * struct perf_mmap - perf's ring buffer mmap details
15 *
16 * @refcnt - e.g. code using PERF_EVENT_IOC_SET_OUTPUT to share this
17 */
18struct perf_mmap {
19 void *base;
Jiri Olsa4fd0cef2019-07-27 22:27:55 +020020 int mask;
Jiri Olsa2cf07b22019-07-27 22:31:17 +020021 int fd;
Jiri Olsa56a94702019-07-27 22:33:20 +020022 int cpu;
Jiri Olsae03edfe2019-07-27 22:35:35 +020023 refcount_t refcnt;
Jiri Olsaebe4d722019-07-27 22:39:53 +020024 u64 prev;
25 u64 start;
26 u64 end;
Jiri Olsa8df7a862019-07-27 22:42:56 +020027 bool overwrite;
Jiri Olsa65aa2e62019-08-27 16:05:18 +020028 u64 flush;
Jiri Olsa4443e6d2019-07-27 22:47:58 +020029 char event_copy[PERF_SAMPLE_MAX_SIZE] __aligned(8);
Jiri Olsa547740f2019-07-27 22:07:44 +020030};
31
Jiri Olsa353120b2019-10-07 14:53:09 +020032void perf_mmap__init(struct perf_mmap *map, bool overwrite);
33
Jiri Olsa547740f2019-07-27 22:07:44 +020034#endif /* __LIBPERF_INTERNAL_MMAP_H */