blob: 83f6bd4d40828626086a31406e166d29f9f3d261 [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>
Riccardo Mancini5d4da302021-08-21 11:19:11 +02009#include <linux/bitops.h>
Ian Rogers6d188042022-01-04 22:13:51 -080010#include <perf/cpumap.h>
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030011#include <stdbool.h>
Arnaldo Carvalho de Melof2a39fe2019-08-30 14:45:20 -030012#include <pthread.h> // for cpu_set_t
Alexey Budankov0b773832018-11-06 12:03:35 +030013#ifdef HAVE_AIO_SUPPORT
14#include <aio.h>
15#endif
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030016#include "auxtrace.h"
17#include "event.h"
18
Alexey Budankovd3d1af62018-11-06 12:04:58 +030019struct aiocb;
Alexey Budankov9c080c02019-12-03 14:44:18 +030020
21struct 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 Melo16958492017-10-06 10:31:47 -030029/**
Jiri Olsaa5830532019-07-27 20:30:53 +020030 * struct mmap - perf's ring buffer mmap details
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030031 *
32 * @refcnt - e.g. code using PERF_EVENT_IOC_SET_OUTPUT to share this
33 */
Jiri Olsaa5830532019-07-27 20:30:53 +020034struct mmap {
Jiri Olsa547740f2019-07-27 22:07:44 +020035 struct perf_mmap core;
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030036 struct auxtrace_mmap auxtrace_mmap;
Alexey Budankov0b773832018-11-06 12:03:35 +030037#ifdef HAVE_AIO_SUPPORT
38 struct {
Alexey Budankov93f20c02018-11-06 12:07:19 +030039 void **data;
40 struct aiocb *cblocks;
41 struct aiocb **aiocb;
Alexey Budankovd3d1af62018-11-06 12:04:58 +030042 int nr_cblocks;
Alexey Budankov0b773832018-11-06 12:03:35 +030043 } aio;
44#endif
Alexey Budankov8384a262019-12-03 14:45:27 +030045 struct mmap_cpu_mask affinity_mask;
Alexey Budankov51255a82019-03-18 20:42:19 +030046 void *data;
47 int comp_level;
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030048};
49
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030050struct mmap_params {
Jiri Olsae4409792019-10-07 14:53:10 +020051 struct perf_mmap_param core;
52 int nr_cblocks, affinity, flush, comp_level;
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030053 struct auxtrace_mmap_params auxtrace_mp;
54};
55
Ian Rogers6d188042022-01-04 22:13:51 -080056int mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, struct perf_cpu cpu);
Jiri Olsa59d7ea622019-10-07 14:53:14 +020057void mmap__munmap(struct mmap *map);
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030058
Jiri Olsaa5830532019-07-27 20:30:53 +020059union perf_event *perf_mmap__read_forward(struct mmap *map);
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030060
Jiri Olsaa5830532019-07-27 20:30:53 +020061int perf_mmap__push(struct mmap *md, void *to,
62 int push(struct mmap *map, void *to, void *buf, size_t size));
Arnaldo Carvalho de Melo73c17d82017-10-06 10:46:01 -030063
Jiri Olsabf59b302019-10-07 14:53:11 +020064size_t mmap__mmap_len(struct mmap *map);
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030065
Alexey Budankov9c080c02019-12-03 14:44:18 +030066void mmap_cpu_mask__scnprintf(struct mmap_cpu_mask *mask, const char *tag);
67
Riccardo Mancini6bd006c2021-08-21 11:19:10 +020068int mmap_cpu_mask__duplicate(struct mmap_cpu_mask *original,
69 struct mmap_cpu_mask *clone);
70
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030071#endif /*__PERF_MMAP_H */