blob: 0b15702be1a5ebba5ad3bf597065e3c8c31aebba [file] [log] [blame]
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -03001#ifndef __PERF_MMAP_H
2#define __PERF_MMAP_H 1
3
Jiri Olsa547740f2019-07-27 22:07:44 +02004#include <internal/mmap.h>
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -03005#include <linux/compiler.h>
6#include <linux/refcount.h>
7#include <linux/types.h>
Daniel Borkmann09d621542018-10-19 15:51:02 +02008#include <linux/ring_buffer.h>
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -03009#include <stdbool.h>
Arnaldo Carvalho de Melof2a39fe2019-08-30 14:45:20 -030010#include <pthread.h> // for cpu_set_t
Alexey Budankov0b773832018-11-06 12:03:35 +030011#ifdef HAVE_AIO_SUPPORT
12#include <aio.h>
13#endif
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030014#include "auxtrace.h"
15#include "event.h"
16
Alexey Budankovd3d1af62018-11-06 12:04:58 +030017struct aiocb;
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030018/**
Jiri Olsaa5830532019-07-27 20:30:53 +020019 * struct mmap - perf's ring buffer mmap details
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030020 *
21 * @refcnt - e.g. code using PERF_EVENT_IOC_SET_OUTPUT to share this
22 */
Jiri Olsaa5830532019-07-27 20:30:53 +020023struct mmap {
Jiri Olsa547740f2019-07-27 22:07:44 +020024 struct perf_mmap core;
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030025 struct auxtrace_mmap auxtrace_mmap;
Alexey Budankov0b773832018-11-06 12:03:35 +030026#ifdef HAVE_AIO_SUPPORT
27 struct {
Alexey Budankov93f20c02018-11-06 12:07:19 +030028 void **data;
29 struct aiocb *cblocks;
30 struct aiocb **aiocb;
Alexey Budankovd3d1af62018-11-06 12:04:58 +030031 int nr_cblocks;
Alexey Budankov0b773832018-11-06 12:03:35 +030032 } aio;
33#endif
Alexey Budankov9d2ed642019-01-22 20:47:43 +030034 cpu_set_t affinity_mask;
Alexey Budankov51255a82019-03-18 20:42:19 +030035 void *data;
36 int comp_level;
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030037};
38
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030039struct mmap_params {
Jiri Olsae4409792019-10-07 14:53:10 +020040 struct perf_mmap_param core;
41 int nr_cblocks, affinity, flush, comp_level;
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030042 struct auxtrace_mmap_params auxtrace_mp;
43};
44
Jiri Olsa32c261c2019-10-07 14:53:12 +020045int mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, int cpu);
Jiri Olsa59d7ea622019-10-07 14:53:14 +020046void mmap__munmap(struct mmap *map);
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030047
Jiri Olsaa5830532019-07-27 20:30:53 +020048union perf_event *perf_mmap__read_forward(struct mmap *map);
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030049
Jiri Olsaa5830532019-07-27 20:30:53 +020050union perf_event *perf_mmap__read_event(struct mmap *map);
Kan Liang7bb45972018-01-18 13:26:23 -080051
Jiri Olsaa5830532019-07-27 20:30:53 +020052int perf_mmap__push(struct mmap *md, void *to,
53 int push(struct mmap *map, void *to, void *buf, size_t size));
Arnaldo Carvalho de Melo73c17d82017-10-06 10:46:01 -030054
Jiri Olsabf59b302019-10-07 14:53:11 +020055size_t mmap__mmap_len(struct mmap *map);
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030056
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030057#endif /*__PERF_MMAP_H */