Loading...
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef __PERF_EVLIST_H
3#define __PERF_EVLIST_H 1
4
5#include <linux/compiler.h>
6#include <linux/kernel.h>
7#include <linux/refcount.h>
8#include <linux/list.h>
9#include <api/fd/array.h>
10#include <internal/evlist.h>
11#include <internal/evsel.h>
12#include "events_stats.h"
13#include "evsel.h"
14#include <pthread.h>
15#include <signal.h>
16#include <unistd.h>
17
18struct pollfd;
19struct thread_map;
20struct perf_cpu_map;
21struct record_opts;
22
23/*
24 * State machine of bkw_mmap_state:
25 *
26 * .________________(forbid)_____________.
27 * | V
28 * NOTREADY --(0)--> RUNNING --(1)--> DATA_PENDING --(2)--> EMPTY
29 * ^ ^ | ^ |
30 * | |__(forbid)____/ |___(forbid)___/|
31 * | |
32 * \_________________(3)_______________/
33 *
34 * NOTREADY : Backward ring buffers are not ready
35 * RUNNING : Backward ring buffers are recording
36 * DATA_PENDING : We are required to collect data from backward ring buffers
37 * EMPTY : We have collected data from backward ring buffers.
38 *
39 * (0): Setup backward ring buffer
40 * (1): Pause ring buffers for reading
41 * (2): Read from ring buffers
42 * (3): Resume ring buffers for recording
43 */
44enum bkw_mmap_state {
45 BKW_MMAP_NOTREADY,
46 BKW_MMAP_RUNNING,
47 BKW_MMAP_DATA_PENDING,
48 BKW_MMAP_EMPTY,
49};
50
51struct event_enable_timer;
52
53struct evlist {
54 struct perf_evlist core;
55 bool enabled;
56 int id_pos;
57 int is_pos;
58 u64 combined_sample_type;
59 enum bkw_mmap_state bkw_mmap_state;
60 struct {
61 int cork_fd;
62 pid_t pid;
63 } workload;
64 struct mmap *mmap;
65 struct mmap *overwrite_mmap;
66 struct evsel *selected;
67 struct events_stats stats;
68 struct perf_env *env;
69 const char *hybrid_pmu_name;
70 void (*trace_event_sample_raw)(struct evlist *evlist,
71 union perf_event *event,
72 struct perf_sample *sample);
73 u64 first_sample_time;
74 u64 last_sample_time;
75 struct {
76 pthread_t th;
77 volatile int done;
78 } thread;
79 struct {
80 int fd; /* control file descriptor */
81 int ack; /* ack file descriptor for control commands */
82 int pos; /* index at evlist core object to check signals */
83 } ctl_fd;
84 struct event_enable_timer *eet;
85};
86
87struct evsel_str_handler {
88 const char *name;
89 void *handler;
90};
91
92struct evlist *evlist__new(void);
93struct evlist *evlist__new_default(void);
94struct evlist *evlist__new_dummy(void);
95void evlist__init(struct evlist *evlist, struct perf_cpu_map *cpus,
96 struct perf_thread_map *threads);
97void evlist__exit(struct evlist *evlist);
98void evlist__delete(struct evlist *evlist);
99
100void evlist__add(struct evlist *evlist, struct evsel *entry);
101void evlist__remove(struct evlist *evlist, struct evsel *evsel);
102
103int __evlist__add_default(struct evlist *evlist, bool precise);
104
105static inline int evlist__add_default(struct evlist *evlist)
106{
107 return __evlist__add_default(evlist, true);
108}
109
110int evlist__add_attrs(struct evlist *evlist, struct perf_event_attr *attrs, size_t nr_attrs);
111
112int __evlist__add_default_attrs(struct evlist *evlist,
113 struct perf_event_attr *attrs, size_t nr_attrs);
114
115int arch_evlist__add_default_attrs(struct evlist *evlist,
116 struct perf_event_attr *attrs,
117 size_t nr_attrs);
118
119#define evlist__add_default_attrs(evlist, array) \
120 arch_evlist__add_default_attrs(evlist, array, ARRAY_SIZE(array))
121
122struct evsel *arch_evlist__leader(struct list_head *list);
123
124int evlist__add_dummy(struct evlist *evlist);
125struct evsel *evlist__add_aux_dummy(struct evlist *evlist, bool system_wide);
126static inline struct evsel *evlist__add_dummy_on_all_cpus(struct evlist *evlist)
127{
128 return evlist__add_aux_dummy(evlist, true);
129}
130#ifdef HAVE_LIBTRACEEVENT
131struct evsel *evlist__add_sched_switch(struct evlist *evlist, bool system_wide);
132#endif
133
134int evlist__add_sb_event(struct evlist *evlist, struct perf_event_attr *attr,
135 evsel__sb_cb_t cb, void *data);
136void evlist__set_cb(struct evlist *evlist, evsel__sb_cb_t cb, void *data);
137int evlist__start_sb_thread(struct evlist *evlist, struct target *target);
138void evlist__stop_sb_thread(struct evlist *evlist);
139
140#ifdef HAVE_LIBTRACEEVENT
141int evlist__add_newtp(struct evlist *evlist, const char *sys, const char *name, void *handler);
142#endif
143
144int __evlist__set_tracepoints_handlers(struct evlist *evlist,
145 const struct evsel_str_handler *assocs,
146 size_t nr_assocs);
147
148#define evlist__set_tracepoints_handlers(evlist, array) \
149 __evlist__set_tracepoints_handlers(evlist, array, ARRAY_SIZE(array))
150
151int evlist__set_tp_filter(struct evlist *evlist, const char *filter);
152int evlist__set_tp_filter_pid(struct evlist *evlist, pid_t pid);
153int evlist__set_tp_filter_pids(struct evlist *evlist, size_t npids, pid_t *pids);
154
155int evlist__append_tp_filter(struct evlist *evlist, const char *filter);
156
157int evlist__append_tp_filter_pid(struct evlist *evlist, pid_t pid);
158int evlist__append_tp_filter_pids(struct evlist *evlist, size_t npids, pid_t *pids);
159
160struct evsel *evlist__find_tracepoint_by_id(struct evlist *evlist, int id);
161struct evsel *evlist__find_tracepoint_by_name(struct evlist *evlist, const char *name);
162
163int evlist__add_pollfd(struct evlist *evlist, int fd);
164int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask);
165
166#ifdef HAVE_EVENTFD_SUPPORT
167int evlist__add_wakeup_eventfd(struct evlist *evlist, int fd);
168#endif
169
170int evlist__poll(struct evlist *evlist, int timeout);
171
172struct evsel *evlist__id2evsel(struct evlist *evlist, u64 id);
173struct evsel *evlist__id2evsel_strict(struct evlist *evlist, u64 id);
174
175struct perf_sample_id *evlist__id2sid(struct evlist *evlist, u64 id);
176
177void evlist__toggle_bkw_mmap(struct evlist *evlist, enum bkw_mmap_state state);
178
179void evlist__mmap_consume(struct evlist *evlist, int idx);
180
181int evlist__open(struct evlist *evlist);
182void evlist__close(struct evlist *evlist);
183
184struct callchain_param;
185
186void evlist__set_id_pos(struct evlist *evlist);
187void evlist__config(struct evlist *evlist, struct record_opts *opts, struct callchain_param *callchain);
188int record_opts__config(struct record_opts *opts);
189
190int evlist__prepare_workload(struct evlist *evlist, struct target *target,
191 const char *argv[], bool pipe_output,
192 void (*exec_error)(int signo, siginfo_t *info, void *ucontext));
193int evlist__start_workload(struct evlist *evlist);
194
195struct option;
196
197int __evlist__parse_mmap_pages(unsigned int *mmap_pages, const char *str);
198int evlist__parse_mmap_pages(const struct option *opt, const char *str, int unset);
199
200unsigned long perf_event_mlock_kb_in_pages(void);
201
202int evlist__mmap_ex(struct evlist *evlist, unsigned int pages,
203 unsigned int auxtrace_pages,
204 bool auxtrace_overwrite, int nr_cblocks,
205 int affinity, int flush, int comp_level);
206int evlist__mmap(struct evlist *evlist, unsigned int pages);
207void evlist__munmap(struct evlist *evlist);
208
209size_t evlist__mmap_size(unsigned long pages);
210
211void evlist__disable(struct evlist *evlist);
212void evlist__enable(struct evlist *evlist);
213void evlist__toggle_enable(struct evlist *evlist);
214void evlist__disable_evsel(struct evlist *evlist, char *evsel_name);
215void evlist__enable_evsel(struct evlist *evlist, char *evsel_name);
216void evlist__disable_non_dummy(struct evlist *evlist);
217void evlist__enable_non_dummy(struct evlist *evlist);
218
219void evlist__set_selected(struct evlist *evlist, struct evsel *evsel);
220
221int evlist__create_maps(struct evlist *evlist, struct target *target);
222int evlist__apply_filters(struct evlist *evlist, struct evsel **err_evsel);
223
224u64 __evlist__combined_sample_type(struct evlist *evlist);
225u64 evlist__combined_sample_type(struct evlist *evlist);
226u64 evlist__combined_branch_type(struct evlist *evlist);
227bool evlist__sample_id_all(struct evlist *evlist);
228u16 evlist__id_hdr_size(struct evlist *evlist);
229
230int evlist__parse_sample(struct evlist *evlist, union perf_event *event, struct perf_sample *sample);
231int evlist__parse_sample_timestamp(struct evlist *evlist, union perf_event *event, u64 *timestamp);
232
233bool evlist__valid_sample_type(struct evlist *evlist);
234bool evlist__valid_sample_id_all(struct evlist *evlist);
235bool evlist__valid_read_format(struct evlist *evlist);
236
237void evlist__splice_list_tail(struct evlist *evlist, struct list_head *list);
238
239static inline bool evlist__empty(struct evlist *evlist)
240{
241 return list_empty(&evlist->core.entries);
242}
243
244static inline struct evsel *evlist__first(struct evlist *evlist)
245{
246 struct perf_evsel *evsel = perf_evlist__first(&evlist->core);
247
248 return container_of(evsel, struct evsel, core);
249}
250
251static inline struct evsel *evlist__last(struct evlist *evlist)
252{
253 struct perf_evsel *evsel = perf_evlist__last(&evlist->core);
254
255 return container_of(evsel, struct evsel, core);
256}
257
258int evlist__strerror_open(struct evlist *evlist, int err, char *buf, size_t size);
259int evlist__strerror_mmap(struct evlist *evlist, int err, char *buf, size_t size);
260
261bool evlist__can_select_event(struct evlist *evlist, const char *str);
262void evlist__to_front(struct evlist *evlist, struct evsel *move_evsel);
263
264/**
265 * __evlist__for_each_entry - iterate thru all the evsels
266 * @list: list_head instance to iterate
267 * @evsel: struct evsel iterator
268 */
269#define __evlist__for_each_entry(list, evsel) \
270 list_for_each_entry(evsel, list, core.node)
271
272/**
273 * evlist__for_each_entry - iterate thru all the evsels
274 * @evlist: evlist instance to iterate
275 * @evsel: struct evsel iterator
276 */
277#define evlist__for_each_entry(evlist, evsel) \
278 __evlist__for_each_entry(&(evlist)->core.entries, evsel)
279
280/**
281 * __evlist__for_each_entry_continue - continue iteration thru all the evsels
282 * @list: list_head instance to iterate
283 * @evsel: struct evsel iterator
284 */
285#define __evlist__for_each_entry_continue(list, evsel) \
286 list_for_each_entry_continue(evsel, list, core.node)
287
288/**
289 * evlist__for_each_entry_continue - continue iteration thru all the evsels
290 * @evlist: evlist instance to iterate
291 * @evsel: struct evsel iterator
292 */
293#define evlist__for_each_entry_continue(evlist, evsel) \
294 __evlist__for_each_entry_continue(&(evlist)->core.entries, evsel)
295
296/**
297 * __evlist__for_each_entry_from - continue iteration from @evsel (included)
298 * @list: list_head instance to iterate
299 * @evsel: struct evsel iterator
300 */
301#define __evlist__for_each_entry_from(list, evsel) \
302 list_for_each_entry_from(evsel, list, core.node)
303
304/**
305 * evlist__for_each_entry_from - continue iteration from @evsel (included)
306 * @evlist: evlist instance to iterate
307 * @evsel: struct evsel iterator
308 */
309#define evlist__for_each_entry_from(evlist, evsel) \
310 __evlist__for_each_entry_from(&(evlist)->core.entries, evsel)
311
312/**
313 * __evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order
314 * @list: list_head instance to iterate
315 * @evsel: struct evsel iterator
316 */
317#define __evlist__for_each_entry_reverse(list, evsel) \
318 list_for_each_entry_reverse(evsel, list, core.node)
319
320/**
321 * evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order
322 * @evlist: evlist instance to iterate
323 * @evsel: struct evsel iterator
324 */
325#define evlist__for_each_entry_reverse(evlist, evsel) \
326 __evlist__for_each_entry_reverse(&(evlist)->core.entries, evsel)
327
328/**
329 * __evlist__for_each_entry_safe - safely iterate thru all the evsels
330 * @list: list_head instance to iterate
331 * @tmp: struct evsel temp iterator
332 * @evsel: struct evsel iterator
333 */
334#define __evlist__for_each_entry_safe(list, tmp, evsel) \
335 list_for_each_entry_safe(evsel, tmp, list, core.node)
336
337/**
338 * evlist__for_each_entry_safe - safely iterate thru all the evsels
339 * @evlist: evlist instance to iterate
340 * @evsel: struct evsel iterator
341 * @tmp: struct evsel temp iterator
342 */
343#define evlist__for_each_entry_safe(evlist, tmp, evsel) \
344 __evlist__for_each_entry_safe(&(evlist)->core.entries, tmp, evsel)
345
346/** Iterator state for evlist__for_each_cpu */
347struct evlist_cpu_iterator {
348 /** The list being iterated through. */
349 struct evlist *container;
350 /** The current evsel of the iterator. */
351 struct evsel *evsel;
352 /** The CPU map index corresponding to the evsel->core.cpus for the current CPU. */
353 int cpu_map_idx;
354 /**
355 * The CPU map index corresponding to evlist->core.all_cpus for the
356 * current CPU. Distinct from cpu_map_idx as the evsel's cpu map may
357 * contain fewer entries.
358 */
359 int evlist_cpu_map_idx;
360 /** The number of CPU map entries in evlist->core.all_cpus. */
361 int evlist_cpu_map_nr;
362 /** The current CPU of the iterator. */
363 struct perf_cpu cpu;
364 /** If present, used to set the affinity when switching between CPUs. */
365 struct affinity *affinity;
366};
367
368/**
369 * evlist__for_each_cpu - without affinity, iterate over the evlist. With
370 * affinity, iterate over all CPUs and then the evlist
371 * for each evsel on that CPU. When switching between
372 * CPUs the affinity is set to the CPU to avoid IPIs
373 * during syscalls.
374 * @evlist_cpu_itr: the iterator instance.
375 * @evlist: evlist instance to iterate.
376 * @affinity: NULL or used to set the affinity to the current CPU.
377 */
378#define evlist__for_each_cpu(evlist_cpu_itr, evlist, affinity) \
379 for ((evlist_cpu_itr) = evlist__cpu_begin(evlist, affinity); \
380 !evlist_cpu_iterator__end(&evlist_cpu_itr); \
381 evlist_cpu_iterator__next(&evlist_cpu_itr))
382
383/** Returns an iterator set to the first CPU/evsel of evlist. */
384struct evlist_cpu_iterator evlist__cpu_begin(struct evlist *evlist, struct affinity *affinity);
385/** Move to next element in iterator, updating CPU, evsel and the affinity. */
386void evlist_cpu_iterator__next(struct evlist_cpu_iterator *evlist_cpu_itr);
387/** Returns true when iterator is at the end of the CPUs and evlist. */
388bool evlist_cpu_iterator__end(const struct evlist_cpu_iterator *evlist_cpu_itr);
389
390struct evsel *evlist__get_tracking_event(struct evlist *evlist);
391void evlist__set_tracking_event(struct evlist *evlist, struct evsel *tracking_evsel);
392
393struct evsel *evlist__find_evsel_by_str(struct evlist *evlist, const char *str);
394
395struct evsel *evlist__event2evsel(struct evlist *evlist, union perf_event *event);
396
397bool evlist__exclude_kernel(struct evlist *evlist);
398
399void evlist__force_leader(struct evlist *evlist);
400
401struct evsel *evlist__reset_weak_group(struct evlist *evlist, struct evsel *evsel, bool close);
402
403#define EVLIST_CTL_CMD_ENABLE_TAG "enable"
404#define EVLIST_CTL_CMD_DISABLE_TAG "disable"
405#define EVLIST_CTL_CMD_ACK_TAG "ack\n"
406#define EVLIST_CTL_CMD_SNAPSHOT_TAG "snapshot"
407#define EVLIST_CTL_CMD_EVLIST_TAG "evlist"
408#define EVLIST_CTL_CMD_STOP_TAG "stop"
409#define EVLIST_CTL_CMD_PING_TAG "ping"
410
411#define EVLIST_CTL_CMD_MAX_LEN 64
412
413enum evlist_ctl_cmd {
414 EVLIST_CTL_CMD_UNSUPPORTED = 0,
415 EVLIST_CTL_CMD_ENABLE,
416 EVLIST_CTL_CMD_DISABLE,
417 EVLIST_CTL_CMD_ACK,
418 EVLIST_CTL_CMD_SNAPSHOT,
419 EVLIST_CTL_CMD_EVLIST,
420 EVLIST_CTL_CMD_STOP,
421 EVLIST_CTL_CMD_PING,
422};
423
424int evlist__parse_control(const char *str, int *ctl_fd, int *ctl_fd_ack, bool *ctl_fd_close);
425void evlist__close_control(int ctl_fd, int ctl_fd_ack, bool *ctl_fd_close);
426int evlist__initialize_ctlfd(struct evlist *evlist, int ctl_fd, int ctl_fd_ack);
427int evlist__finalize_ctlfd(struct evlist *evlist);
428bool evlist__ctlfd_initialized(struct evlist *evlist);
429int evlist__ctlfd_process(struct evlist *evlist, enum evlist_ctl_cmd *cmd);
430int evlist__ctlfd_ack(struct evlist *evlist);
431
432#define EVLIST_ENABLED_MSG "Events enabled\n"
433#define EVLIST_DISABLED_MSG "Events disabled\n"
434
435int evlist__parse_event_enable_time(struct evlist *evlist, struct record_opts *opts,
436 const char *str, int unset);
437int event_enable_timer__start(struct event_enable_timer *eet);
438void event_enable_timer__exit(struct event_enable_timer **ep);
439int event_enable_timer__process(struct event_enable_timer *eet);
440
441struct evsel *evlist__find_evsel(struct evlist *evlist, int idx);
442
443int evlist__scnprintf_evsels(struct evlist *evlist, size_t size, char *bf);
444void evlist__check_mem_load_aux(struct evlist *evlist);
445#endif /* __PERF_EVLIST_H */
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef __PERF_EVLIST_H
3#define __PERF_EVLIST_H 1
4
5#include <linux/compiler.h>
6#include <linux/kernel.h>
7#include <linux/refcount.h>
8#include <linux/list.h>
9#include <api/fd/array.h>
10#include <internal/evlist.h>
11#include <internal/evsel.h>
12#include "events_stats.h"
13#include "evsel.h"
14#include <pthread.h>
15#include <signal.h>
16#include <unistd.h>
17
18struct pollfd;
19struct thread_map;
20struct perf_cpu_map;
21struct record_opts;
22
23/*
24 * State machine of bkw_mmap_state:
25 *
26 * .________________(forbid)_____________.
27 * | V
28 * NOTREADY --(0)--> RUNNING --(1)--> DATA_PENDING --(2)--> EMPTY
29 * ^ ^ | ^ |
30 * | |__(forbid)____/ |___(forbid)___/|
31 * | |
32 * \_________________(3)_______________/
33 *
34 * NOTREADY : Backward ring buffers are not ready
35 * RUNNING : Backward ring buffers are recording
36 * DATA_PENDING : We are required to collect data from backward ring buffers
37 * EMPTY : We have collected data from backward ring buffers.
38 *
39 * (0): Setup backward ring buffer
40 * (1): Pause ring buffers for reading
41 * (2): Read from ring buffers
42 * (3): Resume ring buffers for recording
43 */
44enum bkw_mmap_state {
45 BKW_MMAP_NOTREADY,
46 BKW_MMAP_RUNNING,
47 BKW_MMAP_DATA_PENDING,
48 BKW_MMAP_EMPTY,
49};
50
51struct evlist {
52 struct perf_evlist core;
53 int nr_groups;
54 bool enabled;
55 int id_pos;
56 int is_pos;
57 u64 combined_sample_type;
58 enum bkw_mmap_state bkw_mmap_state;
59 struct {
60 int cork_fd;
61 pid_t pid;
62 } workload;
63 struct mmap *mmap;
64 struct mmap *overwrite_mmap;
65 struct evsel *selected;
66 struct events_stats stats;
67 struct perf_env *env;
68 void (*trace_event_sample_raw)(struct evlist *evlist,
69 union perf_event *event,
70 struct perf_sample *sample);
71 u64 first_sample_time;
72 u64 last_sample_time;
73 struct {
74 pthread_t th;
75 volatile int done;
76 } thread;
77};
78
79struct evsel_str_handler {
80 const char *name;
81 void *handler;
82};
83
84struct evlist *evlist__new(void);
85struct evlist *perf_evlist__new_default(void);
86struct evlist *perf_evlist__new_dummy(void);
87void evlist__init(struct evlist *evlist, struct perf_cpu_map *cpus,
88 struct perf_thread_map *threads);
89void evlist__exit(struct evlist *evlist);
90void evlist__delete(struct evlist *evlist);
91
92void evlist__add(struct evlist *evlist, struct evsel *entry);
93void evlist__remove(struct evlist *evlist, struct evsel *evsel);
94
95int __perf_evlist__add_default(struct evlist *evlist, bool precise);
96
97static inline int perf_evlist__add_default(struct evlist *evlist)
98{
99 return __perf_evlist__add_default(evlist, true);
100}
101
102int __perf_evlist__add_default_attrs(struct evlist *evlist,
103 struct perf_event_attr *attrs, size_t nr_attrs);
104
105#define perf_evlist__add_default_attrs(evlist, array) \
106 __perf_evlist__add_default_attrs(evlist, array, ARRAY_SIZE(array))
107
108int perf_evlist__add_dummy(struct evlist *evlist);
109
110int perf_evlist__add_sb_event(struct evlist **evlist,
111 struct perf_event_attr *attr,
112 perf_evsel__sb_cb_t cb,
113 void *data);
114int perf_evlist__start_sb_thread(struct evlist *evlist,
115 struct target *target);
116void perf_evlist__stop_sb_thread(struct evlist *evlist);
117
118int perf_evlist__add_newtp(struct evlist *evlist,
119 const char *sys, const char *name, void *handler);
120
121void __perf_evlist__set_sample_bit(struct evlist *evlist,
122 enum perf_event_sample_format bit);
123void __perf_evlist__reset_sample_bit(struct evlist *evlist,
124 enum perf_event_sample_format bit);
125
126#define perf_evlist__set_sample_bit(evlist, bit) \
127 __perf_evlist__set_sample_bit(evlist, PERF_SAMPLE_##bit)
128
129#define perf_evlist__reset_sample_bit(evlist, bit) \
130 __perf_evlist__reset_sample_bit(evlist, PERF_SAMPLE_##bit)
131
132int perf_evlist__set_tp_filter(struct evlist *evlist, const char *filter);
133int perf_evlist__set_tp_filter_pid(struct evlist *evlist, pid_t pid);
134int perf_evlist__set_tp_filter_pids(struct evlist *evlist, size_t npids, pid_t *pids);
135
136struct evsel *
137perf_evlist__find_tracepoint_by_id(struct evlist *evlist, int id);
138
139struct evsel *
140perf_evlist__find_tracepoint_by_name(struct evlist *evlist,
141 const char *name);
142
143int evlist__add_pollfd(struct evlist *evlist, int fd);
144int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask);
145
146int evlist__poll(struct evlist *evlist, int timeout);
147
148struct evsel *perf_evlist__id2evsel(struct evlist *evlist, u64 id);
149struct evsel *perf_evlist__id2evsel_strict(struct evlist *evlist,
150 u64 id);
151
152struct perf_sample_id *perf_evlist__id2sid(struct evlist *evlist, u64 id);
153
154void perf_evlist__toggle_bkw_mmap(struct evlist *evlist, enum bkw_mmap_state state);
155
156void evlist__mmap_consume(struct evlist *evlist, int idx);
157
158int evlist__open(struct evlist *evlist);
159void evlist__close(struct evlist *evlist);
160
161struct callchain_param;
162
163void perf_evlist__set_id_pos(struct evlist *evlist);
164bool perf_can_sample_identifier(void);
165bool perf_can_record_switch_events(void);
166bool perf_can_record_cpu_wide(void);
167void perf_evlist__config(struct evlist *evlist, struct record_opts *opts,
168 struct callchain_param *callchain);
169int record_opts__config(struct record_opts *opts);
170
171int perf_evlist__prepare_workload(struct evlist *evlist,
172 struct target *target,
173 const char *argv[], bool pipe_output,
174 void (*exec_error)(int signo, siginfo_t *info,
175 void *ucontext));
176int perf_evlist__start_workload(struct evlist *evlist);
177
178struct option;
179
180int __perf_evlist__parse_mmap_pages(unsigned int *mmap_pages, const char *str);
181int perf_evlist__parse_mmap_pages(const struct option *opt,
182 const char *str,
183 int unset);
184
185unsigned long perf_event_mlock_kb_in_pages(void);
186
187int evlist__mmap_ex(struct evlist *evlist, unsigned int pages,
188 unsigned int auxtrace_pages,
189 bool auxtrace_overwrite, int nr_cblocks,
190 int affinity, int flush, int comp_level);
191int evlist__mmap(struct evlist *evlist, unsigned int pages);
192void evlist__munmap(struct evlist *evlist);
193
194size_t evlist__mmap_size(unsigned long pages);
195
196void evlist__disable(struct evlist *evlist);
197void evlist__enable(struct evlist *evlist);
198void perf_evlist__toggle_enable(struct evlist *evlist);
199
200int perf_evlist__enable_event_idx(struct evlist *evlist,
201 struct evsel *evsel, int idx);
202
203void perf_evlist__set_selected(struct evlist *evlist,
204 struct evsel *evsel);
205
206int perf_evlist__create_maps(struct evlist *evlist, struct target *target);
207int perf_evlist__apply_filters(struct evlist *evlist, struct evsel **err_evsel);
208
209void __perf_evlist__set_leader(struct list_head *list);
210void perf_evlist__set_leader(struct evlist *evlist);
211
212u64 __perf_evlist__combined_sample_type(struct evlist *evlist);
213u64 perf_evlist__combined_sample_type(struct evlist *evlist);
214u64 perf_evlist__combined_branch_type(struct evlist *evlist);
215bool perf_evlist__sample_id_all(struct evlist *evlist);
216u16 perf_evlist__id_hdr_size(struct evlist *evlist);
217
218int perf_evlist__parse_sample(struct evlist *evlist, union perf_event *event,
219 struct perf_sample *sample);
220
221int perf_evlist__parse_sample_timestamp(struct evlist *evlist,
222 union perf_event *event,
223 u64 *timestamp);
224
225bool perf_evlist__valid_sample_type(struct evlist *evlist);
226bool perf_evlist__valid_sample_id_all(struct evlist *evlist);
227bool perf_evlist__valid_read_format(struct evlist *evlist);
228
229void perf_evlist__splice_list_tail(struct evlist *evlist,
230 struct list_head *list);
231
232static inline bool perf_evlist__empty(struct evlist *evlist)
233{
234 return list_empty(&evlist->core.entries);
235}
236
237static inline struct evsel *evlist__first(struct evlist *evlist)
238{
239 struct perf_evsel *evsel = perf_evlist__first(&evlist->core);
240
241 return container_of(evsel, struct evsel, core);
242}
243
244static inline struct evsel *evlist__last(struct evlist *evlist)
245{
246 struct perf_evsel *evsel = perf_evlist__last(&evlist->core);
247
248 return container_of(evsel, struct evsel, core);
249}
250
251int perf_evlist__strerror_open(struct evlist *evlist, int err, char *buf, size_t size);
252int perf_evlist__strerror_mmap(struct evlist *evlist, int err, char *buf, size_t size);
253
254bool perf_evlist__can_select_event(struct evlist *evlist, const char *str);
255void perf_evlist__to_front(struct evlist *evlist,
256 struct evsel *move_evsel);
257
258/**
259 * __evlist__for_each_entry - iterate thru all the evsels
260 * @list: list_head instance to iterate
261 * @evsel: struct evsel iterator
262 */
263#define __evlist__for_each_entry(list, evsel) \
264 list_for_each_entry(evsel, list, core.node)
265
266/**
267 * evlist__for_each_entry - iterate thru all the evsels
268 * @evlist: evlist instance to iterate
269 * @evsel: struct evsel iterator
270 */
271#define evlist__for_each_entry(evlist, evsel) \
272 __evlist__for_each_entry(&(evlist)->core.entries, evsel)
273
274/**
275 * __evlist__for_each_entry_continue - continue iteration thru all the evsels
276 * @list: list_head instance to iterate
277 * @evsel: struct evsel iterator
278 */
279#define __evlist__for_each_entry_continue(list, evsel) \
280 list_for_each_entry_continue(evsel, list, core.node)
281
282/**
283 * evlist__for_each_entry_continue - continue iteration thru all the evsels
284 * @evlist: evlist instance to iterate
285 * @evsel: struct evsel iterator
286 */
287#define evlist__for_each_entry_continue(evlist, evsel) \
288 __evlist__for_each_entry_continue(&(evlist)->core.entries, evsel)
289
290/**
291 * __evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order
292 * @list: list_head instance to iterate
293 * @evsel: struct evsel iterator
294 */
295#define __evlist__for_each_entry_reverse(list, evsel) \
296 list_for_each_entry_reverse(evsel, list, core.node)
297
298/**
299 * evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order
300 * @evlist: evlist instance to iterate
301 * @evsel: struct evsel iterator
302 */
303#define evlist__for_each_entry_reverse(evlist, evsel) \
304 __evlist__for_each_entry_reverse(&(evlist)->core.entries, evsel)
305
306/**
307 * __evlist__for_each_entry_safe - safely iterate thru all the evsels
308 * @list: list_head instance to iterate
309 * @tmp: struct evsel temp iterator
310 * @evsel: struct evsel iterator
311 */
312#define __evlist__for_each_entry_safe(list, tmp, evsel) \
313 list_for_each_entry_safe(evsel, tmp, list, core.node)
314
315/**
316 * evlist__for_each_entry_safe - safely iterate thru all the evsels
317 * @evlist: evlist instance to iterate
318 * @evsel: struct evsel iterator
319 * @tmp: struct evsel temp iterator
320 */
321#define evlist__for_each_entry_safe(evlist, tmp, evsel) \
322 __evlist__for_each_entry_safe(&(evlist)->core.entries, tmp, evsel)
323
324void perf_evlist__set_tracking_event(struct evlist *evlist,
325 struct evsel *tracking_evsel);
326
327struct evsel *
328perf_evlist__find_evsel_by_str(struct evlist *evlist, const char *str);
329
330struct evsel *perf_evlist__event2evsel(struct evlist *evlist,
331 union perf_event *event);
332
333bool perf_evlist__exclude_kernel(struct evlist *evlist);
334
335void perf_evlist__force_leader(struct evlist *evlist);
336
337struct evsel *perf_evlist__reset_weak_group(struct evlist *evlist,
338 struct evsel *evsel);
339#endif /* __PERF_EVLIST_H */