Loading...
1#ifndef __PERF_MMAP_H
2#define __PERF_MMAP_H 1
3
4#include <internal/mmap.h>
5#include <linux/compiler.h>
6#include <linux/refcount.h>
7#include <linux/types.h>
8#include <linux/ring_buffer.h>
9#include <stdbool.h>
10#include <pthread.h> // for cpu_set_t
11#ifdef HAVE_AIO_SUPPORT
12#include <aio.h>
13#endif
14#include "auxtrace.h"
15#include "event.h"
16
17struct aiocb;
18/**
19 * struct mmap - perf's ring buffer mmap details
20 *
21 * @refcnt - e.g. code using PERF_EVENT_IOC_SET_OUTPUT to share this
22 */
23struct mmap {
24 struct perf_mmap core;
25 struct auxtrace_mmap auxtrace_mmap;
26#ifdef HAVE_AIO_SUPPORT
27 struct {
28 void **data;
29 struct aiocb *cblocks;
30 struct aiocb **aiocb;
31 int nr_cblocks;
32 } aio;
33#endif
34 cpu_set_t affinity_mask;
35 void *data;
36 int comp_level;
37};
38
39struct mmap_params {
40 int prot, mask, nr_cblocks, affinity, flush, comp_level;
41 struct auxtrace_mmap_params auxtrace_mp;
42};
43
44int perf_mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, int cpu);
45void perf_mmap__munmap(struct mmap *map);
46
47void perf_mmap__get(struct mmap *map);
48void perf_mmap__put(struct mmap *map);
49
50void perf_mmap__consume(struct mmap *map);
51
52static inline u64 perf_mmap__read_head(struct mmap *mm)
53{
54 return ring_buffer_read_head(mm->core.base);
55}
56
57static inline void perf_mmap__write_tail(struct mmap *md, u64 tail)
58{
59 ring_buffer_write_tail(md->core.base, tail);
60}
61
62union perf_event *perf_mmap__read_forward(struct mmap *map);
63
64union perf_event *perf_mmap__read_event(struct mmap *map);
65
66int perf_mmap__push(struct mmap *md, void *to,
67 int push(struct mmap *map, void *to, void *buf, size_t size));
68
69size_t perf_mmap__mmap_len(struct mmap *map);
70
71int perf_mmap__read_init(struct mmap *md);
72void perf_mmap__read_done(struct mmap *map);
73#endif /*__PERF_MMAP_H */
1#ifndef __PERF_MMAP_H
2#define __PERF_MMAP_H 1
3
4#include <internal/mmap.h>
5#include <linux/types.h>
6#include <linux/bitops.h>
7#include <perf/cpumap.h>
8#ifdef HAVE_AIO_SUPPORT
9#include <aio.h>
10#endif
11#include "auxtrace.h"
12#include "util/compress.h"
13
14struct aiocb;
15
16struct mmap_cpu_mask {
17 unsigned long *bits;
18 size_t nbits;
19};
20
21#define MMAP_CPU_MASK_BYTES(m) \
22 (BITS_TO_LONGS(((struct mmap_cpu_mask *)m)->nbits) * sizeof(unsigned long))
23
24/**
25 * struct mmap - perf's ring buffer mmap details
26 *
27 * @refcnt - e.g. code using PERF_EVENT_IOC_SET_OUTPUT to share this
28 */
29struct mmap {
30 struct perf_mmap core;
31 struct auxtrace_mmap auxtrace_mmap;
32#ifdef HAVE_AIO_SUPPORT
33 struct {
34 void **data;
35 struct aiocb *cblocks;
36 struct aiocb **aiocb;
37 int nr_cblocks;
38 } aio;
39#endif
40 struct mmap_cpu_mask affinity_mask;
41 void *data;
42 struct perf_data_file *file;
43 struct zstd_data zstd_data;
44};
45
46struct mmap_params {
47 struct perf_mmap_param core;
48 int nr_cblocks, affinity, flush, comp_level;
49 struct auxtrace_mmap_params auxtrace_mp;
50};
51
52int mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, struct perf_cpu cpu);
53void mmap__munmap(struct mmap *map);
54
55union perf_event *perf_mmap__read_forward(struct mmap *map);
56
57int perf_mmap__push(struct mmap *md, void *to,
58 int push(struct mmap *map, void *to, void *buf, size_t size));
59
60size_t mmap__mmap_len(struct mmap *map);
61
62void mmap_cpu_mask__scnprintf(struct mmap_cpu_mask *mask, const char *tag);
63
64int mmap_cpu_mask__duplicate(struct mmap_cpu_mask *original,
65 struct mmap_cpu_mask *clone);
66
67#endif /*__PERF_MMAP_H */