1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __PERF_EVLIST_H 3 #define __PERF_EVLIST_H 1 4 5 #include <signal.h> 6 7 #include <linux/compiler.h> 8 #include <linux/kernel.h> 9 #include <linux/list.h> 10 #include <linux/refcount.h> 11 #include <pthread.h> 12 #include <unistd.h> 13 14 #include <api/fd/array.h> 15 #include <internal/evlist.h> 16 #include <internal/evsel.h> 17 #include <internal/rc_check.h> 18 #include <perf/evlist.h> 19 20 #include "affinity.h" 21 #include "events_stats.h" 22 #include "evsel.h" 23 #include "rblist.h" 24 25 struct perf_cpu_map; 26 struct perf_stat_config; 27 struct pollfd; 28 struct record_opts; 29 struct strbuf; 30 struct target; 31 struct thread_map; 32 33 /* 34 * State machine of bkw_mmap_state: 35 * 36 * .________________(forbid)_____________. 37 * | V 38 * NOTREADY --(0)--> RUNNING --(1)--> DATA_PENDING --(2)--> EMPTY 39 * ^ ^ | ^ | 40 * | |__(forbid)____/ |___(forbid)___/| 41 * | | 42 * \_________________(3)_______________/ 43 * 44 * NOTREADY : Backward ring buffers are not ready 45 * RUNNING : Backward ring buffers are recording 46 * DATA_PENDING : We are required to collect data from backward ring buffers 47 * EMPTY : We have collected data from backward ring buffers. 48 * 49 * (0): Setup backward ring buffer 50 * (1): Pause ring buffers for reading 51 * (2): Read from ring buffers 52 * (3): Resume ring buffers for recording 53 */ 54 enum bkw_mmap_state { 55 BKW_MMAP_NOTREADY, 56 BKW_MMAP_RUNNING, 57 BKW_MMAP_DATA_PENDING, 58 BKW_MMAP_EMPTY, 59 }; 60 61 struct event_enable_timer; 62 63 DECLARE_RC_STRUCT(evlist) { 64 struct perf_evlist core; 65 refcount_t refcnt; 66 bool enabled; 67 bool no_affinity; 68 int id_pos; 69 int is_pos; 70 int nr_br_cntr; 71 u64 combined_sample_type; 72 enum bkw_mmap_state bkw_mmap_state; 73 struct { 74 int cork_fd; 75 pid_t pid; 76 } workload; 77 struct mmap *mmap; 78 struct mmap *overwrite_mmap; 79 struct evsel *selected; 80 struct events_stats stats; 81 struct perf_session *session; 82 void (*trace_event_sample_raw)(struct evlist *evlist, 83 union perf_event *event, 84 struct perf_sample *sample); 85 u64 first_sample_time; 86 u64 last_sample_time; 87 struct { 88 pthread_t th; 89 volatile int done; 90 } sb_thread; 91 struct { 92 int fd; /* control file descriptor */ 93 int ack; /* ack file descriptor for control commands */ 94 int pos; /* index at evlist core object to check signals */ 95 } ctl_fd; 96 struct event_enable_timer *eet; 97 /** 98 * @metric_events: A list of struct metric_event which each have a list 99 * of struct metric_expr. 100 */ 101 struct rblist metric_events; 102 /* samples with deferred_callchain would wait here. */ 103 struct list_head deferred_samples; 104 }; 105 106 struct evsel_str_handler { 107 const char *name; 108 void *handler; 109 }; 110 111 static inline struct perf_evlist *evlist__core(struct evlist *evlist) 112 { 113 return &RC_CHK_ACCESS(evlist)->core; 114 } 115 116 static inline const struct perf_evlist *evlist__const_core(const struct evlist *evlist) 117 { 118 return &RC_CHK_ACCESS(evlist)->core; 119 } 120 121 static inline int evlist__nr_entries(const struct evlist *evlist) 122 { 123 return evlist__const_core(evlist)->nr_entries; 124 } 125 126 static inline bool evlist__enabled(const struct evlist *evlist) 127 { 128 return RC_CHK_ACCESS(evlist)->enabled; 129 } 130 131 static inline void evlist__set_enabled(struct evlist *evlist, bool enabled) 132 { 133 RC_CHK_ACCESS(evlist)->enabled = enabled; 134 } 135 136 static inline bool evlist__no_affinity(const struct evlist *evlist) 137 { 138 return RC_CHK_ACCESS(evlist)->no_affinity; 139 } 140 141 static inline void evlist__set_no_affinity(struct evlist *evlist, bool no_affinity) 142 { 143 RC_CHK_ACCESS(evlist)->no_affinity = no_affinity; 144 } 145 146 static inline int evlist__sb_thread_done(const struct evlist *evlist) 147 { 148 return RC_CHK_ACCESS(evlist)->sb_thread.done; 149 } 150 151 static inline void evlist__set_sb_thread_done(struct evlist *evlist, int done) 152 { 153 RC_CHK_ACCESS(evlist)->sb_thread.done = done; 154 } 155 156 static inline pthread_t *evlist__sb_thread_th(struct evlist *evlist) 157 { 158 return &RC_CHK_ACCESS(evlist)->sb_thread.th; 159 } 160 161 static inline int evlist__id_pos(const struct evlist *evlist) 162 { 163 return RC_CHK_ACCESS(evlist)->id_pos; 164 } 165 166 static inline int evlist__is_pos(const struct evlist *evlist) 167 { 168 return RC_CHK_ACCESS(evlist)->is_pos; 169 } 170 171 static inline struct event_enable_timer *evlist__event_enable_timer(struct evlist *evlist) 172 { 173 return RC_CHK_ACCESS(evlist)->eet; 174 } 175 176 static inline enum bkw_mmap_state evlist__bkw_mmap_state(const struct evlist *evlist) 177 { 178 return RC_CHK_ACCESS(evlist)->bkw_mmap_state; 179 } 180 181 static inline void evlist__set_bkw_mmap_state(struct evlist *evlist, enum bkw_mmap_state state) 182 { 183 RC_CHK_ACCESS(evlist)->bkw_mmap_state = state; 184 } 185 186 static inline struct mmap *evlist__mmap(struct evlist *evlist) 187 { 188 return RC_CHK_ACCESS(evlist)->mmap; 189 } 190 191 static inline struct mmap *evlist__overwrite_mmap(struct evlist *evlist) 192 { 193 return RC_CHK_ACCESS(evlist)->overwrite_mmap; 194 } 195 196 static inline struct events_stats *evlist__stats(struct evlist *evlist) 197 { 198 return &RC_CHK_ACCESS(evlist)->stats; 199 } 200 201 static inline u64 evlist__first_sample_time(const struct evlist *evlist) 202 { 203 return RC_CHK_ACCESS(evlist)->first_sample_time; 204 } 205 206 static inline void evlist__set_first_sample_time(struct evlist *evlist, u64 first) 207 { 208 RC_CHK_ACCESS(evlist)->first_sample_time = first; 209 } 210 211 static inline u64 evlist__last_sample_time(const struct evlist *evlist) 212 { 213 return RC_CHK_ACCESS(evlist)->last_sample_time; 214 } 215 216 static inline void evlist__set_last_sample_time(struct evlist *evlist, u64 last) 217 { 218 RC_CHK_ACCESS(evlist)->last_sample_time = last; 219 } 220 221 static inline int evlist__nr_br_cntr(const struct evlist *evlist) 222 { 223 return RC_CHK_ACCESS(evlist)->nr_br_cntr; 224 } 225 226 static inline void evlist__set_nr_br_cntr(struct evlist *evlist, int nr) 227 { 228 RC_CHK_ACCESS(evlist)->nr_br_cntr = nr; 229 } 230 231 static inline struct perf_session *evlist__session(struct evlist *evlist) 232 { 233 return RC_CHK_ACCESS(evlist)->session; 234 } 235 236 static inline void evlist__set_session(struct evlist *evlist, struct perf_session *session) 237 { 238 RC_CHK_ACCESS(evlist)->session = session; 239 } 240 241 static inline void (*evlist__trace_event_sample_raw(struct evlist *evlist)) 242 (struct evlist *evlist, 243 union perf_event *event, 244 struct perf_sample *sample) 245 { 246 return RC_CHK_ACCESS(evlist)->trace_event_sample_raw; 247 } 248 249 static inline void evlist__set_trace_event_sample_raw(struct evlist *evlist, 250 void (*fun)(struct evlist *evlist, 251 union perf_event *event, 252 struct perf_sample *sample)) 253 { 254 RC_CHK_ACCESS(evlist)->trace_event_sample_raw = fun; 255 } 256 257 static inline pid_t evlist__workload_pid(const struct evlist *evlist) 258 { 259 return RC_CHK_ACCESS(evlist)->workload.pid; 260 } 261 262 static inline void evlist__set_workload_pid(struct evlist *evlist, pid_t pid) 263 { 264 RC_CHK_ACCESS(evlist)->workload.pid = pid; 265 } 266 267 static inline int evlist__workload_cork_fd(const struct evlist *evlist) 268 { 269 return RC_CHK_ACCESS(evlist)->workload.cork_fd; 270 } 271 272 static inline void evlist__set_workload_cork_fd(struct evlist *evlist, int cork_fd) 273 { 274 RC_CHK_ACCESS(evlist)->workload.cork_fd = cork_fd; 275 } 276 277 static inline int evlist__ctl_fd_fd(const struct evlist *evlist) 278 { 279 return RC_CHK_ACCESS(evlist)->ctl_fd.fd; 280 } 281 282 static inline void evlist__set_ctl_fd_fd(struct evlist *evlist, int fd) 283 { 284 RC_CHK_ACCESS(evlist)->ctl_fd.fd = fd; 285 } 286 287 static inline int evlist__ctl_fd_ack(const struct evlist *evlist) 288 { 289 return RC_CHK_ACCESS(evlist)->ctl_fd.ack; 290 } 291 292 static inline void evlist__set_ctl_fd_ack(struct evlist *evlist, int ack) 293 { 294 RC_CHK_ACCESS(evlist)->ctl_fd.ack = ack; 295 } 296 297 static inline int evlist__ctl_fd_pos(const struct evlist *evlist) 298 { 299 return RC_CHK_ACCESS(evlist)->ctl_fd.pos; 300 } 301 302 static inline void evlist__set_ctl_fd_pos(struct evlist *evlist, int pos) 303 { 304 RC_CHK_ACCESS(evlist)->ctl_fd.pos = pos; 305 } 306 307 static inline refcount_t *evlist__refcnt(struct evlist *evlist) 308 { 309 return &RC_CHK_ACCESS(evlist)->refcnt; 310 } 311 312 static inline struct rblist *evlist__metric_events(struct evlist *evlist) 313 { 314 return &RC_CHK_ACCESS(evlist)->metric_events; 315 } 316 317 static inline struct list_head *evlist__deferred_samples(struct evlist *evlist) 318 { 319 return &RC_CHK_ACCESS(evlist)->deferred_samples; 320 } 321 322 static inline struct evsel *evlist__selected(struct evlist *evlist) 323 { 324 return RC_CHK_ACCESS(evlist)->selected; 325 } 326 327 static inline void evlist__set_selected(struct evlist *evlist, struct evsel *evsel) 328 { 329 RC_CHK_ACCESS(evlist)->selected = evsel; 330 } 331 332 struct evlist *evlist__new(void); 333 struct evlist *evlist__new_default(const struct target *target, bool sample_callchains); 334 struct evlist *evlist__new_dummy(void); 335 struct evlist *evlist__get(struct evlist *evlist); 336 void evlist__put(struct evlist *evlist); 337 338 void evlist__add(struct evlist *evlist, struct evsel *entry); 339 void evlist__remove(struct evlist *evlist, struct evsel *evsel); 340 341 int arch_evlist__cmp(const struct evsel *lhs, const struct evsel *rhs); 342 int arch_evlist__add_required_events(struct list_head *list); 343 344 int evlist__add_dummy(struct evlist *evlist); 345 struct evsel *evlist__add_aux_dummy(struct evlist *evlist, bool system_wide); 346 static inline struct evsel *evlist__add_dummy_on_all_cpus(struct evlist *evlist) 347 { 348 return evlist__add_aux_dummy(evlist, true); 349 } 350 #ifdef HAVE_LIBTRACEEVENT 351 struct evsel *evlist__add_sched_switch(struct evlist *evlist, bool system_wide); 352 #endif 353 354 int evlist__add_sb_event(struct evlist *evlist, struct perf_event_attr *attr, 355 evsel__sb_cb_t cb, void *data); 356 void evlist__set_cb(struct evlist *evlist, evsel__sb_cb_t cb, void *data); 357 int evlist__start_sb_thread(struct evlist *evlist, struct target *target); 358 void evlist__stop_sb_thread(struct evlist *evlist); 359 360 #ifdef HAVE_LIBTRACEEVENT 361 int evlist__add_newtp(struct evlist *evlist, const char *sys, const char *name, void *handler); 362 #endif 363 364 int __evlist__set_tracepoints_handlers(struct evlist *evlist, 365 const struct evsel_str_handler *assocs, 366 size_t nr_assocs); 367 368 #define evlist__set_tracepoints_handlers(evlist, array) \ 369 __evlist__set_tracepoints_handlers(evlist, array, ARRAY_SIZE(array)) 370 371 int evlist__set_tp_filter(struct evlist *evlist, const char *filter); 372 int evlist__set_tp_filter_pids(struct evlist *evlist, size_t npids, pid_t *pids); 373 374 int evlist__append_tp_filter(struct evlist *evlist, const char *filter); 375 376 int evlist__append_tp_filter_pid(struct evlist *evlist, pid_t pid); 377 int evlist__append_tp_filter_pids(struct evlist *evlist, size_t npids, pid_t *pids); 378 379 struct evsel *evlist__find_tracepoint_by_name(struct evlist *evlist, const char *name); 380 381 int evlist__add_pollfd(struct evlist *evlist, int fd); 382 int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask); 383 384 #ifdef HAVE_EVENTFD_SUPPORT 385 int evlist__add_wakeup_eventfd(struct evlist *evlist, int fd); 386 #endif 387 388 int evlist__poll(struct evlist *evlist, int timeout); 389 390 struct evsel *evlist__id2evsel(struct evlist *evlist, u64 id); 391 struct evsel *evlist__id2evsel_strict(struct evlist *evlist, u64 id); 392 393 struct perf_sample_id *evlist__id2sid(struct evlist *evlist, u64 id); 394 395 void evlist__toggle_bkw_mmap(struct evlist *evlist, enum bkw_mmap_state state); 396 397 void evlist__mmap_consume(struct evlist *evlist, int idx); 398 399 int evlist__open(struct evlist *evlist); 400 void evlist__close(struct evlist *evlist); 401 402 struct callchain_param; 403 404 void evlist__set_id_pos(struct evlist *evlist); 405 void evlist__config(struct evlist *evlist, struct record_opts *opts, struct callchain_param *callchain); 406 int record_opts__config(struct record_opts *opts); 407 408 int evlist__prepare_workload(struct evlist *evlist, struct target *target, 409 const char *argv[], bool pipe_output, 410 void (*exec_error)(int signo, siginfo_t *info, void *ucontext)); 411 int evlist__start_workload(struct evlist *evlist); 412 void evlist__cancel_workload(struct evlist *evlist); 413 414 struct option; 415 416 int __evlist__parse_mmap_pages(unsigned int *mmap_pages, const char *str); 417 int evlist__parse_mmap_pages(const struct option *opt, const char *str, int unset); 418 419 unsigned long perf_event_mlock_kb_in_pages(void); 420 421 int evlist__mmap_ex(struct evlist *evlist, unsigned int pages, 422 unsigned int auxtrace_pages, 423 bool auxtrace_overwrite, int nr_cblocks, 424 int affinity, int flush, int comp_level); 425 int evlist__do_mmap(struct evlist *evlist, unsigned int pages); 426 void evlist__do_munmap(struct evlist *evlist); 427 428 size_t evlist__mmap_size(unsigned long pages); 429 430 void evlist__disable(struct evlist *evlist); 431 void evlist__enable(struct evlist *evlist); 432 void evlist__toggle_enable(struct evlist *evlist); 433 void evlist__disable_evsel(struct evlist *evlist, char *evsel_name); 434 void evlist__enable_evsel(struct evlist *evlist, char *evsel_name); 435 void evlist__disable_non_dummy(struct evlist *evlist); 436 void evlist__enable_non_dummy(struct evlist *evlist); 437 438 int evlist__create_maps(struct evlist *evlist, struct target *target); 439 int evlist__apply_filters(struct evlist *evlist, struct evsel **err_evsel, 440 struct target *target); 441 442 u64 __evlist__combined_sample_type(struct evlist *evlist); 443 u64 evlist__combined_sample_type(struct evlist *evlist); 444 u64 evlist__combined_branch_type(struct evlist *evlist); 445 void evlist__update_br_cntr(struct evlist *evlist); 446 bool evlist__sample_id_all(struct evlist *evlist); 447 u16 evlist__id_hdr_size(struct evlist *evlist); 448 449 int evlist__parse_sample(struct evlist *evlist, union perf_event *event, struct perf_sample *sample); 450 int evlist__parse_sample_timestamp(struct evlist *evlist, union perf_event *event, u64 *timestamp); 451 452 bool evlist__valid_sample_type(struct evlist *evlist); 453 bool evlist__valid_sample_id_all(struct evlist *evlist); 454 bool evlist__valid_read_format(struct evlist *evlist); 455 456 void evlist__splice_list_tail(struct evlist *evlist, struct list_head *list); 457 458 static inline bool evlist__empty(struct evlist *evlist) 459 { 460 return list_empty(&evlist__core(evlist)->entries); 461 } 462 463 static inline struct evsel *evlist__first(struct evlist *evlist) 464 { 465 struct perf_evsel *evsel = perf_evlist__first(evlist__core(evlist)); 466 467 return container_of(evsel, struct evsel, core); 468 } 469 470 static inline struct evsel *evlist__last(struct evlist *evlist) 471 { 472 struct perf_evsel *evsel = perf_evlist__last(evlist__core(evlist)); 473 474 return container_of(evsel, struct evsel, core); 475 } 476 477 static inline int evlist__nr_groups(struct evlist *evlist) 478 { 479 return perf_evlist__nr_groups(evlist__core(evlist)); 480 } 481 482 int evlist__strerror_open(struct evlist *evlist, int err, char *buf, size_t size); 483 int evlist__strerror_mmap(struct evlist *evlist, int err, char *buf, size_t size); 484 485 bool evlist__can_select_event(struct evlist *evlist, const char *str); 486 void evlist__to_front(struct evlist *evlist, struct evsel *move_evsel); 487 488 /** 489 * __evlist__for_each_entry - iterate thru all the evsels 490 * @list: list_head instance to iterate 491 * @evsel: struct evsel iterator 492 */ 493 #define __evlist__for_each_entry(list, evsel) \ 494 list_for_each_entry(evsel, list, core.node) 495 496 /** 497 * evlist__for_each_entry - iterate thru all the evsels 498 * @evlist: evlist instance to iterate 499 * @evsel: struct evsel iterator 500 */ 501 #define evlist__for_each_entry(evlist, evsel) \ 502 __evlist__for_each_entry(&evlist__core(evlist)->entries, evsel) 503 504 /** 505 * __evlist__for_each_entry_continue - continue iteration thru all the evsels 506 * @list: list_head instance to iterate 507 * @evsel: struct evsel iterator 508 */ 509 #define __evlist__for_each_entry_continue(list, evsel) \ 510 list_for_each_entry_continue(evsel, list, core.node) 511 512 /** 513 * evlist__for_each_entry_continue - continue iteration thru all the evsels 514 * @evlist: evlist instance to iterate 515 * @evsel: struct evsel iterator 516 */ 517 #define evlist__for_each_entry_continue(evlist, evsel) \ 518 __evlist__for_each_entry_continue(&evlist__core(evlist)->entries, evsel) 519 520 /** 521 * __evlist__for_each_entry_from - continue iteration from @evsel (included) 522 * @list: list_head instance to iterate 523 * @evsel: struct evsel iterator 524 */ 525 #define __evlist__for_each_entry_from(list, evsel) \ 526 list_for_each_entry_from(evsel, list, core.node) 527 528 /** 529 * evlist__for_each_entry_from - continue iteration from @evsel (included) 530 * @evlist: evlist instance to iterate 531 * @evsel: struct evsel iterator 532 */ 533 #define evlist__for_each_entry_from(evlist, evsel) \ 534 __evlist__for_each_entry_from(&evlist__core(evlist)->entries, evsel) 535 536 /** 537 * __evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order 538 * @list: list_head instance to iterate 539 * @evsel: struct evsel iterator 540 */ 541 #define __evlist__for_each_entry_reverse(list, evsel) \ 542 list_for_each_entry_reverse(evsel, list, core.node) 543 544 /** 545 * evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order 546 * @evlist: evlist instance to iterate 547 * @evsel: struct evsel iterator 548 */ 549 #define evlist__for_each_entry_reverse(evlist, evsel) \ 550 __evlist__for_each_entry_reverse(&evlist__core(evlist)->entries, evsel) 551 552 /** 553 * __evlist__for_each_entry_safe - safely iterate thru all the evsels 554 * @list: list_head instance to iterate 555 * @tmp: struct evsel temp iterator 556 * @evsel: struct evsel iterator 557 */ 558 #define __evlist__for_each_entry_safe(list, tmp, evsel) \ 559 list_for_each_entry_safe(evsel, tmp, list, core.node) 560 561 /** 562 * evlist__for_each_entry_safe - safely iterate thru all the evsels 563 * @evlist: evlist instance to iterate 564 * @evsel: struct evsel iterator 565 * @tmp: struct evsel temp iterator 566 */ 567 #define evlist__for_each_entry_safe(evlist, tmp, evsel) \ 568 __evlist__for_each_entry_safe(&evlist__core(evlist)->entries, tmp, evsel) 569 570 /** Iterator state for evlist__for_each_cpu */ 571 struct evlist_cpu_iterator { 572 /** The list being iterated through. */ 573 struct evlist *container; 574 /** The current evsel of the iterator. */ 575 struct evsel *evsel; 576 /** The CPU map index corresponding to the evsel->core.cpus for the current CPU. */ 577 int cpu_map_idx; 578 /** 579 * The CPU map index corresponding to evlist->core.all_cpus for the 580 * current CPU. Distinct from cpu_map_idx as the evsel's cpu map may 581 * contain fewer entries. 582 */ 583 int evlist_cpu_map_idx; 584 /** The number of CPU map entries in evlist->core.all_cpus. */ 585 int evlist_cpu_map_nr; 586 /** The current CPU of the iterator. */ 587 struct perf_cpu cpu; 588 /** If present, used to set the affinity when switching between CPUs. */ 589 struct affinity *affinity; 590 /** Maybe be used to hold affinity state prior to iterating. */ 591 struct affinity saved_affinity; 592 }; 593 594 /** 595 * evlist__for_each_cpu - without affinity, iterate over the evlist. With 596 * affinity, iterate over all CPUs and then the evlist 597 * for each evsel on that CPU. When switching between 598 * CPUs the affinity is set to the CPU to avoid IPIs 599 * during syscalls. The affinity is set up and removed 600 * automatically, if the loop is broken a call to 601 * evlist_cpu_iterator__exit is necessary. 602 * @evlist_cpu_itr: the iterator instance. 603 * @evlist: evlist instance to iterate. 604 */ 605 #define evlist__for_each_cpu(evlist_cpu_itr, evlist) \ 606 for (evlist_cpu_iterator__init(&(evlist_cpu_itr), evlist); \ 607 !evlist_cpu_iterator__end(&evlist_cpu_itr); \ 608 evlist_cpu_iterator__next(&evlist_cpu_itr)) 609 610 /** Setup an iterator set to the first CPU/evsel of evlist. */ 611 void evlist_cpu_iterator__init(struct evlist_cpu_iterator *itr, struct evlist *evlist); 612 /** 613 * Cleans up the iterator, automatically done by evlist_cpu_iterator__next when 614 * the end of the list is reached. Multiple calls are safe. 615 */ 616 void evlist_cpu_iterator__exit(struct evlist_cpu_iterator *itr); 617 /** Move to next element in iterator, updating CPU, evsel and the affinity. */ 618 void evlist_cpu_iterator__next(struct evlist_cpu_iterator *evlist_cpu_itr); 619 /** Returns true when iterator is at the end of the CPUs and evlist. */ 620 static inline bool evlist_cpu_iterator__end(const struct evlist_cpu_iterator *evlist_cpu_itr) 621 { 622 return evlist_cpu_itr->evlist_cpu_map_idx >= evlist_cpu_itr->evlist_cpu_map_nr; 623 } 624 625 struct evsel *evlist__get_tracking_event(struct evlist *evlist); 626 void evlist__set_tracking_event(struct evlist *evlist, struct evsel *tracking_evsel); 627 struct evsel *evlist__findnew_tracking_event(struct evlist *evlist, bool system_wide); 628 629 struct evsel *evlist__find_evsel_by_str(struct evlist *evlist, const char *str); 630 631 struct evsel *evlist__event2evsel(struct evlist *evlist, union perf_event *event); 632 633 bool evlist__exclude_kernel(struct evlist *evlist); 634 635 void evlist__force_leader(struct evlist *evlist); 636 637 struct evsel *evlist__reset_weak_group(struct evlist *evlist, struct evsel *evsel, bool close); 638 639 #define EVLIST_CTL_CMD_ENABLE_TAG "enable" 640 #define EVLIST_CTL_CMD_DISABLE_TAG "disable" 641 #define EVLIST_CTL_CMD_ACK_TAG "ack\n" 642 #define EVLIST_CTL_CMD_SNAPSHOT_TAG "snapshot" 643 #define EVLIST_CTL_CMD_EVLIST_TAG "evlist" 644 #define EVLIST_CTL_CMD_STOP_TAG "stop" 645 #define EVLIST_CTL_CMD_PING_TAG "ping" 646 647 #define EVLIST_CTL_CMD_MAX_LEN 64 648 649 enum evlist_ctl_cmd { 650 EVLIST_CTL_CMD_UNSUPPORTED = 0, 651 EVLIST_CTL_CMD_ENABLE, 652 EVLIST_CTL_CMD_DISABLE, 653 EVLIST_CTL_CMD_ACK, 654 EVLIST_CTL_CMD_SNAPSHOT, 655 EVLIST_CTL_CMD_EVLIST, 656 EVLIST_CTL_CMD_STOP, 657 EVLIST_CTL_CMD_PING, 658 }; 659 660 int evlist__parse_control(const char *str, int *ctl_fd, int *ctl_fd_ack, bool *ctl_fd_close); 661 void evlist__close_control(int ctl_fd, int ctl_fd_ack, bool *ctl_fd_close); 662 int evlist__initialize_ctlfd(struct evlist *evlist, int ctl_fd, int ctl_fd_ack); 663 int evlist__finalize_ctlfd(struct evlist *evlist); 664 bool evlist__ctlfd_initialized(struct evlist *evlist); 665 int evlist__ctlfd_process(struct evlist *evlist, enum evlist_ctl_cmd *cmd); 666 int evlist__ctlfd_ack(struct evlist *evlist); 667 668 #define EVLIST_ENABLED_MSG "Events enabled\n" 669 #define EVLIST_DISABLED_MSG "Events disabled\n" 670 671 int evlist__parse_event_enable_time(struct evlist *evlist, struct record_opts *opts, 672 const char *str, int unset); 673 int event_enable_timer__start(struct event_enable_timer *eet); 674 int event_enable_timer__process(struct event_enable_timer *eet); 675 676 struct evsel *evlist__find_evsel(struct evlist *evlist, int idx); 677 678 void evlist__format_evsels(struct evlist *evlist, struct strbuf *sb, size_t max_length); 679 void evlist__check_mem_load_aux(struct evlist *evlist); 680 void evlist__warn_user_requested_cpus(struct evlist *evlist, const char *cpu_list); 681 void evlist__uniquify_evsel_names(struct evlist *evlist, const struct perf_stat_config *config); 682 bool evlist__has_bpf_output(struct evlist *evlist); 683 bool evlist__needs_bpf_sb_event(struct evlist *evlist); 684 685 #endif /* __PERF_EVLIST_H */ 686