1dd68ada2SJohn Kacur #ifndef __PERF_SORT_H 2dd68ada2SJohn Kacur #define __PERF_SORT_H 3dd68ada2SJohn Kacur #include "../builtin.h" 4dd68ada2SJohn Kacur 5dd68ada2SJohn Kacur #include "util.h" 6dd68ada2SJohn Kacur 7dd68ada2SJohn Kacur #include "color.h" 8dd68ada2SJohn Kacur #include <linux/list.h> 9dd68ada2SJohn Kacur #include "cache.h" 10dd68ada2SJohn Kacur #include <linux/rbtree.h> 11dd68ada2SJohn Kacur #include "symbol.h" 12dd68ada2SJohn Kacur #include "string.h" 13dd68ada2SJohn Kacur #include "callchain.h" 14dd68ada2SJohn Kacur #include "strlist.h" 15dd68ada2SJohn Kacur #include "values.h" 16dd68ada2SJohn Kacur 17dd68ada2SJohn Kacur #include "../perf.h" 18dd68ada2SJohn Kacur #include "debug.h" 19dd68ada2SJohn Kacur #include "header.h" 20dd68ada2SJohn Kacur 21dd68ada2SJohn Kacur #include "parse-options.h" 22dd68ada2SJohn Kacur #include "parse-events.h" 23dd68ada2SJohn Kacur 24dd68ada2SJohn Kacur #include "thread.h" 25dd68ada2SJohn Kacur #include "sort.h" 26dd68ada2SJohn Kacur 27dd68ada2SJohn Kacur extern regex_t parent_regex; 28edb7c60eSArnaldo Carvalho de Melo extern const char *sort_order; 29edb7c60eSArnaldo Carvalho de Melo extern const char default_parent_pattern[]; 30edb7c60eSArnaldo Carvalho de Melo extern const char *parent_pattern; 31edb7c60eSArnaldo Carvalho de Melo extern const char default_sort_order[]; 32dd68ada2SJohn Kacur extern int sort__need_collapse; 33dd68ada2SJohn Kacur extern int sort__has_parent; 341af55640SNamhyung Kim extern int sort__has_sym; 35993ac88dSStephane Eranian extern int sort__branch_mode; 36dd68ada2SJohn Kacur extern struct sort_entry sort_comm; 37dd68ada2SJohn Kacur extern struct sort_entry sort_dso; 38dd68ada2SJohn Kacur extern struct sort_entry sort_sym; 39dd68ada2SJohn Kacur extern struct sort_entry sort_parent; 40a68c2c58SStephane Eranian extern struct sort_entry sort_dso_from; 41a68c2c58SStephane Eranian extern struct sort_entry sort_dso_to; 42a68c2c58SStephane Eranian extern struct sort_entry sort_sym_from; 43a68c2c58SStephane Eranian extern struct sort_entry sort_sym_to; 44a4fb581bSFrederic Weisbecker extern enum sort_type sort__first_dimension; 45dd68ada2SJohn Kacur 46b24c28f7SNamhyung Kim struct he_stat { 47b24c28f7SNamhyung Kim u64 period; 48b24c28f7SNamhyung Kim u64 period_sys; 49b24c28f7SNamhyung Kim u64 period_us; 50b24c28f7SNamhyung Kim u64 period_guest_sys; 51b24c28f7SNamhyung Kim u64 period_guest_us; 52b24c28f7SNamhyung Kim u32 nr_events; 53b24c28f7SNamhyung Kim }; 54b24c28f7SNamhyung Kim 5596c47f19SJiri Olsa struct hist_entry_diff { 5696c47f19SJiri Olsa bool computed; 5796c47f19SJiri Olsa 5896c47f19SJiri Olsa /* PERF_HPP__DISPL */ 5996c47f19SJiri Olsa int displacement; 6096c47f19SJiri Olsa 6196c47f19SJiri Olsa /* PERF_HPP__DELTA */ 6296c47f19SJiri Olsa double period_ratio_delta; 6396c47f19SJiri Olsa 6496c47f19SJiri Olsa /* PERF_HPP__RATIO */ 6596c47f19SJiri Olsa double period_ratio; 6696c47f19SJiri Olsa }; 6796c47f19SJiri Olsa 680f0cbf7aSArnaldo Carvalho de Melo /** 690f0cbf7aSArnaldo Carvalho de Melo * struct hist_entry - histogram entry 700f0cbf7aSArnaldo Carvalho de Melo * 710f0cbf7aSArnaldo Carvalho de Melo * @row_offset - offset from the first callchain expanded to appear on screen 720f0cbf7aSArnaldo Carvalho de Melo * @nr_rows - rows expanded in callchain, recalculated on folding/unfolding 730f0cbf7aSArnaldo Carvalho de Melo */ 74dd68ada2SJohn Kacur struct hist_entry { 751980c2ebSArnaldo Carvalho de Melo struct rb_node rb_node_in; 76dd68ada2SJohn Kacur struct rb_node rb_node; 77b24c28f7SNamhyung Kim struct he_stat stat; 7859fd5306SArnaldo Carvalho de Melo struct map_symbol ms; 79a5e29acaSArnaldo Carvalho de Melo struct thread *thread; 80dd68ada2SJohn Kacur u64 ip; 81f60f3593SArun Sharma s32 cpu; 820f0cbf7aSArnaldo Carvalho de Melo 8396c47f19SJiri Olsa struct hist_entry_diff diff; 8496c47f19SJiri Olsa 850f0cbf7aSArnaldo Carvalho de Melo /* XXX These two should move to some tree widget lib */ 860f0cbf7aSArnaldo Carvalho de Melo u16 row_offset; 870f0cbf7aSArnaldo Carvalho de Melo u16 nr_rows; 880f0cbf7aSArnaldo Carvalho de Melo 890f0cbf7aSArnaldo Carvalho de Melo bool init_have_children; 90dd68ada2SJohn Kacur char level; 91df71d95fSArnaldo Carvalho de Melo bool used; 92a5e29acaSArnaldo Carvalho de Melo u8 filtered; 93409a8be6SArnaldo Carvalho de Melo char *srcline; 94439d473bSArnaldo Carvalho de Melo struct symbol *parent; 9586a9eee0SArnaldo Carvalho de Melo unsigned long position; 96dd464345SJiri Olsa union { 9786a9eee0SArnaldo Carvalho de Melo struct hist_entry *pair; 98dd68ada2SJohn Kacur struct rb_root sorted_chain; 99dd68ada2SJohn Kacur }; 100b5387528SRoberto Agostino Vitillo struct branch_info *branch_info; 101ae359f19SJiri Olsa struct hists *hists; 102d2009c51SFrederic Weisbecker struct callchain_root callchain[0]; 10386a9eee0SArnaldo Carvalho de Melo }; 104dd68ada2SJohn Kacur 105a4fb581bSFrederic Weisbecker enum sort_type { 106a4fb581bSFrederic Weisbecker SORT_PID, 107a4fb581bSFrederic Weisbecker SORT_COMM, 108a4fb581bSFrederic Weisbecker SORT_DSO, 109a4fb581bSFrederic Weisbecker SORT_SYM, 110f60f3593SArun Sharma SORT_PARENT, 111f60f3593SArun Sharma SORT_CPU, 112b5387528SRoberto Agostino Vitillo SORT_DSO_FROM, 113b5387528SRoberto Agostino Vitillo SORT_DSO_TO, 114b5387528SRoberto Agostino Vitillo SORT_SYM_FROM, 115b5387528SRoberto Agostino Vitillo SORT_SYM_TO, 116b5387528SRoberto Agostino Vitillo SORT_MISPREDICT, 117409a8be6SArnaldo Carvalho de Melo SORT_SRCLINE, 118a4fb581bSFrederic Weisbecker }; 119a4fb581bSFrederic Weisbecker 120dd68ada2SJohn Kacur /* 121dd68ada2SJohn Kacur * configurable sorting bits 122dd68ada2SJohn Kacur */ 123dd68ada2SJohn Kacur 124dd68ada2SJohn Kacur struct sort_entry { 125dd68ada2SJohn Kacur struct list_head list; 126dd68ada2SJohn Kacur 127fcd14984SFrederic Weisbecker const char *se_header; 128dd68ada2SJohn Kacur 129fcd14984SFrederic Weisbecker int64_t (*se_cmp)(struct hist_entry *, struct hist_entry *); 130fcd14984SFrederic Weisbecker int64_t (*se_collapse)(struct hist_entry *, struct hist_entry *); 131fcd14984SFrederic Weisbecker int (*se_snprintf)(struct hist_entry *self, char *bf, size_t size, 132a4e3b956SArnaldo Carvalho de Melo unsigned int width); 1338a6c5b26SArnaldo Carvalho de Melo u8 se_width_idx; 134dd68ada2SJohn Kacur bool elide; 135dd68ada2SJohn Kacur }; 136dd68ada2SJohn Kacur 137dd68ada2SJohn Kacur extern struct sort_entry sort_thread; 138dd68ada2SJohn Kacur extern struct list_head hist_entry__sort_list; 139dd68ada2SJohn Kacur 140c8829c7aSArnaldo Carvalho de Melo void setup_sorting(const char * const usagestr[], const struct option *opts); 141dd68ada2SJohn Kacur extern int sort_dimension__add(const char *); 142c351c281SArnaldo Carvalho de Melo void sort_entry__setup_elide(struct sort_entry *self, struct strlist *list, 143c351c281SArnaldo Carvalho de Melo const char *list_name, FILE *fp); 144dd68ada2SJohn Kacur 145dd68ada2SJohn Kacur #endif /* __PERF_SORT_H */ 146