hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/tools/perf/util/mmap.h
....@@ -1,102 +1,66 @@
11 #ifndef __PERF_MMAP_H
22 #define __PERF_MMAP_H 1
33
4
+#include <internal/mmap.h>
45 #include <linux/compiler.h>
56 #include <linux/refcount.h>
67 #include <linux/types.h>
7
-#include <asm/barrier.h>
8
+#include <linux/ring_buffer.h>
89 #include <stdbool.h>
10
+#include <pthread.h> // for cpu_set_t
11
+#ifdef HAVE_AIO_SUPPORT
12
+#include <aio.h>
13
+#endif
914 #include "auxtrace.h"
1015 #include "event.h"
1116
17
+struct aiocb;
18
+
19
+struct 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
+
1227 /**
13
- * struct perf_mmap - perf's ring buffer mmap details
28
+ * struct mmap - perf's ring buffer mmap details
1429 *
1530 * @refcnt - e.g. code using PERF_EVENT_IOC_SET_OUTPUT to share this
1631 */
17
-struct perf_mmap {
18
- void *base;
19
- int mask;
20
- int fd;
21
- int cpu;
22
- refcount_t refcnt;
23
- u64 prev;
24
- u64 start;
25
- u64 end;
26
- bool overwrite;
32
+struct mmap {
33
+ struct perf_mmap core;
2734 struct auxtrace_mmap auxtrace_mmap;
28
- char event_copy[PERF_SAMPLE_MAX_SIZE] __aligned(8);
29
-};
30
-
31
-/*
32
- * State machine of bkw_mmap_state:
33
- *
34
- * .________________(forbid)_____________.
35
- * | V
36
- * NOTREADY --(0)--> RUNNING --(1)--> DATA_PENDING --(2)--> EMPTY
37
- * ^ ^ | ^ |
38
- * | |__(forbid)____/ |___(forbid)___/|
39
- * | |
40
- * \_________________(3)_______________/
41
- *
42
- * NOTREADY : Backward ring buffers are not ready
43
- * RUNNING : Backward ring buffers are recording
44
- * DATA_PENDING : We are required to collect data from backward ring buffers
45
- * EMPTY : We have collected data from backward ring buffers.
46
- *
47
- * (0): Setup backward ring buffer
48
- * (1): Pause ring buffers for reading
49
- * (2): Read from ring buffers
50
- * (3): Resume ring buffers for recording
51
- */
52
-enum bkw_mmap_state {
53
- BKW_MMAP_NOTREADY,
54
- BKW_MMAP_RUNNING,
55
- BKW_MMAP_DATA_PENDING,
56
- BKW_MMAP_EMPTY,
35
+#ifdef HAVE_AIO_SUPPORT
36
+ struct {
37
+ void **data;
38
+ struct aiocb *cblocks;
39
+ struct aiocb **aiocb;
40
+ int nr_cblocks;
41
+ } aio;
42
+#endif
43
+ struct mmap_cpu_mask affinity_mask;
44
+ void *data;
45
+ int comp_level;
5746 };
5847
5948 struct mmap_params {
60
- int prot, mask;
49
+ struct perf_mmap_param core;
50
+ int nr_cblocks, affinity, flush, comp_level;
6151 struct auxtrace_mmap_params auxtrace_mp;
6252 };
6353
64
-int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd, int cpu);
65
-void perf_mmap__munmap(struct perf_mmap *map);
54
+int mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, int cpu);
55
+void mmap__munmap(struct mmap *map);
6656
67
-void perf_mmap__get(struct perf_mmap *map);
68
-void perf_mmap__put(struct perf_mmap *map);
57
+union perf_event *perf_mmap__read_forward(struct mmap *map);
6958
70
-void perf_mmap__consume(struct perf_mmap *map);
59
+int perf_mmap__push(struct mmap *md, void *to,
60
+ int push(struct mmap *map, void *to, void *buf, size_t size));
7161
72
-static inline u64 perf_mmap__read_head(struct perf_mmap *mm)
73
-{
74
- struct perf_event_mmap_page *pc = mm->base;
75
- u64 head = READ_ONCE(pc->data_head);
76
- rmb();
77
- return head;
78
-}
62
+size_t mmap__mmap_len(struct mmap *map);
7963
80
-static inline void perf_mmap__write_tail(struct perf_mmap *md, u64 tail)
81
-{
82
- struct perf_event_mmap_page *pc = md->base;
64
+void mmap_cpu_mask__scnprintf(struct mmap_cpu_mask *mask, const char *tag);
8365
84
- /*
85
- * ensure all reads are done before we write the tail out.
86
- */
87
- mb();
88
- pc->data_tail = tail;
89
-}
90
-
91
-union perf_event *perf_mmap__read_forward(struct perf_mmap *map);
92
-
93
-union perf_event *perf_mmap__read_event(struct perf_mmap *map);
94
-
95
-int perf_mmap__push(struct perf_mmap *md, void *to,
96
- int push(void *to, void *buf, size_t size));
97
-
98
-size_t perf_mmap__mmap_len(struct perf_mmap *map);
99
-
100
-int perf_mmap__read_init(struct perf_mmap *md);
101
-void perf_mmap__read_done(struct perf_mmap *map);
10266 #endif /*__PERF_MMAP_H */