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; 34dd68ada2SJohn Kacur extern char *field_sep; 35dd68ada2SJohn Kacur extern struct sort_entry sort_comm; 36dd68ada2SJohn Kacur extern struct sort_entry sort_dso; 37dd68ada2SJohn Kacur extern struct sort_entry sort_sym; 38dd68ada2SJohn Kacur extern struct sort_entry sort_parent; 39a4fb581bSFrederic Weisbecker extern enum sort_type sort__first_dimension; 40dd68ada2SJohn Kacur 410f0cbf7aSArnaldo Carvalho de Melo /** 420f0cbf7aSArnaldo Carvalho de Melo * struct hist_entry - histogram entry 430f0cbf7aSArnaldo Carvalho de Melo * 440f0cbf7aSArnaldo Carvalho de Melo * @row_offset - offset from the first callchain expanded to appear on screen 450f0cbf7aSArnaldo Carvalho de Melo * @nr_rows - rows expanded in callchain, recalculated on folding/unfolding 460f0cbf7aSArnaldo Carvalho de Melo */ 47dd68ada2SJohn Kacur struct hist_entry { 48dd68ada2SJohn Kacur struct rb_node rb_node; 49c82ee828SArnaldo Carvalho de Melo u64 period; 50c82ee828SArnaldo Carvalho de Melo u64 period_sys; 51c82ee828SArnaldo Carvalho de Melo u64 period_us; 52c82ee828SArnaldo Carvalho de Melo u64 period_guest_sys; 53c82ee828SArnaldo Carvalho de Melo u64 period_guest_us; 5459fd5306SArnaldo Carvalho de Melo struct map_symbol ms; 55a5e29acaSArnaldo Carvalho de Melo struct thread *thread; 56dd68ada2SJohn Kacur u64 ip; 57f60f3593SArun Sharma s32 cpu; 58c82ee828SArnaldo Carvalho de Melo u32 nr_events; 590f0cbf7aSArnaldo Carvalho de Melo 600f0cbf7aSArnaldo Carvalho de Melo /* XXX These two should move to some tree widget lib */ 610f0cbf7aSArnaldo Carvalho de Melo u16 row_offset; 620f0cbf7aSArnaldo Carvalho de Melo u16 nr_rows; 630f0cbf7aSArnaldo Carvalho de Melo 640f0cbf7aSArnaldo Carvalho de Melo bool init_have_children; 65dd68ada2SJohn Kacur char level; 66a5e29acaSArnaldo Carvalho de Melo u8 filtered; 67439d473bSArnaldo Carvalho de Melo struct symbol *parent; 6886a9eee0SArnaldo Carvalho de Melo union { 6986a9eee0SArnaldo Carvalho de Melo unsigned long position; 7086a9eee0SArnaldo Carvalho de Melo struct hist_entry *pair; 71dd68ada2SJohn Kacur struct rb_root sorted_chain; 72dd68ada2SJohn Kacur }; 73b9fb9304SArnaldo Carvalho de Melo struct callchain_node callchain[0]; 7486a9eee0SArnaldo Carvalho de Melo }; 75dd68ada2SJohn Kacur 76a4fb581bSFrederic Weisbecker enum sort_type { 77a4fb581bSFrederic Weisbecker SORT_PID, 78a4fb581bSFrederic Weisbecker SORT_COMM, 79a4fb581bSFrederic Weisbecker SORT_DSO, 80a4fb581bSFrederic Weisbecker SORT_SYM, 81f60f3593SArun Sharma SORT_PARENT, 82f60f3593SArun Sharma SORT_CPU, 83a4fb581bSFrederic Weisbecker }; 84a4fb581bSFrederic Weisbecker 85dd68ada2SJohn Kacur /* 86dd68ada2SJohn Kacur * configurable sorting bits 87dd68ada2SJohn Kacur */ 88dd68ada2SJohn Kacur 89dd68ada2SJohn Kacur struct sort_entry { 90dd68ada2SJohn Kacur struct list_head list; 91dd68ada2SJohn Kacur 92fcd14984SFrederic Weisbecker const char *se_header; 93dd68ada2SJohn Kacur 94fcd14984SFrederic Weisbecker int64_t (*se_cmp)(struct hist_entry *, struct hist_entry *); 95fcd14984SFrederic Weisbecker int64_t (*se_collapse)(struct hist_entry *, struct hist_entry *); 96fcd14984SFrederic Weisbecker int (*se_snprintf)(struct hist_entry *self, char *bf, size_t size, 97a4e3b956SArnaldo Carvalho de Melo unsigned int width); 988a6c5b26SArnaldo Carvalho de Melo u8 se_width_idx; 99dd68ada2SJohn Kacur bool elide; 100dd68ada2SJohn Kacur }; 101dd68ada2SJohn Kacur 102dd68ada2SJohn Kacur extern struct sort_entry sort_thread; 103dd68ada2SJohn Kacur extern struct list_head hist_entry__sort_list; 104dd68ada2SJohn Kacur 105c8829c7aSArnaldo Carvalho de Melo void setup_sorting(const char * const usagestr[], const struct option *opts); 106c8829c7aSArnaldo Carvalho de Melo 107dd68ada2SJohn Kacur extern size_t sort__thread_print(FILE *, struct hist_entry *, unsigned int); 108dd68ada2SJohn Kacur extern size_t sort__comm_print(FILE *, struct hist_entry *, unsigned int); 109dd68ada2SJohn Kacur extern size_t sort__dso_print(FILE *, struct hist_entry *, unsigned int); 110dd68ada2SJohn Kacur extern size_t sort__sym_print(FILE *, struct hist_entry *, unsigned int __used); 111dd68ada2SJohn Kacur extern int64_t cmp_null(void *, void *); 112dd68ada2SJohn Kacur extern int64_t sort__thread_cmp(struct hist_entry *, struct hist_entry *); 113dd68ada2SJohn Kacur extern int64_t sort__comm_cmp(struct hist_entry *, struct hist_entry *); 114dd68ada2SJohn Kacur extern int64_t sort__comm_collapse(struct hist_entry *, struct hist_entry *); 115dd68ada2SJohn Kacur extern int64_t sort__dso_cmp(struct hist_entry *, struct hist_entry *); 116dd68ada2SJohn Kacur extern int64_t sort__sym_cmp(struct hist_entry *, struct hist_entry *); 117dd68ada2SJohn Kacur extern int64_t sort__parent_cmp(struct hist_entry *, struct hist_entry *); 118f60f3593SArun Sharma int64_t sort__cpu_cmp(struct hist_entry *left, struct hist_entry *right); 119dd68ada2SJohn Kacur extern size_t sort__parent_print(FILE *, struct hist_entry *, unsigned int); 120dd68ada2SJohn Kacur extern int sort_dimension__add(const char *); 121c351c281SArnaldo Carvalho de Melo void sort_entry__setup_elide(struct sort_entry *self, struct strlist *list, 122c351c281SArnaldo Carvalho de Melo const char *list_name, FILE *fp); 123dd68ada2SJohn Kacur 124dd68ada2SJohn Kacur #endif /* __PERF_SORT_H */ 125