| .. | .. |
|---|
| 2 | 2 | #ifndef __PERF_HIST_H |
|---|
| 3 | 3 | #define __PERF_HIST_H |
|---|
| 4 | 4 | |
|---|
| 5 | +#include <linux/rbtree.h> |
|---|
| 5 | 6 | #include <linux/types.h> |
|---|
| 6 | 7 | #include <pthread.h> |
|---|
| 7 | | -#include "callchain.h" |
|---|
| 8 | 8 | #include "evsel.h" |
|---|
| 9 | | -#include "header.h" |
|---|
| 10 | 9 | #include "color.h" |
|---|
| 11 | | -#include "ui/progress.h" |
|---|
| 10 | +#include "events_stats.h" |
|---|
| 12 | 11 | |
|---|
| 13 | 12 | struct hist_entry; |
|---|
| 14 | 13 | struct hist_entry_ops; |
|---|
| 15 | 14 | struct addr_location; |
|---|
| 15 | +struct map_symbol; |
|---|
| 16 | +struct mem_info; |
|---|
| 17 | +struct branch_info; |
|---|
| 18 | +struct branch_stack; |
|---|
| 19 | +struct block_info; |
|---|
| 16 | 20 | struct symbol; |
|---|
| 21 | +struct ui_progress; |
|---|
| 17 | 22 | |
|---|
| 18 | 23 | enum hist_filter { |
|---|
| 19 | 24 | HIST_FILTER__DSO, |
|---|
| .. | .. |
|---|
| 28 | 33 | |
|---|
| 29 | 34 | enum hist_column { |
|---|
| 30 | 35 | HISTC_SYMBOL, |
|---|
| 36 | + HISTC_TIME, |
|---|
| 31 | 37 | HISTC_DSO, |
|---|
| 32 | 38 | HISTC_THREAD, |
|---|
| 33 | 39 | HISTC_COMM, |
|---|
| 34 | 40 | HISTC_CGROUP_ID, |
|---|
| 41 | + HISTC_CGROUP, |
|---|
| 35 | 42 | HISTC_PARENT, |
|---|
| 36 | 43 | HISTC_CPU, |
|---|
| 37 | 44 | HISTC_SOCKET, |
|---|
| .. | .. |
|---|
| 62 | 69 | HISTC_TRACE, |
|---|
| 63 | 70 | HISTC_SYM_SIZE, |
|---|
| 64 | 71 | HISTC_DSO_SIZE, |
|---|
| 72 | + HISTC_SYMBOL_IPC, |
|---|
| 65 | 73 | HISTC_NR_COLS, /* Last entry */ |
|---|
| 66 | 74 | }; |
|---|
| 67 | 75 | |
|---|
| .. | .. |
|---|
| 69 | 77 | struct dso; |
|---|
| 70 | 78 | |
|---|
| 71 | 79 | struct hists { |
|---|
| 72 | | - struct rb_root entries_in_array[2]; |
|---|
| 73 | | - struct rb_root *entries_in; |
|---|
| 74 | | - struct rb_root entries; |
|---|
| 75 | | - struct rb_root entries_collapsed; |
|---|
| 80 | + struct rb_root_cached entries_in_array[2]; |
|---|
| 81 | + struct rb_root_cached *entries_in; |
|---|
| 82 | + struct rb_root_cached entries; |
|---|
| 83 | + struct rb_root_cached entries_collapsed; |
|---|
| 76 | 84 | u64 nr_entries; |
|---|
| 77 | 85 | u64 nr_non_filtered_entries; |
|---|
| 78 | 86 | u64 callchain_period; |
|---|
| .. | .. |
|---|
| 110 | 118 | |
|---|
| 111 | 119 | bool hide_unresolved; |
|---|
| 112 | 120 | |
|---|
| 113 | | - struct perf_evsel *evsel; |
|---|
| 121 | + struct evsel *evsel; |
|---|
| 114 | 122 | struct perf_sample *sample; |
|---|
| 115 | 123 | struct hist_entry *he; |
|---|
| 116 | 124 | struct symbol *parent; |
|---|
| .. | .. |
|---|
| 144 | 152 | struct perf_sample *sample, |
|---|
| 145 | 153 | bool sample_self); |
|---|
| 146 | 154 | |
|---|
| 155 | +struct hist_entry *hists__add_entry_block(struct hists *hists, |
|---|
| 156 | + struct addr_location *al, |
|---|
| 157 | + struct block_info *bi); |
|---|
| 158 | + |
|---|
| 147 | 159 | int hist_entry_iter__add(struct hist_entry_iter *iter, struct addr_location *al, |
|---|
| 148 | 160 | int max_stack_depth, void *arg); |
|---|
| 149 | 161 | |
|---|
| .. | .. |
|---|
| 159 | 171 | struct perf_hpp_fmt *fmt, int printed); |
|---|
| 160 | 172 | void hist_entry__delete(struct hist_entry *he); |
|---|
| 161 | 173 | |
|---|
| 162 | | -typedef int (*hists__resort_cb_t)(struct hist_entry *he); |
|---|
| 174 | +typedef int (*hists__resort_cb_t)(struct hist_entry *he, void *arg); |
|---|
| 163 | 175 | |
|---|
| 164 | | -void perf_evsel__output_resort(struct perf_evsel *evsel, struct ui_progress *prog); |
|---|
| 176 | +void evsel__output_resort_cb(struct evsel *evsel, struct ui_progress *prog, |
|---|
| 177 | + hists__resort_cb_t cb, void *cb_arg); |
|---|
| 178 | +void evsel__output_resort(struct evsel *evsel, struct ui_progress *prog); |
|---|
| 165 | 179 | void hists__output_resort(struct hists *hists, struct ui_progress *prog); |
|---|
| 166 | 180 | void hists__output_resort_cb(struct hists *hists, struct ui_progress *prog, |
|---|
| 167 | 181 | hists__resort_cb_t cb); |
|---|
| .. | .. |
|---|
| 171 | 185 | void hists__delete_entries(struct hists *hists); |
|---|
| 172 | 186 | void hists__output_recalc_col_len(struct hists *hists, int max_rows); |
|---|
| 173 | 187 | |
|---|
| 188 | +struct hist_entry *hists__get_entry(struct hists *hists, int idx); |
|---|
| 189 | + |
|---|
| 174 | 190 | u64 hists__total_period(struct hists *hists); |
|---|
| 175 | 191 | void hists__reset_stats(struct hists *hists); |
|---|
| 176 | 192 | void hists__inc_stats(struct hists *hists, struct hist_entry *h); |
|---|
| 177 | 193 | void hists__inc_nr_events(struct hists *hists, u32 type); |
|---|
| 178 | 194 | void hists__inc_nr_samples(struct hists *hists, bool filtered); |
|---|
| 179 | | -void events_stats__inc(struct events_stats *stats, u32 type); |
|---|
| 180 | | -size_t events_stats__fprintf(struct events_stats *stats, FILE *fp); |
|---|
| 181 | 195 | |
|---|
| 182 | 196 | size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, |
|---|
| 183 | 197 | int max_cols, float min_pcnt, FILE *fp, |
|---|
| 184 | 198 | bool ignore_callchains); |
|---|
| 185 | | -size_t perf_evlist__fprintf_nr_events(struct perf_evlist *evlist, FILE *fp); |
|---|
| 199 | +size_t perf_evlist__fprintf_nr_events(struct evlist *evlist, FILE *fp); |
|---|
| 186 | 200 | |
|---|
| 187 | 201 | void hists__filter_by_dso(struct hists *hists); |
|---|
| 188 | 202 | void hists__filter_by_thread(struct hists *hists); |
|---|
| .. | .. |
|---|
| 203 | 217 | |
|---|
| 204 | 218 | void hists__match(struct hists *leader, struct hists *other); |
|---|
| 205 | 219 | int hists__link(struct hists *leader, struct hists *other); |
|---|
| 220 | +int hists__unlink(struct hists *hists); |
|---|
| 206 | 221 | |
|---|
| 207 | 222 | struct hists_evsel { |
|---|
| 208 | | - struct perf_evsel evsel; |
|---|
| 223 | + struct evsel evsel; |
|---|
| 209 | 224 | struct hists hists; |
|---|
| 210 | 225 | }; |
|---|
| 211 | 226 | |
|---|
| 212 | | -static inline struct perf_evsel *hists_to_evsel(struct hists *hists) |
|---|
| 227 | +static inline struct evsel *hists_to_evsel(struct hists *hists) |
|---|
| 213 | 228 | { |
|---|
| 214 | 229 | struct hists_evsel *hevsel = container_of(hists, struct hists_evsel, hists); |
|---|
| 215 | 230 | return &hevsel->evsel; |
|---|
| 216 | 231 | } |
|---|
| 217 | 232 | |
|---|
| 218 | | -static inline struct hists *evsel__hists(struct perf_evsel *evsel) |
|---|
| 233 | +static inline struct hists *evsel__hists(struct evsel *evsel) |
|---|
| 219 | 234 | { |
|---|
| 220 | 235 | struct hists_evsel *hevsel = (struct hists_evsel *)evsel; |
|---|
| 221 | 236 | return &hevsel->hists; |
|---|
| .. | .. |
|---|
| 229 | 244 | int hists__init(void); |
|---|
| 230 | 245 | int __hists__init(struct hists *hists, struct perf_hpp_list *hpp_list); |
|---|
| 231 | 246 | |
|---|
| 232 | | -struct rb_root *hists__get_rotate_entries_in(struct hists *hists); |
|---|
| 247 | +struct rb_root_cached *hists__get_rotate_entries_in(struct hists *hists); |
|---|
| 233 | 248 | |
|---|
| 234 | 249 | struct perf_hpp { |
|---|
| 235 | 250 | char *buf; |
|---|
| 236 | 251 | size_t size; |
|---|
| 237 | 252 | const char *sep; |
|---|
| 238 | 253 | void *ptr; |
|---|
| 254 | + bool skip; |
|---|
| 239 | 255 | }; |
|---|
| 240 | 256 | |
|---|
| 241 | 257 | struct perf_hpp_fmt { |
|---|
| .. | .. |
|---|
| 351 | 367 | void perf_hpp__reset_output_field(struct perf_hpp_list *list); |
|---|
| 352 | 368 | void perf_hpp__append_sort_keys(struct perf_hpp_list *list); |
|---|
| 353 | 369 | int perf_hpp__setup_hists_formats(struct perf_hpp_list *list, |
|---|
| 354 | | - struct perf_evlist *evlist); |
|---|
| 370 | + struct evlist *evlist); |
|---|
| 355 | 371 | |
|---|
| 356 | 372 | |
|---|
| 357 | 373 | bool perf_hpp__is_sort_entry(struct perf_hpp_fmt *format); |
|---|
| .. | .. |
|---|
| 416 | 432 | : 0; |
|---|
| 417 | 433 | } |
|---|
| 418 | 434 | |
|---|
| 419 | | -struct perf_evlist; |
|---|
| 435 | +struct evlist; |
|---|
| 420 | 436 | |
|---|
| 421 | 437 | struct hist_browser_timer { |
|---|
| 422 | 438 | void (*timer)(void *arg); |
|---|
| .. | .. |
|---|
| 425 | 441 | }; |
|---|
| 426 | 442 | |
|---|
| 427 | 443 | struct annotation_options; |
|---|
| 444 | +struct res_sample; |
|---|
| 445 | + |
|---|
| 446 | +enum rstype { |
|---|
| 447 | + A_NORMAL, |
|---|
| 448 | + A_ASM, |
|---|
| 449 | + A_SOURCE |
|---|
| 450 | +}; |
|---|
| 451 | + |
|---|
| 452 | +struct block_hist; |
|---|
| 428 | 453 | |
|---|
| 429 | 454 | #ifdef HAVE_SLANG_SUPPORT |
|---|
| 430 | 455 | #include "../ui/keysyms.h" |
|---|
| 431 | | -int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel, |
|---|
| 456 | +void attr_to_script(char *buf, struct perf_event_attr *attr); |
|---|
| 457 | + |
|---|
| 458 | +int map_symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel, |
|---|
| 432 | 459 | struct hist_browser_timer *hbt, |
|---|
| 433 | 460 | struct annotation_options *annotation_opts); |
|---|
| 434 | 461 | |
|---|
| 435 | | -int hist_entry__tui_annotate(struct hist_entry *he, struct perf_evsel *evsel, |
|---|
| 462 | +int hist_entry__tui_annotate(struct hist_entry *he, struct evsel *evsel, |
|---|
| 436 | 463 | struct hist_browser_timer *hbt, |
|---|
| 437 | 464 | struct annotation_options *annotation_opts); |
|---|
| 438 | 465 | |
|---|
| 439 | | -int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, |
|---|
| 466 | +int perf_evlist__tui_browse_hists(struct evlist *evlist, const char *help, |
|---|
| 440 | 467 | struct hist_browser_timer *hbt, |
|---|
| 441 | 468 | float min_pcnt, |
|---|
| 442 | 469 | struct perf_env *env, |
|---|
| 443 | 470 | bool warn_lost_event, |
|---|
| 444 | 471 | struct annotation_options *annotation_options); |
|---|
| 445 | | -int script_browse(const char *script_opt); |
|---|
| 472 | + |
|---|
| 473 | +int script_browse(const char *script_opt, struct evsel *evsel); |
|---|
| 474 | + |
|---|
| 475 | +void run_script(char *cmd); |
|---|
| 476 | +int res_sample_browse(struct res_sample *res_samples, int num_res, |
|---|
| 477 | + struct evsel *evsel, enum rstype rstype); |
|---|
| 478 | +void res_sample_init(void); |
|---|
| 479 | + |
|---|
| 480 | +int block_hists_tui_browse(struct block_hist *bh, struct evsel *evsel, |
|---|
| 481 | + float min_percent, struct perf_env *env, |
|---|
| 482 | + struct annotation_options *annotation_opts); |
|---|
| 446 | 483 | #else |
|---|
| 447 | 484 | static inline |
|---|
| 448 | | -int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __maybe_unused, |
|---|
| 485 | +int perf_evlist__tui_browse_hists(struct evlist *evlist __maybe_unused, |
|---|
| 449 | 486 | const char *help __maybe_unused, |
|---|
| 450 | 487 | struct hist_browser_timer *hbt __maybe_unused, |
|---|
| 451 | 488 | float min_pcnt __maybe_unused, |
|---|
| .. | .. |
|---|
| 456 | 493 | return 0; |
|---|
| 457 | 494 | } |
|---|
| 458 | 495 | static inline int map_symbol__tui_annotate(struct map_symbol *ms __maybe_unused, |
|---|
| 459 | | - struct perf_evsel *evsel __maybe_unused, |
|---|
| 496 | + struct evsel *evsel __maybe_unused, |
|---|
| 460 | 497 | struct hist_browser_timer *hbt __maybe_unused, |
|---|
| 461 | 498 | struct annotation_options *annotation_options __maybe_unused) |
|---|
| 462 | 499 | { |
|---|
| .. | .. |
|---|
| 464 | 501 | } |
|---|
| 465 | 502 | |
|---|
| 466 | 503 | static inline int hist_entry__tui_annotate(struct hist_entry *he __maybe_unused, |
|---|
| 467 | | - struct perf_evsel *evsel __maybe_unused, |
|---|
| 504 | + struct evsel *evsel __maybe_unused, |
|---|
| 468 | 505 | struct hist_browser_timer *hbt __maybe_unused, |
|---|
| 469 | 506 | struct annotation_options *annotation_opts __maybe_unused) |
|---|
| 470 | 507 | { |
|---|
| 471 | 508 | return 0; |
|---|
| 472 | 509 | } |
|---|
| 473 | 510 | |
|---|
| 474 | | -static inline int script_browse(const char *script_opt __maybe_unused) |
|---|
| 511 | +static inline int script_browse(const char *script_opt __maybe_unused, |
|---|
| 512 | + struct evsel *evsel __maybe_unused) |
|---|
| 513 | +{ |
|---|
| 514 | + return 0; |
|---|
| 515 | +} |
|---|
| 516 | + |
|---|
| 517 | +static inline int res_sample_browse(struct res_sample *res_samples __maybe_unused, |
|---|
| 518 | + int num_res __maybe_unused, |
|---|
| 519 | + struct evsel *evsel __maybe_unused, |
|---|
| 520 | + enum rstype rstype __maybe_unused) |
|---|
| 521 | +{ |
|---|
| 522 | + return 0; |
|---|
| 523 | +} |
|---|
| 524 | + |
|---|
| 525 | +static inline void res_sample_init(void) {} |
|---|
| 526 | + |
|---|
| 527 | +static inline int block_hists_tui_browse(struct block_hist *bh __maybe_unused, |
|---|
| 528 | + struct evsel *evsel __maybe_unused, |
|---|
| 529 | + float min_percent __maybe_unused, |
|---|
| 530 | + struct perf_env *env __maybe_unused, |
|---|
| 531 | + struct annotation_options *annotation_opts __maybe_unused) |
|---|
| 475 | 532 | { |
|---|
| 476 | 533 | return 0; |
|---|
| 477 | 534 | } |
|---|
| .. | .. |
|---|
| 479 | 536 | #define K_LEFT -1000 |
|---|
| 480 | 537 | #define K_RIGHT -2000 |
|---|
| 481 | 538 | #define K_SWITCH_INPUT_DATA -3000 |
|---|
| 539 | +#define K_RELOAD -4000 |
|---|
| 482 | 540 | #endif |
|---|
| 483 | 541 | |
|---|
| 484 | 542 | unsigned int hists__sort_list_width(struct hists *hists); |
|---|
| 485 | 543 | unsigned int hists__overhead_width(struct hists *hists); |
|---|
| 486 | 544 | |
|---|
| 487 | 545 | void hist__account_cycles(struct branch_stack *bs, struct addr_location *al, |
|---|
| 488 | | - struct perf_sample *sample, bool nonany_branch_mode); |
|---|
| 546 | + struct perf_sample *sample, bool nonany_branch_mode, |
|---|
| 547 | + u64 *total_cycles); |
|---|
| 489 | 548 | |
|---|
| 490 | 549 | struct option; |
|---|
| 491 | 550 | int parse_filter_percentage(const struct option *opt, const char *arg, int unset); |
|---|