]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blame - tools/perf/util/evlist.h
perf tools: Rename 'struct perf_mmap' to 'struct mmap'
[mirror_ubuntu-hirsute-kernel.git] / tools / perf / util / evlist.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
361c99a6
ACM
2#ifndef __PERF_EVLIST_H
3#define __PERF_EVLIST_H 1
4
5c97cac6 5#include <linux/compiler.h>
877a7a11 6#include <linux/kernel.h>
25a3720c 7#include <linux/refcount.h>
361c99a6 8#include <linux/list.h>
1b85337d 9#include <api/fd/array.h>
50d08e47 10#include <stdio.h>
ce9036a6 11#include <internal/evlist.h>
47729258 12#include "events_stats.h"
0c21f736 13#include "evsel.h"
16958497 14#include "mmap.h"
9607ad3a 15#include <signal.h>
35b9d88e 16#include <unistd.h>
361c99a6 17
5c581041 18struct pollfd;
f8a95309 19struct thread_map;
f854839b 20struct perf_cpu_map;
b4006796 21struct record_opts;
5c581041 22
70db7533
ACM
23#define PERF_EVLIST__HLIST_BITS 8
24#define PERF_EVLIST__HLIST_SIZE (1 << PERF_EVLIST__HLIST_BITS)
25
63503dba 26struct evlist {
ce9036a6 27 struct perf_evlist core;
70db7533 28 struct hlist_head heads[PERF_EVLIST__HLIST_SIZE];
97f63e4a 29 int nr_groups;
aece948f 30 int nr_mmaps;
2b56bcfb 31 bool enabled;
994a1f78 32 size_t mmap_len;
75562573
AH
33 int id_pos;
34 int is_pos;
35 u64 combined_sample_type;
54cc54de 36 enum bkw_mmap_state bkw_mmap_state;
35b9d88e
ACM
37 struct {
38 int cork_fd;
39 pid_t pid;
40 } workload;
1b85337d 41 struct fdarray pollfd;
a5830532
JO
42 struct mmap *mmap;
43 struct mmap *overwrite_mmap;
32dcd021 44 struct evsel *selected;
75be989a 45 struct events_stats stats;
2c07144d 46 struct perf_env *env;
63503dba 47 void (*trace_event_sample_raw)(struct evlist *evlist,
93115d32
TR
48 union perf_event *event,
49 struct perf_sample *sample);
6011518d
JY
50 u64 first_sample_time;
51 u64 last_sample_time;
657ee553
SL
52 struct {
53 pthread_t th;
54 volatile int done;
55 } thread;
361c99a6
ACM
56};
57
32dcd021 58struct evsel_str_handler {
ee29be62
ACM
59 const char *name;
60 void *handler;
61};
62
0f98b11c 63struct evlist *evlist__new(void);
63503dba
JO
64struct evlist *perf_evlist__new_default(void);
65struct evlist *perf_evlist__new_dummy(void);
52c86bca
JO
66void evlist__init(struct evlist *evlist, struct perf_cpu_map *cpus,
67 struct perf_thread_map *threads);
63503dba 68void perf_evlist__exit(struct evlist *evlist);
c12995a5 69void evlist__delete(struct evlist *evlist);
361c99a6 70
a1cf3a75 71void evlist__add(struct evlist *evlist, struct evsel *entry);
16251027 72void evlist__remove(struct evlist *evlist, struct evsel *evsel);
db918acb 73
63503dba 74int __perf_evlist__add_default(struct evlist *evlist, bool precise);
db918acb 75
63503dba 76static inline int perf_evlist__add_default(struct evlist *evlist)
db918acb
ACM
77{
78 return __perf_evlist__add_default(evlist, true);
79}
80
63503dba 81int __perf_evlist__add_default_attrs(struct evlist *evlist,
79695e1b 82 struct perf_event_attr *attrs, size_t nr_attrs);
e60fc847 83
79695e1b
ACM
84#define perf_evlist__add_default_attrs(evlist, array) \
85 __perf_evlist__add_default_attrs(evlist, array, ARRAY_SIZE(array))
361c99a6 86
63503dba 87int perf_evlist__add_dummy(struct evlist *evlist);
5bae0250 88
63503dba 89int perf_evlist__add_sb_event(struct evlist **evlist,
657ee553
SL
90 struct perf_event_attr *attr,
91 perf_evsel__sb_cb_t cb,
92 void *data);
63503dba 93int perf_evlist__start_sb_thread(struct evlist *evlist,
657ee553 94 struct target *target);
63503dba 95void perf_evlist__stop_sb_thread(struct evlist *evlist);
657ee553 96
63503dba 97int perf_evlist__add_newtp(struct evlist *evlist,
39876e7d
ACM
98 const char *sys, const char *name, void *handler);
99
63503dba 100void __perf_evlist__set_sample_bit(struct evlist *evlist,
22c8a376 101 enum perf_event_sample_format bit);
63503dba 102void __perf_evlist__reset_sample_bit(struct evlist *evlist,
22c8a376
ACM
103 enum perf_event_sample_format bit);
104
105#define perf_evlist__set_sample_bit(evlist, bit) \
106 __perf_evlist__set_sample_bit(evlist, PERF_SAMPLE_##bit)
107
108#define perf_evlist__reset_sample_bit(evlist, bit) \
109 __perf_evlist__reset_sample_bit(evlist, PERF_SAMPLE_##bit)
110
63503dba
JO
111int perf_evlist__set_tp_filter(struct evlist *evlist, const char *filter);
112int perf_evlist__set_tp_filter_pid(struct evlist *evlist, pid_t pid);
113int perf_evlist__set_tp_filter_pids(struct evlist *evlist, size_t npids, pid_t *pids);
745cefc5 114
32dcd021 115struct evsel *
63503dba 116perf_evlist__find_tracepoint_by_id(struct evlist *evlist, int id);
da378962 117
32dcd021 118struct evsel *
63503dba 119perf_evlist__find_tracepoint_by_name(struct evlist *evlist,
a2f2804a
DA
120 const char *name);
121
63503dba 122void perf_evlist__id_add(struct evlist *evlist, struct evsel *evsel,
a91e5431 123 int cpu, int thread, u64 id);
63503dba 124int perf_evlist__id_add_fd(struct evlist *evlist,
32dcd021 125 struct evsel *evsel,
1c59612d 126 int cpu, int thread, int fd);
3d3b5e95 127
63503dba
JO
128int perf_evlist__add_pollfd(struct evlist *evlist, int fd);
129int perf_evlist__alloc_pollfd(struct evlist *evlist);
130int perf_evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask);
1ddec7f0 131
63503dba 132int perf_evlist__poll(struct evlist *evlist, int timeout);
f66a889d 133
63503dba
JO
134struct evsel *perf_evlist__id2evsel(struct evlist *evlist, u64 id);
135struct evsel *perf_evlist__id2evsel_strict(struct evlist *evlist,
dddcf6ab 136 u64 id);
70db7533 137
63503dba 138struct perf_sample_id *perf_evlist__id2sid(struct evlist *evlist, u64 id);
932a3594 139
63503dba 140void perf_evlist__toggle_bkw_mmap(struct evlist *evlist, enum bkw_mmap_state state);
54cc54de 141
63503dba 142void perf_evlist__mmap_consume(struct evlist *evlist, int idx);
8e50d384 143
474ddc4c 144int evlist__open(struct evlist *evlist);
750b4ede 145void evlist__close(struct evlist *evlist);
727ab04e 146
e68ae9cf
ACM
147struct callchain_param;
148
63503dba 149void perf_evlist__set_id_pos(struct evlist *evlist);
75562573 150bool perf_can_sample_identifier(void);
b757bb09 151bool perf_can_record_switch_events(void);
83509565 152bool perf_can_record_cpu_wide(void);
63503dba 153void perf_evlist__config(struct evlist *evlist, struct record_opts *opts,
e68ae9cf 154 struct callchain_param *callchain);
b4006796 155int record_opts__config(struct record_opts *opts);
0f82ebc4 156
63503dba 157int perf_evlist__prepare_workload(struct evlist *evlist,
602ad878 158 struct target *target,
55e162ea 159 const char *argv[], bool pipe_output,
735f7e0b
ACM
160 void (*exec_error)(int signo, siginfo_t *info,
161 void *ucontext));
63503dba 162int perf_evlist__start_workload(struct evlist *evlist);
35b9d88e 163
724ce97e
ACM
164struct option;
165
e9db1310 166int __perf_evlist__parse_mmap_pages(unsigned int *mmap_pages, const char *str);
994a1f78
JO
167int perf_evlist__parse_mmap_pages(const struct option *opt,
168 const char *str,
169 int unset);
170
f5e7150c
ACM
171unsigned long perf_event_mlock_kb_in_pages(void);
172
63503dba 173int perf_evlist__mmap_ex(struct evlist *evlist, unsigned int pages,
7a276ff6 174 unsigned int auxtrace_pages,
470530bb 175 bool auxtrace_overwrite, int nr_cblocks,
51255a8a 176 int affinity, int flush, int comp_level);
63503dba
JO
177int perf_evlist__mmap(struct evlist *evlist, unsigned int pages);
178void perf_evlist__munmap(struct evlist *evlist);
7e2ed097 179
0c582449
JO
180size_t perf_evlist__mmap_size(unsigned long pages);
181
e74676de 182void evlist__disable(struct evlist *evlist);
1c87f165 183void evlist__enable(struct evlist *evlist);
63503dba 184void perf_evlist__toggle_enable(struct evlist *evlist);
4152ab37 185
63503dba 186int perf_evlist__enable_event_idx(struct evlist *evlist,
32dcd021 187 struct evsel *evsel, int idx);
395c3070 188
63503dba 189void perf_evlist__set_selected(struct evlist *evlist,
32dcd021 190 struct evsel *evsel);
81cce8de 191
63503dba
JO
192int perf_evlist__create_maps(struct evlist *evlist, struct target *target);
193int perf_evlist__apply_filters(struct evlist *evlist, struct evsel **err_evsel);
f8a95309 194
63dab225 195void __perf_evlist__set_leader(struct list_head *list);
63503dba 196void perf_evlist__set_leader(struct evlist *evlist);
63dab225 197
63503dba
JO
198u64 perf_evlist__read_format(struct evlist *evlist);
199u64 __perf_evlist__combined_sample_type(struct evlist *evlist);
200u64 perf_evlist__combined_sample_type(struct evlist *evlist);
201u64 perf_evlist__combined_branch_type(struct evlist *evlist);
202bool perf_evlist__sample_id_all(struct evlist *evlist);
203u16 perf_evlist__id_hdr_size(struct evlist *evlist);
74429964 204
63503dba 205int perf_evlist__parse_sample(struct evlist *evlist, union perf_event *event,
0807d2d8 206 struct perf_sample *sample);
cb0b29e0 207
63503dba 208int perf_evlist__parse_sample_timestamp(struct evlist *evlist,
01468120
JO
209 union perf_event *event,
210 u64 *timestamp);
211
63503dba
JO
212bool perf_evlist__valid_sample_type(struct evlist *evlist);
213bool perf_evlist__valid_sample_id_all(struct evlist *evlist);
214bool perf_evlist__valid_read_format(struct evlist *evlist);
0529bc1f 215
63503dba 216void perf_evlist__splice_list_tail(struct evlist *evlist,
f114d6ef 217 struct list_head *list);
0c21f736 218
63503dba 219static inline bool perf_evlist__empty(struct evlist *evlist)
64831a21 220{
ce9036a6 221 return list_empty(&evlist->core.entries);
64831a21
DCC
222}
223
63503dba 224static inline struct evsel *perf_evlist__first(struct evlist *evlist)
0c21f736 225{
ce9036a6 226 return list_entry(evlist->core.entries.next, struct evsel, core.node);
0c21f736
ACM
227}
228
63503dba 229static inline struct evsel *perf_evlist__last(struct evlist *evlist)
0c21f736 230{
ce9036a6 231 return list_entry(evlist->core.entries.prev, struct evsel, core.node);
0c21f736 232}
78f067b3 233
63503dba 234size_t perf_evlist__fprintf(struct evlist *evlist, FILE *fp);
0479b8b9 235
63503dba
JO
236int perf_evlist__strerror_open(struct evlist *evlist, int err, char *buf, size_t size);
237int perf_evlist__strerror_mmap(struct evlist *evlist, int err, char *buf, size_t size);
6ef068cb 238
63503dba
JO
239bool perf_evlist__can_select_event(struct evlist *evlist, const char *str);
240void perf_evlist__to_front(struct evlist *evlist,
32dcd021 241 struct evsel *move_evsel);
a025e4f0 242
0050f7aa 243/**
e5cadb93 244 * __evlist__for_each_entry - iterate thru all the evsels
0050f7aa
ACM
245 * @list: list_head instance to iterate
246 * @evsel: struct evsel iterator
247 */
e5cadb93 248#define __evlist__for_each_entry(list, evsel) \
b27c4ece 249 list_for_each_entry(evsel, list, core.node)
0050f7aa
ACM
250
251/**
e5cadb93 252 * evlist__for_each_entry - iterate thru all the evsels
0050f7aa
ACM
253 * @evlist: evlist instance to iterate
254 * @evsel: struct evsel iterator
255 */
e5cadb93 256#define evlist__for_each_entry(evlist, evsel) \
ce9036a6 257 __evlist__for_each_entry(&(evlist)->core.entries, evsel)
0050f7aa
ACM
258
259/**
e5cadb93 260 * __evlist__for_each_entry_continue - continue iteration thru all the evsels
0050f7aa
ACM
261 * @list: list_head instance to iterate
262 * @evsel: struct evsel iterator
263 */
e5cadb93 264#define __evlist__for_each_entry_continue(list, evsel) \
b27c4ece 265 list_for_each_entry_continue(evsel, list, core.node)
0050f7aa
ACM
266
267/**
e5cadb93 268 * evlist__for_each_entry_continue - continue iteration thru all the evsels
0050f7aa
ACM
269 * @evlist: evlist instance to iterate
270 * @evsel: struct evsel iterator
271 */
e5cadb93 272#define evlist__for_each_entry_continue(evlist, evsel) \
ce9036a6 273 __evlist__for_each_entry_continue(&(evlist)->core.entries, evsel)
0050f7aa
ACM
274
275/**
e5cadb93 276 * __evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order
0050f7aa
ACM
277 * @list: list_head instance to iterate
278 * @evsel: struct evsel iterator
279 */
e5cadb93 280#define __evlist__for_each_entry_reverse(list, evsel) \
b27c4ece 281 list_for_each_entry_reverse(evsel, list, core.node)
0050f7aa
ACM
282
283/**
e5cadb93 284 * evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order
0050f7aa
ACM
285 * @evlist: evlist instance to iterate
286 * @evsel: struct evsel iterator
287 */
e5cadb93 288#define evlist__for_each_entry_reverse(evlist, evsel) \
ce9036a6 289 __evlist__for_each_entry_reverse(&(evlist)->core.entries, evsel)
0050f7aa
ACM
290
291/**
e5cadb93 292 * __evlist__for_each_entry_safe - safely iterate thru all the evsels
0050f7aa
ACM
293 * @list: list_head instance to iterate
294 * @tmp: struct evsel temp iterator
295 * @evsel: struct evsel iterator
296 */
e5cadb93 297#define __evlist__for_each_entry_safe(list, tmp, evsel) \
b27c4ece 298 list_for_each_entry_safe(evsel, tmp, list, core.node)
0050f7aa
ACM
299
300/**
e5cadb93 301 * evlist__for_each_entry_safe - safely iterate thru all the evsels
0050f7aa
ACM
302 * @evlist: evlist instance to iterate
303 * @evsel: struct evsel iterator
304 * @tmp: struct evsel temp iterator
305 */
e5cadb93 306#define evlist__for_each_entry_safe(evlist, tmp, evsel) \
ce9036a6 307 __evlist__for_each_entry_safe(&(evlist)->core.entries, tmp, evsel)
c09ec622 308
63503dba 309void perf_evlist__set_tracking_event(struct evlist *evlist,
32dcd021 310 struct evsel *tracking_evsel);
45cf6c33 311
32dcd021 312struct evsel *
63503dba 313perf_evlist__find_evsel_by_str(struct evlist *evlist, const char *str);
7cb5c5ac 314
63503dba 315struct evsel *perf_evlist__event2evsel(struct evlist *evlist,
7cb5c5ac 316 union perf_event *event);
07d6f446 317
63503dba 318bool perf_evlist__exclude_kernel(struct evlist *evlist);
e2bdbe80 319
63503dba 320void perf_evlist__force_leader(struct evlist *evlist);
e2bdbe80 321
63503dba 322struct evsel *perf_evlist__reset_weak_group(struct evlist *evlist,
32dcd021 323 struct evsel *evsel);
361c99a6 324#endif /* __PERF_EVLIST_H */