hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/tools/perf/util/hist.h
....@@ -2,18 +2,23 @@
22 #ifndef __PERF_HIST_H
33 #define __PERF_HIST_H
44
5
+#include <linux/rbtree.h>
56 #include <linux/types.h>
67 #include <pthread.h>
7
-#include "callchain.h"
88 #include "evsel.h"
9
-#include "header.h"
109 #include "color.h"
11
-#include "ui/progress.h"
10
+#include "events_stats.h"
1211
1312 struct hist_entry;
1413 struct hist_entry_ops;
1514 struct addr_location;
15
+struct map_symbol;
16
+struct mem_info;
17
+struct branch_info;
18
+struct branch_stack;
19
+struct block_info;
1620 struct symbol;
21
+struct ui_progress;
1722
1823 enum hist_filter {
1924 HIST_FILTER__DSO,
....@@ -28,10 +33,12 @@
2833
2934 enum hist_column {
3035 HISTC_SYMBOL,
36
+ HISTC_TIME,
3137 HISTC_DSO,
3238 HISTC_THREAD,
3339 HISTC_COMM,
3440 HISTC_CGROUP_ID,
41
+ HISTC_CGROUP,
3542 HISTC_PARENT,
3643 HISTC_CPU,
3744 HISTC_SOCKET,
....@@ -62,6 +69,7 @@
6269 HISTC_TRACE,
6370 HISTC_SYM_SIZE,
6471 HISTC_DSO_SIZE,
72
+ HISTC_SYMBOL_IPC,
6573 HISTC_NR_COLS, /* Last entry */
6674 };
6775
....@@ -69,10 +77,10 @@
6977 struct dso;
7078
7179 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;
7684 u64 nr_entries;
7785 u64 nr_non_filtered_entries;
7886 u64 callchain_period;
....@@ -110,7 +118,7 @@
110118
111119 bool hide_unresolved;
112120
113
- struct perf_evsel *evsel;
121
+ struct evsel *evsel;
114122 struct perf_sample *sample;
115123 struct hist_entry *he;
116124 struct symbol *parent;
....@@ -144,6 +152,10 @@
144152 struct perf_sample *sample,
145153 bool sample_self);
146154
155
+struct hist_entry *hists__add_entry_block(struct hists *hists,
156
+ struct addr_location *al,
157
+ struct block_info *bi);
158
+
147159 int hist_entry_iter__add(struct hist_entry_iter *iter, struct addr_location *al,
148160 int max_stack_depth, void *arg);
149161
....@@ -159,9 +171,11 @@
159171 struct perf_hpp_fmt *fmt, int printed);
160172 void hist_entry__delete(struct hist_entry *he);
161173
162
-typedef int (*hists__resort_cb_t)(struct hist_entry *he);
174
+typedef int (*hists__resort_cb_t)(struct hist_entry *he, void *arg);
163175
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);
165179 void hists__output_resort(struct hists *hists, struct ui_progress *prog);
166180 void hists__output_resort_cb(struct hists *hists, struct ui_progress *prog,
167181 hists__resort_cb_t cb);
....@@ -171,18 +185,18 @@
171185 void hists__delete_entries(struct hists *hists);
172186 void hists__output_recalc_col_len(struct hists *hists, int max_rows);
173187
188
+struct hist_entry *hists__get_entry(struct hists *hists, int idx);
189
+
174190 u64 hists__total_period(struct hists *hists);
175191 void hists__reset_stats(struct hists *hists);
176192 void hists__inc_stats(struct hists *hists, struct hist_entry *h);
177193 void hists__inc_nr_events(struct hists *hists, u32 type);
178194 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);
181195
182196 size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
183197 int max_cols, float min_pcnt, FILE *fp,
184198 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);
186200
187201 void hists__filter_by_dso(struct hists *hists);
188202 void hists__filter_by_thread(struct hists *hists);
....@@ -203,19 +217,20 @@
203217
204218 void hists__match(struct hists *leader, struct hists *other);
205219 int hists__link(struct hists *leader, struct hists *other);
220
+int hists__unlink(struct hists *hists);
206221
207222 struct hists_evsel {
208
- struct perf_evsel evsel;
223
+ struct evsel evsel;
209224 struct hists hists;
210225 };
211226
212
-static inline struct perf_evsel *hists_to_evsel(struct hists *hists)
227
+static inline struct evsel *hists_to_evsel(struct hists *hists)
213228 {
214229 struct hists_evsel *hevsel = container_of(hists, struct hists_evsel, hists);
215230 return &hevsel->evsel;
216231 }
217232
218
-static inline struct hists *evsel__hists(struct perf_evsel *evsel)
233
+static inline struct hists *evsel__hists(struct evsel *evsel)
219234 {
220235 struct hists_evsel *hevsel = (struct hists_evsel *)evsel;
221236 return &hevsel->hists;
....@@ -229,13 +244,14 @@
229244 int hists__init(void);
230245 int __hists__init(struct hists *hists, struct perf_hpp_list *hpp_list);
231246
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);
233248
234249 struct perf_hpp {
235250 char *buf;
236251 size_t size;
237252 const char *sep;
238253 void *ptr;
254
+ bool skip;
239255 };
240256
241257 struct perf_hpp_fmt {
....@@ -351,7 +367,7 @@
351367 void perf_hpp__reset_output_field(struct perf_hpp_list *list);
352368 void perf_hpp__append_sort_keys(struct perf_hpp_list *list);
353369 int perf_hpp__setup_hists_formats(struct perf_hpp_list *list,
354
- struct perf_evlist *evlist);
370
+ struct evlist *evlist);
355371
356372
357373 bool perf_hpp__is_sort_entry(struct perf_hpp_fmt *format);
....@@ -416,7 +432,7 @@
416432 : 0;
417433 }
418434
419
-struct perf_evlist;
435
+struct evlist;
420436
421437 struct hist_browser_timer {
422438 void (*timer)(void *arg);
....@@ -425,27 +441,48 @@
425441 };
426442
427443 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;
428453
429454 #ifdef HAVE_SLANG_SUPPORT
430455 #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,
432459 struct hist_browser_timer *hbt,
433460 struct annotation_options *annotation_opts);
434461
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,
436463 struct hist_browser_timer *hbt,
437464 struct annotation_options *annotation_opts);
438465
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,
440467 struct hist_browser_timer *hbt,
441468 float min_pcnt,
442469 struct perf_env *env,
443470 bool warn_lost_event,
444471 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);
446483 #else
447484 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,
449486 const char *help __maybe_unused,
450487 struct hist_browser_timer *hbt __maybe_unused,
451488 float min_pcnt __maybe_unused,
....@@ -456,7 +493,7 @@
456493 return 0;
457494 }
458495 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,
460497 struct hist_browser_timer *hbt __maybe_unused,
461498 struct annotation_options *annotation_options __maybe_unused)
462499 {
....@@ -464,14 +501,34 @@
464501 }
465502
466503 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,
468505 struct hist_browser_timer *hbt __maybe_unused,
469506 struct annotation_options *annotation_opts __maybe_unused)
470507 {
471508 return 0;
472509 }
473510
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)
475532 {
476533 return 0;
477534 }
....@@ -479,13 +536,15 @@
479536 #define K_LEFT -1000
480537 #define K_RIGHT -2000
481538 #define K_SWITCH_INPUT_DATA -3000
539
+#define K_RELOAD -4000
482540 #endif
483541
484542 unsigned int hists__sort_list_width(struct hists *hists);
485543 unsigned int hists__overhead_width(struct hists *hists);
486544
487545 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);
489548
490549 struct option;
491550 int parse_filter_percentage(const struct option *opt, const char *arg, int unset);