aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-07-20 13:42:52 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-07-23 07:55:59 -0400
commit8a6c5b261c1188379469807d84bfb1365d0f6823 (patch)
treeb18ac8d951c33a480bd7c0a743d341d0e9bf3e90 /tools
parent7a007ca90b7c465137de06795ef4d5faa10f459e (diff)
perf sort: Make column width code per hists instance
They were globals, and since we support multiple hists and sessions at the same time, it doesn't make sense to calculate those values considereing all symbols in all sessions. Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/event.c34
-rw-r--r--tools/perf/util/hist.c115
-rw-r--r--tools/perf/util/hist.h27
-rw-r--r--tools/perf/util/newt.c9
-rw-r--r--tools/perf/util/sort.c17
-rw-r--r--tools/perf/util/sort.h6
-rw-r--r--tools/perf/util/symbol.c9
-rw-r--r--tools/perf/util/symbol.h2
8 files changed, 140 insertions, 79 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index d7f21d71eb69..121339f4360d 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -340,30 +340,29 @@ int event__synthesize_kernel_mmap(event__handler_t process,
340 return process(&ev, session); 340 return process(&ev, session);
341} 341}
342 342
343static void thread__comm_adjust(struct thread *self) 343static void thread__comm_adjust(struct thread *self, struct hists *hists)
344{ 344{
345 char *comm = self->comm; 345 char *comm = self->comm;
346 346
347 if (!symbol_conf.col_width_list_str && !symbol_conf.field_sep && 347 if (!symbol_conf.col_width_list_str && !symbol_conf.field_sep &&
348 (!symbol_conf.comm_list || 348 (!symbol_conf.comm_list ||
349 strlist__has_entry(symbol_conf.comm_list, comm))) { 349 strlist__has_entry(symbol_conf.comm_list, comm))) {
350 unsigned int slen = strlen(comm); 350 u16 slen = strlen(comm);
351 351
352 if (slen > comms__col_width) { 352 if (hists__new_col_len(hists, HISTC_COMM, slen))
353 comms__col_width = slen; 353 hists__set_col_len(hists, HISTC_THREAD, slen + 6);
354 threads__col_width = slen + 6;
355 }
356 } 354 }
357} 355}
358 356
359static int thread__set_comm_adjust(struct thread *self, const char *comm) 357static int thread__set_comm_adjust(struct thread *self, const char *comm,
358 struct hists *hists)
360{ 359{
361 int ret = thread__set_comm(self, comm); 360 int ret = thread__set_comm(self, comm);
362 361
363 if (ret) 362 if (ret)
364 return ret; 363 return ret;
365 364
366 thread__comm_adjust(self); 365 thread__comm_adjust(self, hists);
367 366
368 return 0; 367 return 0;
369} 368}
@@ -374,7 +373,8 @@ int event__process_comm(event_t *self, struct perf_session *session)
374 373
375 dump_printf(": %s:%d\n", self->comm.comm, self->comm.tid); 374 dump_printf(": %s:%d\n", self->comm.comm, self->comm.tid);
376 375
377 if (thread == NULL || thread__set_comm_adjust(thread, self->comm.comm)) { 376 if (thread == NULL || thread__set_comm_adjust(thread, self->comm.comm,
377 &session->hists)) {
378 dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n"); 378 dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n");
379 return -1; 379 return -1;
380 } 380 }
@@ -641,16 +641,13 @@ void thread__find_addr_location(struct thread *self,
641 al->sym = NULL; 641 al->sym = NULL;
642} 642}
643 643
644static void dso__calc_col_width(struct dso *self) 644static void dso__calc_col_width(struct dso *self, struct hists *hists)
645{ 645{
646 if (!symbol_conf.col_width_list_str && !symbol_conf.field_sep && 646 if (!symbol_conf.col_width_list_str && !symbol_conf.field_sep &&
647 (!symbol_conf.dso_list || 647 (!symbol_conf.dso_list ||
648 strlist__has_entry(symbol_conf.dso_list, self->name))) { 648 strlist__has_entry(symbol_conf.dso_list, self->name))) {
649 u16 slen = self->short_name_len; 649 u16 slen = dso__name_len(self);
650 if (verbose) 650 hists__new_col_len(hists, HISTC_DSO, slen);
651 slen = self->long_name_len;
652 if (dsos__col_width < slen)
653 dsos__col_width = slen;
654 } 651 }
655 652
656 self->slen_calculated = 1; 653 self->slen_calculated = 1;
@@ -729,16 +726,17 @@ int event__preprocess_sample(const event_t *self, struct perf_session *session,
729 * sampled. 726 * sampled.
730 */ 727 */
731 if (!sort_dso.elide && !al->map->dso->slen_calculated) 728 if (!sort_dso.elide && !al->map->dso->slen_calculated)
732 dso__calc_col_width(al->map->dso); 729 dso__calc_col_width(al->map->dso, &session->hists);
733 730
734 al->sym = map__find_symbol(al->map, al->addr, filter); 731 al->sym = map__find_symbol(al->map, al->addr, filter);
735 } else { 732 } else {
736 const unsigned int unresolved_col_width = BITS_PER_LONG / 4; 733 const unsigned int unresolved_col_width = BITS_PER_LONG / 4;
737 734
738 if (dsos__col_width < unresolved_col_width && 735 if (hists__col_len(&session->hists, HISTC_DSO) < unresolved_col_width &&
739 !symbol_conf.col_width_list_str && !symbol_conf.field_sep && 736 !symbol_conf.col_width_list_str && !symbol_conf.field_sep &&
740 !symbol_conf.dso_list) 737 !symbol_conf.dso_list)
741 dsos__col_width = unresolved_col_width; 738 hists__set_col_len(&session->hists, HISTC_DSO,
739 unresolved_col_width);
742 } 740 }
743 741
744 if (symbol_conf.sym_list && al->sym && 742 if (symbol_conf.sym_list && al->sym &&
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index d998d1d706eb..0bc67900352c 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -16,6 +16,50 @@ struct callchain_param callchain_param = {
16 .min_percent = 0.5 16 .min_percent = 0.5
17}; 17};
18 18
19u16 hists__col_len(struct hists *self, enum hist_column col)
20{
21 return self->col_len[col];
22}
23
24void hists__set_col_len(struct hists *self, enum hist_column col, u16 len)
25{
26 self->col_len[col] = len;
27}
28
29bool hists__new_col_len(struct hists *self, enum hist_column col, u16 len)
30{
31 if (len > hists__col_len(self, col)) {
32 hists__set_col_len(self, col, len);
33 return true;
34 }
35 return false;
36}
37
38static void hists__reset_col_len(struct hists *self)
39{
40 enum hist_column col;
41
42 for (col = 0; col < HISTC_NR_COLS; ++col)
43 hists__set_col_len(self, col, 0);
44}
45
46static void hists__calc_col_len(struct hists *self, struct hist_entry *h)
47{
48 u16 len;
49
50 if (h->ms.sym)
51 hists__new_col_len(self, HISTC_SYMBOL, h->ms.sym->namelen);
52
53 len = thread__comm_len(h->thread);
54 if (hists__new_col_len(self, HISTC_COMM, len))
55 hists__set_col_len(self, HISTC_THREAD, len + 6);
56
57 if (h->ms.map) {
58 len = dso__name_len(h->ms.map->dso);
59 hists__new_col_len(self, HISTC_DSO, len);
60 }
61}
62
19static void hist_entry__add_cpumode_period(struct hist_entry *self, 63static void hist_entry__add_cpumode_period(struct hist_entry *self,
20 unsigned int cpumode, u64 period) 64 unsigned int cpumode, u64 period)
21{ 65{
@@ -56,13 +100,12 @@ static struct hist_entry *hist_entry__new(struct hist_entry *template)
56 return self; 100 return self;
57} 101}
58 102
59static void hists__inc_nr_entries(struct hists *self, struct hist_entry *entry) 103static void hists__inc_nr_entries(struct hists *self, struct hist_entry *h)
60{ 104{
61 if (entry->filtered) 105 if (!h->filtered) {
62 return; 106 hists__calc_col_len(self, h);
63 if (entry->ms.sym && self->max_sym_namelen < entry->ms.sym->namelen) 107 ++self->nr_entries;
64 self->max_sym_namelen = entry->ms.sym->namelen; 108 }
65 ++self->nr_entries;
66} 109}
67 110
68static u8 symbol__parent_filter(const struct symbol *parent) 111static u8 symbol__parent_filter(const struct symbol *parent)
@@ -208,7 +251,7 @@ void hists__collapse_resort(struct hists *self)
208 tmp = RB_ROOT; 251 tmp = RB_ROOT;
209 next = rb_first(&self->entries); 252 next = rb_first(&self->entries);
210 self->nr_entries = 0; 253 self->nr_entries = 0;
211 self->max_sym_namelen = 0; 254 hists__reset_col_len(self);
212 255
213 while (next) { 256 while (next) {
214 n = rb_entry(next, struct hist_entry, rb_node); 257 n = rb_entry(next, struct hist_entry, rb_node);
@@ -265,7 +308,7 @@ void hists__output_resort(struct hists *self)
265 next = rb_first(&self->entries); 308 next = rb_first(&self->entries);
266 309
267 self->nr_entries = 0; 310 self->nr_entries = 0;
268 self->max_sym_namelen = 0; 311 hists__reset_col_len(self);
269 312
270 while (next) { 313 while (next) {
271 n = rb_entry(next, struct hist_entry, rb_node); 314 n = rb_entry(next, struct hist_entry, rb_node);
@@ -532,8 +575,9 @@ static size_t hist_entry_callchain__fprintf(FILE *fp, struct hist_entry *self,
532} 575}
533 576
534int hist_entry__snprintf(struct hist_entry *self, char *s, size_t size, 577int hist_entry__snprintf(struct hist_entry *self, char *s, size_t size,
535 struct hists *pair_hists, bool show_displacement, 578 struct hists *hists, struct hists *pair_hists,
536 long displacement, bool color, u64 session_total) 579 bool show_displacement, long displacement,
580 bool color, u64 session_total)
537{ 581{
538 struct sort_entry *se; 582 struct sort_entry *se;
539 u64 period, total, period_sys, period_us, period_guest_sys, period_guest_us; 583 u64 period, total, period_sys, period_us, period_guest_sys, period_guest_us;
@@ -637,24 +681,25 @@ int hist_entry__snprintf(struct hist_entry *self, char *s, size_t size,
637 681
638 ret += snprintf(s + ret, size - ret, "%s", sep ?: " "); 682 ret += snprintf(s + ret, size - ret, "%s", sep ?: " ");
639 ret += se->se_snprintf(self, s + ret, size - ret, 683 ret += se->se_snprintf(self, s + ret, size - ret,
640 se->se_width ? *se->se_width : 0); 684 hists__col_len(hists, se->se_width_idx));
641 } 685 }
642 686
643 return ret; 687 return ret;
644} 688}
645 689
646int hist_entry__fprintf(struct hist_entry *self, struct hists *pair_hists, 690int hist_entry__fprintf(struct hist_entry *self, struct hists *hists,
647 bool show_displacement, long displacement, FILE *fp, 691 struct hists *pair_hists, bool show_displacement,
648 u64 session_total) 692 long displacement, FILE *fp, u64 session_total)
649{ 693{
650 char bf[512]; 694 char bf[512];
651 hist_entry__snprintf(self, bf, sizeof(bf), pair_hists, 695 hist_entry__snprintf(self, bf, sizeof(bf), hists, pair_hists,
652 show_displacement, displacement, 696 show_displacement, displacement,
653 true, session_total); 697 true, session_total);
654 return fprintf(fp, "%s\n", bf); 698 return fprintf(fp, "%s\n", bf);
655} 699}
656 700
657static size_t hist_entry__fprintf_callchain(struct hist_entry *self, FILE *fp, 701static size_t hist_entry__fprintf_callchain(struct hist_entry *self,
702 struct hists *hists, FILE *fp,
658 u64 session_total) 703 u64 session_total)
659{ 704{
660 int left_margin = 0; 705 int left_margin = 0;
@@ -662,7 +707,7 @@ static size_t hist_entry__fprintf_callchain(struct hist_entry *self, FILE *fp,
662 if (sort__first_dimension == SORT_COMM) { 707 if (sort__first_dimension == SORT_COMM) {
663 struct sort_entry *se = list_first_entry(&hist_entry__sort_list, 708 struct sort_entry *se = list_first_entry(&hist_entry__sort_list,
664 typeof(*se), list); 709 typeof(*se), list);
665 left_margin = se->se_width ? *se->se_width : 0; 710 left_margin = hists__col_len(hists, se->se_width_idx);
666 left_margin -= thread__comm_len(self->thread); 711 left_margin -= thread__comm_len(self->thread);
667 } 712 }
668 713
@@ -733,17 +778,17 @@ size_t hists__fprintf(struct hists *self, struct hists *pair,
733 continue; 778 continue;
734 } 779 }
735 width = strlen(se->se_header); 780 width = strlen(se->se_header);
736 if (se->se_width) { 781 if (symbol_conf.col_width_list_str) {
737 if (symbol_conf.col_width_list_str) { 782 if (col_width) {
738 if (col_width) { 783 hists__set_col_len(self, se->se_width_idx,
739 *se->se_width = atoi(col_width); 784 atoi(col_width));
740 col_width = strchr(col_width, ','); 785 col_width = strchr(col_width, ',');
741 if (col_width) 786 if (col_width)
742 ++col_width; 787 ++col_width;
743 }
744 } 788 }
745 width = *se->se_width = max(*se->se_width, width);
746 } 789 }
790 if (!hists__new_col_len(self, se->se_width_idx, width))
791 width = hists__col_len(self, se->se_width_idx);
747 fprintf(fp, " %*s", width, se->se_header); 792 fprintf(fp, " %*s", width, se->se_header);
748 } 793 }
749 fprintf(fp, "\n"); 794 fprintf(fp, "\n");
@@ -766,9 +811,8 @@ size_t hists__fprintf(struct hists *self, struct hists *pair,
766 continue; 811 continue;
767 812
768 fprintf(fp, " "); 813 fprintf(fp, " ");
769 if (se->se_width) 814 width = hists__col_len(self, se->se_width_idx);
770 width = *se->se_width; 815 if (width == 0)
771 else
772 width = strlen(se->se_header); 816 width = strlen(se->se_header);
773 for (i = 0; i < width; i++) 817 for (i = 0; i < width; i++)
774 fprintf(fp, "."); 818 fprintf(fp, ".");
@@ -788,12 +832,12 @@ print_entries:
788 displacement = 0; 832 displacement = 0;
789 ++position; 833 ++position;
790 } 834 }
791 ret += hist_entry__fprintf(h, pair, show_displacement, 835 ret += hist_entry__fprintf(h, self, pair, show_displacement,
792 displacement, fp, self->stats.total_period); 836 displacement, fp, self->stats.total_period);
793 837
794 if (symbol_conf.use_callchain) 838 if (symbol_conf.use_callchain)
795 ret += hist_entry__fprintf_callchain(h, fp, self->stats.total_period); 839 ret += hist_entry__fprintf_callchain(h, self, fp,
796 840 self->stats.total_period);
797 if (h->ms.map == NULL && verbose > 1) { 841 if (h->ms.map == NULL && verbose > 1) {
798 __map_groups__fprintf_maps(&h->thread->mg, 842 __map_groups__fprintf_maps(&h->thread->mg,
799 MAP__FUNCTION, verbose, fp); 843 MAP__FUNCTION, verbose, fp);
@@ -817,8 +861,7 @@ static void hists__remove_entry_filter(struct hists *self, struct hist_entry *h,
817 self->stats.total_period += h->period; 861 self->stats.total_period += h->period;
818 self->stats.nr_events[PERF_RECORD_SAMPLE] += h->nr_events; 862 self->stats.nr_events[PERF_RECORD_SAMPLE] += h->nr_events;
819 863
820 if (h->ms.sym && self->max_sym_namelen < h->ms.sym->namelen) 864 hists__calc_col_len(self, h);
821 self->max_sym_namelen = h->ms.sym->namelen;
822} 865}
823 866
824void hists__filter_by_dso(struct hists *self, const struct dso *dso) 867void hists__filter_by_dso(struct hists *self, const struct dso *dso)
@@ -827,7 +870,7 @@ void hists__filter_by_dso(struct hists *self, const struct dso *dso)
827 870
828 self->nr_entries = self->stats.total_period = 0; 871 self->nr_entries = self->stats.total_period = 0;
829 self->stats.nr_events[PERF_RECORD_SAMPLE] = 0; 872 self->stats.nr_events[PERF_RECORD_SAMPLE] = 0;
830 self->max_sym_namelen = 0; 873 hists__reset_col_len(self);
831 874
832 for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) { 875 for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) {
833 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); 876 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
@@ -850,7 +893,7 @@ void hists__filter_by_thread(struct hists *self, const struct thread *thread)
850 893
851 self->nr_entries = self->stats.total_period = 0; 894 self->nr_entries = self->stats.total_period = 0;
852 self->stats.nr_events[PERF_RECORD_SAMPLE] = 0; 895 self->stats.nr_events[PERF_RECORD_SAMPLE] = 0;
853 self->max_sym_namelen = 0; 896 hists__reset_col_len(self);
854 897
855 for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) { 898 for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) {
856 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); 899 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 83fa33a7b38b..92962b2f579b 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -56,6 +56,16 @@ struct events_stats {
56 u32 nr_unknown_events; 56 u32 nr_unknown_events;
57}; 57};
58 58
59enum hist_column {
60 HISTC_SYMBOL,
61 HISTC_DSO,
62 HISTC_THREAD,
63 HISTC_COMM,
64 HISTC_PARENT,
65 HISTC_CPU,
66 HISTC_NR_COLS, /* Last entry */
67};
68
59struct hists { 69struct hists {
60 struct rb_node rb_node; 70 struct rb_node rb_node;
61 struct rb_root entries; 71 struct rb_root entries;
@@ -64,7 +74,7 @@ struct hists {
64 u64 config; 74 u64 config;
65 u64 event_stream; 75 u64 event_stream;
66 u32 type; 76 u32 type;
67 u32 max_sym_namelen; 77 u16 col_len[HISTC_NR_COLS];
68}; 78};
69 79
70struct hist_entry *__hists__add_entry(struct hists *self, 80struct hist_entry *__hists__add_entry(struct hists *self,
@@ -72,12 +82,13 @@ struct hist_entry *__hists__add_entry(struct hists *self,
72 struct symbol *parent, u64 period); 82 struct symbol *parent, u64 period);
73extern int64_t hist_entry__cmp(struct hist_entry *, struct hist_entry *); 83extern int64_t hist_entry__cmp(struct hist_entry *, struct hist_entry *);
74extern int64_t hist_entry__collapse(struct hist_entry *, struct hist_entry *); 84extern int64_t hist_entry__collapse(struct hist_entry *, struct hist_entry *);
75int hist_entry__fprintf(struct hist_entry *self, struct hists *pair_hists, 85int hist_entry__fprintf(struct hist_entry *self, struct hists *hists,
76 bool show_displacement, long displacement, FILE *fp, 86 struct hists *pair_hists, bool show_displacement,
77 u64 total); 87 long displacement, FILE *fp, u64 total);
78int hist_entry__snprintf(struct hist_entry *self, char *bf, size_t size, 88int hist_entry__snprintf(struct hist_entry *self, char *bf, size_t size,
79 struct hists *pair_hists, bool show_displacement, 89 struct hists *hists, struct hists *pair_hists,
80 long displacement, bool color, u64 total); 90 bool show_displacement, long displacement,
91 bool color, u64 total);
81void hist_entry__free(struct hist_entry *); 92void hist_entry__free(struct hist_entry *);
82 93
83void hists__output_resort(struct hists *self); 94void hists__output_resort(struct hists *self);
@@ -95,6 +106,10 @@ int hist_entry__annotate(struct hist_entry *self, struct list_head *head);
95void hists__filter_by_dso(struct hists *self, const struct dso *dso); 106void hists__filter_by_dso(struct hists *self, const struct dso *dso);
96void hists__filter_by_thread(struct hists *self, const struct thread *thread); 107void hists__filter_by_thread(struct hists *self, const struct thread *thread);
97 108
109u16 hists__col_len(struct hists *self, enum hist_column col);
110void hists__set_col_len(struct hists *self, enum hist_column col, u16 len);
111bool hists__new_col_len(struct hists *self, enum hist_column col, u16 len);
112
98#ifdef NO_NEWT_SUPPORT 113#ifdef NO_NEWT_SUPPORT
99static inline int hists__browse(struct hists *self __used, 114static inline int hists__browse(struct hists *self __used,
100 const char *helpline __used, 115 const char *helpline __used,
diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c
index 7979003adeaf..ab6eb368cbf5 100644
--- a/tools/perf/util/newt.c
+++ b/tools/perf/util/newt.c
@@ -692,7 +692,8 @@ static void hist_entry__append_callchain_browser(struct hist_entry *self,
692} 692}
693 693
694static size_t hist_entry__append_browser(struct hist_entry *self, 694static size_t hist_entry__append_browser(struct hist_entry *self,
695 newtComponent tree, u64 total) 695 newtComponent tree,
696 struct hists *hists)
696{ 697{
697 char s[256]; 698 char s[256];
698 size_t ret; 699 size_t ret;
@@ -700,8 +701,8 @@ static size_t hist_entry__append_browser(struct hist_entry *self,
700 if (symbol_conf.exclude_other && !self->parent) 701 if (symbol_conf.exclude_other && !self->parent)
701 return 0; 702 return 0;
702 703
703 ret = hist_entry__snprintf(self, s, sizeof(s), NULL, 704 ret = hist_entry__snprintf(self, s, sizeof(s), hists, NULL,
704 false, 0, false, total); 705 false, 0, false, hists->stats.total_period);
705 if (symbol_conf.use_callchain) { 706 if (symbol_conf.use_callchain) {
706 int indexes[2]; 707 int indexes[2];
707 708
@@ -842,7 +843,7 @@ static int hist_browser__populate(struct hist_browser *self, struct hists *hists
842 if (h->filtered) 843 if (h->filtered)
843 continue; 844 continue;
844 845
845 len = hist_entry__append_browser(h, self->tree, hists->stats.total_period); 846 len = hist_entry__append_browser(h, self->tree, hists);
846 if (len > max_len) 847 if (len > max_len)
847 max_len = len; 848 max_len = len;
848 if (symbol_conf.use_callchain) 849 if (symbol_conf.use_callchain)
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index c27b4b03fbc1..1c61a4f4aa8a 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1,4 +1,5 @@
1#include "sort.h" 1#include "sort.h"
2#include "hist.h"
2 3
3regex_t parent_regex; 4regex_t parent_regex;
4const char default_parent_pattern[] = "^sys_|^do_page_fault"; 5const char default_parent_pattern[] = "^sys_|^do_page_fault";
@@ -10,11 +11,6 @@ int sort__has_parent = 0;
10 11
11enum sort_type sort__first_dimension; 12enum sort_type sort__first_dimension;
12 13
13unsigned int dsos__col_width;
14unsigned int comms__col_width;
15unsigned int threads__col_width;
16unsigned int cpus__col_width;
17static unsigned int parent_symbol__col_width;
18char * field_sep; 14char * field_sep;
19 15
20LIST_HEAD(hist_entry__sort_list); 16LIST_HEAD(hist_entry__sort_list);
@@ -36,7 +32,7 @@ struct sort_entry sort_thread = {
36 .se_header = "Command: Pid", 32 .se_header = "Command: Pid",
37 .se_cmp = sort__thread_cmp, 33 .se_cmp = sort__thread_cmp,
38 .se_snprintf = hist_entry__thread_snprintf, 34 .se_snprintf = hist_entry__thread_snprintf,
39 .se_width = &threads__col_width, 35 .se_width_idx = HISTC_THREAD,
40}; 36};
41 37
42struct sort_entry sort_comm = { 38struct sort_entry sort_comm = {
@@ -44,34 +40,35 @@ struct sort_entry sort_comm = {
44 .se_cmp = sort__comm_cmp, 40 .se_cmp = sort__comm_cmp,
45 .se_collapse = sort__comm_collapse, 41 .se_collapse = sort__comm_collapse,
46 .se_snprintf = hist_entry__comm_snprintf, 42 .se_snprintf = hist_entry__comm_snprintf,
47 .se_width = &comms__col_width, 43 .se_width_idx = HISTC_COMM,
48}; 44};
49 45
50struct sort_entry sort_dso = { 46struct sort_entry sort_dso = {
51 .se_header = "Shared Object", 47 .se_header = "Shared Object",
52 .se_cmp = sort__dso_cmp, 48 .se_cmp = sort__dso_cmp,
53 .se_snprintf = hist_entry__dso_snprintf, 49 .se_snprintf = hist_entry__dso_snprintf,
54 .se_width = &dsos__col_width, 50 .se_width_idx = HISTC_DSO,
55}; 51};
56 52
57struct sort_entry sort_sym = { 53struct sort_entry sort_sym = {
58 .se_header = "Symbol", 54 .se_header = "Symbol",
59 .se_cmp = sort__sym_cmp, 55 .se_cmp = sort__sym_cmp,
60 .se_snprintf = hist_entry__sym_snprintf, 56 .se_snprintf = hist_entry__sym_snprintf,
57 .se_width_idx = HISTC_SYMBOL,
61}; 58};
62 59
63struct sort_entry sort_parent = { 60struct sort_entry sort_parent = {
64 .se_header = "Parent symbol", 61 .se_header = "Parent symbol",
65 .se_cmp = sort__parent_cmp, 62 .se_cmp = sort__parent_cmp,
66 .se_snprintf = hist_entry__parent_snprintf, 63 .se_snprintf = hist_entry__parent_snprintf,
67 .se_width = &parent_symbol__col_width, 64 .se_width_idx = HISTC_PARENT,
68}; 65};
69 66
70struct sort_entry sort_cpu = { 67struct sort_entry sort_cpu = {
71 .se_header = "CPU", 68 .se_header = "CPU",
72 .se_cmp = sort__cpu_cmp, 69 .se_cmp = sort__cpu_cmp,
73 .se_snprintf = hist_entry__cpu_snprintf, 70 .se_snprintf = hist_entry__cpu_snprintf,
74 .se_width = &cpus__col_width, 71 .se_width_idx = HISTC_CPU,
75}; 72};
76 73
77struct sort_dimension { 74struct sort_dimension {
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 560c855417e4..03a1722e6d02 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -36,10 +36,6 @@ extern struct sort_entry sort_comm;
36extern struct sort_entry sort_dso; 36extern struct sort_entry sort_dso;
37extern struct sort_entry sort_sym; 37extern struct sort_entry sort_sym;
38extern struct sort_entry sort_parent; 38extern struct sort_entry sort_parent;
39extern unsigned int dsos__col_width;
40extern unsigned int comms__col_width;
41extern unsigned int threads__col_width;
42extern unsigned int cpus__col_width;
43extern enum sort_type sort__first_dimension; 39extern enum sort_type sort__first_dimension;
44 40
45struct hist_entry { 41struct hist_entry {
@@ -87,7 +83,7 @@ struct sort_entry {
87 int64_t (*se_collapse)(struct hist_entry *, struct hist_entry *); 83 int64_t (*se_collapse)(struct hist_entry *, struct hist_entry *);
88 int (*se_snprintf)(struct hist_entry *self, char *bf, size_t size, 84 int (*se_snprintf)(struct hist_entry *self, char *bf, size_t size,
89 unsigned int width); 85 unsigned int width);
90 unsigned int *se_width; 86 u8 se_width_idx;
91 bool elide; 87 bool elide;
92}; 88};
93 89
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 971d0a05d6b4..bc6e7e8c480d 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -12,6 +12,7 @@
12#include <fcntl.h> 12#include <fcntl.h>
13#include <unistd.h> 13#include <unistd.h>
14#include "build-id.h" 14#include "build-id.h"
15#include "debug.h"
15#include "symbol.h" 16#include "symbol.h"
16#include "strlist.h" 17#include "strlist.h"
17 18
@@ -40,6 +41,14 @@ struct symbol_conf symbol_conf = {
40 .try_vmlinux_path = true, 41 .try_vmlinux_path = true,
41}; 42};
42 43
44int dso__name_len(const struct dso *self)
45{
46 if (verbose)
47 return self->long_name_len;
48
49 return self->short_name_len;
50}
51
43bool dso__loaded(const struct dso *self, enum map_type type) 52bool dso__loaded(const struct dso *self, enum map_type type)
44{ 53{
45 return self->loaded & (1 << type); 54 return self->loaded & (1 << type);
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 80e569bbdecc..d436ee3d3a73 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -146,6 +146,8 @@ struct dso *dso__new(const char *name);
146struct dso *dso__new_kernel(const char *name); 146struct dso *dso__new_kernel(const char *name);
147void dso__delete(struct dso *self); 147void dso__delete(struct dso *self);
148 148
149int dso__name_len(const struct dso *self);
150
149bool dso__loaded(const struct dso *self, enum map_type type); 151bool dso__loaded(const struct dso *self, enum map_type type);
150bool dso__sorted_by_name(const struct dso *self, enum map_type type); 152bool dso__sorted_by_name(const struct dso *self, enum map_type type);
151 153