blob: 9d5f589f02ae70e187539ad08202157c08801771 [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;
Alexey Budankov9c080c02019-12-03 14:44:18 +030018
19struct mmap_cpu_mask {
20 unsigned long *bits;
21 size_t nbits;
22};
23
24#define MMAP_CPU_MASK_BYTES(m) \
25 (BITS_TO_LONGS(((struct mmap_cpu_mask *)m)->nbits) * sizeof(unsigned long))
26
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030027/**
Jiri Olsaa5830532019-07-27 20:30:53 +020028 * struct mmap - perf's ring buffer mmap details
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030029 *
30 * @refcnt - e.g. code using PERF_EVENT_IOC_SET_OUTPUT to share this
31 */
Jiri Olsaa5830532019-07-27 20:30:53 +020032struct mmap {
Jiri Olsa547740f2019-07-27 22:07:44 +020033 struct perf_mmap core;
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030034 struct auxtrace_mmap auxtrace_mmap;
Alexey Budankov0b773832018-11-06 12:03:35 +030035#ifdef HAVE_AIO_SUPPORT
36 struct {
Alexey Budankov93f20c02018-11-06 12:07:19 +030037 void **data;
38 struct aiocb *cblocks;
39 struct aiocb **aiocb;
Alexey Budankovd3d1af62018-11-06 12:04:58 +030040 int nr_cblocks;
Alexey Budankov0b773832018-11-06 12:03:35 +030041 } aio;
42#endif
Alexey Budankov8384a262019-12-03 14:45:27 +030043 struct mmap_cpu_mask affinity_mask;
Alexey Budankov51255a82019-03-18 20:42:19 +030044 void *data;
45 int comp_level;
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030046};
47
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030048struct mmap_params {
Jiri Olsae4409792019-10-07 14:53:10 +020049 struct perf_mmap_param core;
50 int nr_cblocks, affinity, flush, comp_level;
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030051 struct auxtrace_mmap_params auxtrace_mp;
52};
53
Jiri Olsa32c261c2019-10-07 14:53:12 +020054int mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, int cpu);
Jiri Olsa59d7ea622019-10-07 14:53:14 +020055void mmap__munmap(struct mmap *map);
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030056
Jiri Olsaa5830532019-07-27 20:30:53 +020057union perf_event *perf_mmap__read_forward(struct mmap *map);
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030058
Jiri Olsaa5830532019-07-27 20:30:53 +020059int perf_mmap__push(struct mmap *md, void *to,
60 int push(struct mmap *map, void *to, void *buf, size_t size));
Arnaldo Carvalho de Melo73c17d82017-10-06 10:46:01 -030061
Jiri Olsabf59b302019-10-07 14:53:11 +020062size_t mmap__mmap_len(struct mmap *map);
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030063
Alexey Budankov9c080c02019-12-03 14:44:18 +030064void mmap_cpu_mask__scnprintf(struct mmap_cpu_mask *mask, const char *tag);
65
Arnaldo Carvalho de Melo16958492017-10-06 10:31:47 -030066#endif /*__PERF_MMAP_H */