Lines Matching +full:left +full:- +full:right

1 // SPDX-License-Identifier: GPL-2.0
25 #include <traceevent/event-parse.h>
26 #include "mem-events.h"
29 #include "time-utils.h"
55 * -t, --field-separator
81 return size - 1; in repsep_snprintf()
90 return -1; in cmp_null()
95 /* --sort pid */
98 sort__thread_cmp(struct hist_entry *left, struct hist_entry *right) in sort__thread_cmp() argument
100 return right->thread->tid - left->thread->tid; in sort__thread_cmp()
106 const char *comm = thread__comm_str(he->thread); in hist_entry__thread_snprintf()
108 width = max(7U, width) - 8; in hist_entry__thread_snprintf()
109 return repsep_snprintf(bf, size, "%7d:%-*.*s", he->thread->tid, in hist_entry__thread_snprintf()
118 return -1; in hist_entry__thread_filter()
120 return th && he->thread != th; in hist_entry__thread_filter()
131 /* --sort comm */
139 sort__comm_cmp(struct hist_entry *left, struct hist_entry *right) in sort__comm_cmp() argument
141 return strcmp(comm__str(right->comm), comm__str(left->comm)); in sort__comm_cmp()
145 sort__comm_collapse(struct hist_entry *left, struct hist_entry *right) in sort__comm_collapse() argument
147 return strcmp(comm__str(right->comm), comm__str(left->comm)); in sort__comm_collapse()
151 sort__comm_sort(struct hist_entry *left, struct hist_entry *right) in sort__comm_sort() argument
153 return strcmp(comm__str(right->comm), comm__str(left->comm)); in sort__comm_sort()
159 return repsep_snprintf(bf, size, "%-*.*s", width, width, comm__str(he->comm)); in hist_entry__comm_snprintf()
172 /* --sort dso */
176 struct dso *dso_l = map_l ? map_l->dso : NULL; in _sort__dso_cmp()
177 struct dso *dso_r = map_r ? map_r->dso : NULL; in _sort__dso_cmp()
184 dso_name_l = dso_l->long_name; in _sort__dso_cmp()
185 dso_name_r = dso_r->long_name; in _sort__dso_cmp()
187 dso_name_l = dso_l->short_name; in _sort__dso_cmp()
188 dso_name_r = dso_r->short_name; in _sort__dso_cmp()
195 sort__dso_cmp(struct hist_entry *left, struct hist_entry *right) in sort__dso_cmp() argument
197 return _sort__dso_cmp(right->ms.map, left->ms.map); in sort__dso_cmp()
203 if (map && map->dso) { in _hist_entry__dso_snprintf()
204 const char *dso_name = verbose > 0 ? map->dso->long_name : in _hist_entry__dso_snprintf()
205 map->dso->short_name; in _hist_entry__dso_snprintf()
206 return repsep_snprintf(bf, size, "%-*.*s", width, width, dso_name); in _hist_entry__dso_snprintf()
209 return repsep_snprintf(bf, size, "%-*.*s", width, width, "[unknown]"); in _hist_entry__dso_snprintf()
215 return _hist_entry__dso_snprintf(he->ms.map, bf, size, width); in hist_entry__dso_snprintf()
223 return -1; in hist_entry__dso_filter()
225 return dso && (!he->ms.map || he->ms.map->dso != dso); in hist_entry__dso_filter()
236 /* --sort symbol */
240 return (int64_t)(right_ip - left_ip); in _sort__addr_cmp()
251 if (sym_l->inlined || sym_r->inlined) { in _sort__sym_cmp()
252 int ret = strcmp(sym_l->name, sym_r->name); in _sort__sym_cmp()
256 if ((sym_l->start <= sym_r->end) && (sym_l->end >= sym_r->start)) in _sort__sym_cmp()
260 if (sym_l->start != sym_r->start) in _sort__sym_cmp()
261 return (int64_t)(sym_r->start - sym_l->start); in _sort__sym_cmp()
263 return (int64_t)(sym_r->end - sym_l->end); in _sort__sym_cmp()
267 sort__sym_cmp(struct hist_entry *left, struct hist_entry *right) in sort__sym_cmp() argument
271 if (!left->ms.sym && !right->ms.sym) in sort__sym_cmp()
272 return _sort__addr_cmp(left->ip, right->ip); in sort__sym_cmp()
278 if (!hists__has(left->hists, dso) || hists__has(right->hists, dso)) { in sort__sym_cmp()
279 ret = sort__dso_cmp(left, right); in sort__sym_cmp()
284 return _sort__sym_cmp(left->ms.sym, right->ms.sym); in sort__sym_cmp()
288 sort__sym_sort(struct hist_entry *left, struct hist_entry *right) in sort__sym_sort() argument
290 if (!left->ms.sym || !right->ms.sym) in sort__sym_sort()
291 return cmp_null(left->ms.sym, right->ms.sym); in sort__sym_sort()
293 return strcmp(right->ms.sym->name, left->ms.sym->name); in sort__sym_sort()
300 struct symbol *sym = ms->sym; in _hist_entry__sym_snprintf()
301 struct map *map = ms->map; in _hist_entry__sym_snprintf()
305 char o = map ? dso__symtab_origin(map->dso) : '!'; in _hist_entry__sym_snprintf()
308 if (map && map->dso && map->dso->kernel in _hist_entry__sym_snprintf()
309 && map->dso->adjust_symbols) in _hist_entry__sym_snprintf()
310 rip = map->unmap_ip(map, ip); in _hist_entry__sym_snprintf()
312 ret += repsep_snprintf(bf, size, "%-#*llx %c ", in _hist_entry__sym_snprintf()
316 ret += repsep_snprintf(bf + ret, size - ret, "[%c] ", level); in _hist_entry__sym_snprintf()
318 if (sym->type == STT_OBJECT) { in _hist_entry__sym_snprintf()
319 ret += repsep_snprintf(bf + ret, size - ret, "%s", sym->name); in _hist_entry__sym_snprintf()
320 ret += repsep_snprintf(bf + ret, size - ret, "+0x%llx", in _hist_entry__sym_snprintf()
321 ip - map->unmap_ip(map, sym->start)); in _hist_entry__sym_snprintf()
323 ret += repsep_snprintf(bf + ret, size - ret, "%.*s", in _hist_entry__sym_snprintf()
324 width - ret, in _hist_entry__sym_snprintf()
325 sym->name); in _hist_entry__sym_snprintf()
326 if (sym->inlined) in _hist_entry__sym_snprintf()
327 ret += repsep_snprintf(bf + ret, size - ret, in _hist_entry__sym_snprintf()
332 ret += repsep_snprintf(bf + ret, size - ret, "%-#.*llx", in _hist_entry__sym_snprintf()
341 return _hist_entry__sym_snprintf(&he->ms, he->ip, in hist_entry__sym_snprintf()
342 he->level, bf, size, width); in hist_entry__sym_snprintf()
350 return -1; in hist_entry__sym_filter()
352 return sym && (!he->ms.sym || !strstr(he->ms.sym->name, sym)); in hist_entry__sym_filter()
364 /* --sort srcline */
368 return map__srcline(he->ms.map, he->ip, he->ms.sym); in hist_entry__srcline()
372 sort__srcline_cmp(struct hist_entry *left, struct hist_entry *right) in sort__srcline_cmp() argument
374 if (!left->srcline) in sort__srcline_cmp()
375 left->srcline = hist_entry__srcline(left); in sort__srcline_cmp()
376 if (!right->srcline) in sort__srcline_cmp()
377 right->srcline = hist_entry__srcline(right); in sort__srcline_cmp()
379 return strcmp(right->srcline, left->srcline); in sort__srcline_cmp()
385 if (!he->srcline) in hist_entry__srcline_snprintf()
386 he->srcline = hist_entry__srcline(he); in hist_entry__srcline_snprintf()
388 return repsep_snprintf(bf, size, "%-.*s", width, he->srcline); in hist_entry__srcline_snprintf()
398 /* --sort srcline_from */
402 return map__srcline(ams->ms.map, ams->al_addr, ams->ms.sym); in addr_map_symbol__srcline()
406 sort__srcline_from_cmp(struct hist_entry *left, struct hist_entry *right) in sort__srcline_from_cmp() argument
408 if (!left->branch_info->srcline_from) in sort__srcline_from_cmp()
409 left->branch_info->srcline_from = addr_map_symbol__srcline(&left->branch_info->from); in sort__srcline_from_cmp()
411 if (!right->branch_info->srcline_from) in sort__srcline_from_cmp()
412 right->branch_info->srcline_from = addr_map_symbol__srcline(&right->branch_info->from); in sort__srcline_from_cmp()
414 return strcmp(right->branch_info->srcline_from, left->branch_info->srcline_from); in sort__srcline_from_cmp()
420 return repsep_snprintf(bf, size, "%-*.*s", width, width, he->branch_info->srcline_from); in hist_entry__srcline_from_snprintf()
430 /* --sort srcline_to */
433 sort__srcline_to_cmp(struct hist_entry *left, struct hist_entry *right) in sort__srcline_to_cmp() argument
435 if (!left->branch_info->srcline_to) in sort__srcline_to_cmp()
436 left->branch_info->srcline_to = addr_map_symbol__srcline(&left->branch_info->to); in sort__srcline_to_cmp()
438 if (!right->branch_info->srcline_to) in sort__srcline_to_cmp()
439 right->branch_info->srcline_to = addr_map_symbol__srcline(&right->branch_info->to); in sort__srcline_to_cmp()
441 return strcmp(right->branch_info->srcline_to, left->branch_info->srcline_to); in sort__srcline_to_cmp()
447 return repsep_snprintf(bf, size, "%-*.*s", width, width, he->branch_info->srcline_to); in hist_entry__srcline_to_snprintf()
461 struct symbol *sym = he->ms.sym; in hist_entry__sym_ipc_snprintf()
467 return repsep_snprintf(bf, size, "%-*s", width, "-"); in hist_entry__sym_ipc_snprintf()
471 if (notes->hit_cycles) in hist_entry__sym_ipc_snprintf()
472 ipc = notes->hit_insn / ((double)notes->hit_cycles); in hist_entry__sym_ipc_snprintf()
474 if (notes->total_insn) { in hist_entry__sym_ipc_snprintf()
475 coverage = notes->cover_insn * 100.0 / in hist_entry__sym_ipc_snprintf()
476 ((double)notes->total_insn); in hist_entry__sym_ipc_snprintf()
479 snprintf(tmp, sizeof(tmp), "%-5.2f [%5.1f%%]", ipc, coverage); in hist_entry__sym_ipc_snprintf()
480 return repsep_snprintf(bf, size, "%-*s", width, tmp); in hist_entry__sym_ipc_snprintf()
497 snprintf(tmp, sizeof(tmp), "%-5s %2s", "-", "-"); in hist_entry__sym_ipc_null_snprintf()
498 return repsep_snprintf(bf, size, "%-*s", width, tmp); in hist_entry__sym_ipc_null_snprintf()
508 /* --sort srcfile */
515 struct map *map = e->ms.map; in hist_entry__get_srcfile()
520 sf = __get_srcline(map->dso, map__rip_2objdump(map, e->ip), in hist_entry__get_srcfile()
521 e->ms.sym, false, true, true, e->ip); in hist_entry__get_srcfile()
534 sort__srcfile_cmp(struct hist_entry *left, struct hist_entry *right) in sort__srcfile_cmp() argument
536 if (!left->srcfile) in sort__srcfile_cmp()
537 left->srcfile = hist_entry__get_srcfile(left); in sort__srcfile_cmp()
538 if (!right->srcfile) in sort__srcfile_cmp()
539 right->srcfile = hist_entry__get_srcfile(right); in sort__srcfile_cmp()
541 return strcmp(right->srcfile, left->srcfile); in sort__srcfile_cmp()
547 if (!he->srcfile) in hist_entry__srcfile_snprintf()
548 he->srcfile = hist_entry__get_srcfile(he); in hist_entry__srcfile_snprintf()
550 return repsep_snprintf(bf, size, "%-.*s", width, he->srcfile); in hist_entry__srcfile_snprintf()
560 /* --sort parent */
563 sort__parent_cmp(struct hist_entry *left, struct hist_entry *right) in sort__parent_cmp() argument
565 struct symbol *sym_l = left->parent; in sort__parent_cmp()
566 struct symbol *sym_r = right->parent; in sort__parent_cmp()
571 return strcmp(sym_r->name, sym_l->name); in sort__parent_cmp()
577 return repsep_snprintf(bf, size, "%-*.*s", width, width, in hist_entry__parent_snprintf()
578 he->parent ? he->parent->name : "[other]"); in hist_entry__parent_snprintf()
588 /* --sort cpu */
591 sort__cpu_cmp(struct hist_entry *left, struct hist_entry *right) in sort__cpu_cmp() argument
593 return right->cpu - left->cpu; in sort__cpu_cmp()
599 return repsep_snprintf(bf, size, "%*.*d", width, width, he->cpu); in hist_entry__cpu_snprintf()
609 /* --sort cgroup_id */
613 return (int64_t)(right_dev - left_dev); in _sort__cgroup_dev_cmp()
618 return (int64_t)(right_ino - left_ino); in _sort__cgroup_inode_cmp()
622 sort__cgroup_id_cmp(struct hist_entry *left, struct hist_entry *right) in sort__cgroup_id_cmp() argument
626 ret = _sort__cgroup_dev_cmp(right->cgroup_id.dev, left->cgroup_id.dev); in sort__cgroup_id_cmp()
630 return _sort__cgroup_inode_cmp(right->cgroup_id.ino, in sort__cgroup_id_cmp()
631 left->cgroup_id.ino); in sort__cgroup_id_cmp()
638 return repsep_snprintf(bf, size, "%lu/0x%lx", he->cgroup_id.dev, in hist_entry__cgroup_id_snprintf()
639 he->cgroup_id.ino); in hist_entry__cgroup_id_snprintf()
649 /* --sort cgroup */
652 sort__cgroup_cmp(struct hist_entry *left, struct hist_entry *right) in sort__cgroup_cmp() argument
654 return right->cgroup - left->cgroup; in sort__cgroup_cmp()
663 if (he->cgroup) { in hist_entry__cgroup_snprintf()
664 struct cgroup *cgrp = cgroup__find(he->ms.maps->machine->env, in hist_entry__cgroup_snprintf()
665 he->cgroup); in hist_entry__cgroup_snprintf()
667 cgrp_name = cgrp->name; in hist_entry__cgroup_snprintf()
682 /* --sort socket */
685 sort__socket_cmp(struct hist_entry *left, struct hist_entry *right) in sort__socket_cmp() argument
687 return right->socket - left->socket; in sort__socket_cmp()
693 return repsep_snprintf(bf, size, "%*.*d", width, width-3, he->socket); in hist_entry__socket_snprintf()
701 return -1; in hist_entry__socket_filter()
703 return sk >= 0 && he->socket != sk; in hist_entry__socket_filter()
714 /* --sort time */
717 sort__time_cmp(struct hist_entry *left, struct hist_entry *right) in sort__time_cmp() argument
719 return right->time - left->time; in sort__time_cmp()
728 timestamp__scnprintf_nsec(he->time, he_time, in hist_entry__time_snprintf()
731 timestamp__scnprintf_usec(he->time, he_time, in hist_entry__time_snprintf()
734 return repsep_snprintf(bf, size, "%-.*s", width, he_time); in hist_entry__time_snprintf()
744 /* --sort trace */
751 .data = he->raw_data, in get_trace_output()
752 .size = he->raw_size, in get_trace_output()
755 evsel = hists_to_evsel(he->hists); in get_trace_output()
759 tep_print_fields(&seq, he->raw_data, he->raw_size, in get_trace_output()
760 evsel->tp_format); in get_trace_output()
762 tep_print_event(evsel->tp_format->tep, in get_trace_output()
773 sort__trace_cmp(struct hist_entry *left, struct hist_entry *right) in sort__trace_cmp() argument
777 evsel = hists_to_evsel(left->hists); in sort__trace_cmp()
778 if (evsel->core.attr.type != PERF_TYPE_TRACEPOINT) in sort__trace_cmp()
781 if (left->trace_output == NULL) in sort__trace_cmp()
782 left->trace_output = get_trace_output(left); in sort__trace_cmp()
783 if (right->trace_output == NULL) in sort__trace_cmp()
784 right->trace_output = get_trace_output(right); in sort__trace_cmp()
786 return strcmp(right->trace_output, left->trace_output); in sort__trace_cmp()
794 evsel = hists_to_evsel(he->hists); in hist_entry__trace_snprintf()
795 if (evsel->core.attr.type != PERF_TYPE_TRACEPOINT) in hist_entry__trace_snprintf()
796 return scnprintf(bf, size, "%-.*s", width, "N/A"); in hist_entry__trace_snprintf()
798 if (he->trace_output == NULL) in hist_entry__trace_snprintf()
799 he->trace_output = get_trace_output(he); in hist_entry__trace_snprintf()
800 return repsep_snprintf(bf, size, "%-.*s", width, he->trace_output); in hist_entry__trace_snprintf()
813 sort__dso_from_cmp(struct hist_entry *left, struct hist_entry *right) in sort__dso_from_cmp() argument
815 if (!left->branch_info || !right->branch_info) in sort__dso_from_cmp()
816 return cmp_null(left->branch_info, right->branch_info); in sort__dso_from_cmp()
818 return _sort__dso_cmp(left->branch_info->from.ms.map, in sort__dso_from_cmp()
819 right->branch_info->from.ms.map); in sort__dso_from_cmp()
825 if (he->branch_info) in hist_entry__dso_from_snprintf()
826 return _hist_entry__dso_snprintf(he->branch_info->from.ms.map, in hist_entry__dso_from_snprintf()
829 return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A"); in hist_entry__dso_from_snprintf()
838 return -1; in hist_entry__dso_from_filter()
840 return dso && (!he->branch_info || !he->branch_info->from.ms.map || in hist_entry__dso_from_filter()
841 he->branch_info->from.ms.map->dso != dso); in hist_entry__dso_from_filter()
845 sort__dso_to_cmp(struct hist_entry *left, struct hist_entry *right) in sort__dso_to_cmp() argument
847 if (!left->branch_info || !right->branch_info) in sort__dso_to_cmp()
848 return cmp_null(left->branch_info, right->branch_info); in sort__dso_to_cmp()
850 return _sort__dso_cmp(left->branch_info->to.ms.map, in sort__dso_to_cmp()
851 right->branch_info->to.ms.map); in sort__dso_to_cmp()
857 if (he->branch_info) in hist_entry__dso_to_snprintf()
858 return _hist_entry__dso_snprintf(he->branch_info->to.ms.map, in hist_entry__dso_to_snprintf()
861 return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A"); in hist_entry__dso_to_snprintf()
870 return -1; in hist_entry__dso_to_filter()
872 return dso && (!he->branch_info || !he->branch_info->to.ms.map || in hist_entry__dso_to_filter()
873 he->branch_info->to.ms.map->dso != dso); in hist_entry__dso_to_filter()
877 sort__sym_from_cmp(struct hist_entry *left, struct hist_entry *right) in sort__sym_from_cmp() argument
879 struct addr_map_symbol *from_l = &left->branch_info->from; in sort__sym_from_cmp()
880 struct addr_map_symbol *from_r = &right->branch_info->from; in sort__sym_from_cmp()
882 if (!left->branch_info || !right->branch_info) in sort__sym_from_cmp()
883 return cmp_null(left->branch_info, right->branch_info); in sort__sym_from_cmp()
885 from_l = &left->branch_info->from; in sort__sym_from_cmp()
886 from_r = &right->branch_info->from; in sort__sym_from_cmp()
888 if (!from_l->ms.sym && !from_r->ms.sym) in sort__sym_from_cmp()
889 return _sort__addr_cmp(from_l->addr, from_r->addr); in sort__sym_from_cmp()
891 return _sort__sym_cmp(from_l->ms.sym, from_r->ms.sym); in sort__sym_from_cmp()
895 sort__sym_to_cmp(struct hist_entry *left, struct hist_entry *right) in sort__sym_to_cmp() argument
899 if (!left->branch_info || !right->branch_info) in sort__sym_to_cmp()
900 return cmp_null(left->branch_info, right->branch_info); in sort__sym_to_cmp()
902 to_l = &left->branch_info->to; in sort__sym_to_cmp()
903 to_r = &right->branch_info->to; in sort__sym_to_cmp()
905 if (!to_l->ms.sym && !to_r->ms.sym) in sort__sym_to_cmp()
906 return _sort__addr_cmp(to_l->addr, to_r->addr); in sort__sym_to_cmp()
908 return _sort__sym_cmp(to_l->ms.sym, to_r->ms.sym); in sort__sym_to_cmp()
914 if (he->branch_info) { in hist_entry__sym_from_snprintf()
915 struct addr_map_symbol *from = &he->branch_info->from; in hist_entry__sym_from_snprintf()
917 return _hist_entry__sym_snprintf(&from->ms, from->al_addr, in hist_entry__sym_from_snprintf()
918 from->al_level, bf, size, width); in hist_entry__sym_from_snprintf()
921 return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A"); in hist_entry__sym_from_snprintf()
927 if (he->branch_info) { in hist_entry__sym_to_snprintf()
928 struct addr_map_symbol *to = &he->branch_info->to; in hist_entry__sym_to_snprintf()
930 return _hist_entry__sym_snprintf(&to->ms, to->al_addr, in hist_entry__sym_to_snprintf()
931 to->al_level, bf, size, width); in hist_entry__sym_to_snprintf()
934 return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A"); in hist_entry__sym_to_snprintf()
943 return -1; in hist_entry__sym_from_filter()
945 return sym && !(he->branch_info && he->branch_info->from.ms.sym && in hist_entry__sym_from_filter()
946 strstr(he->branch_info->from.ms.sym->name, sym)); in hist_entry__sym_from_filter()
955 return -1; in hist_entry__sym_to_filter()
957 return sym && !(he->branch_info && he->branch_info->to.ms.sym && in hist_entry__sym_to_filter()
958 strstr(he->branch_info->to.ms.sym->name, sym)); in hist_entry__sym_to_filter()
997 struct symbol *sym = ms->sym; in _hist_entry__addr_snprintf()
998 struct map *map = ms->map; in _hist_entry__addr_snprintf()
1001 ret += repsep_snprintf(bf + ret, size - ret, "[%c] ", level); in _hist_entry__addr_snprintf()
1003 if (sym->type == STT_OBJECT) { in _hist_entry__addr_snprintf()
1004 ret += repsep_snprintf(bf + ret, size - ret, "%s", sym->name); in _hist_entry__addr_snprintf()
1005 ret += repsep_snprintf(bf + ret, size - ret, "+0x%llx", in _hist_entry__addr_snprintf()
1006 ip - map->unmap_ip(map, sym->start)); in _hist_entry__addr_snprintf()
1008 ret += repsep_snprintf(bf + ret, size - ret, "%.*s", in _hist_entry__addr_snprintf()
1009 width - ret, in _hist_entry__addr_snprintf()
1010 sym->name); in _hist_entry__addr_snprintf()
1011 offs = ip - sym->start; in _hist_entry__addr_snprintf()
1013 ret += repsep_snprintf(bf + ret, size - ret, "+0x%llx", offs); in _hist_entry__addr_snprintf()
1017 ret += repsep_snprintf(bf + ret, size - ret, "%-#.*llx", in _hist_entry__addr_snprintf()
1027 if (he->branch_info) { in hist_entry__addr_from_snprintf()
1028 struct addr_map_symbol *from = &he->branch_info->from; in hist_entry__addr_from_snprintf()
1030 return _hist_entry__addr_snprintf(&from->ms, from->al_addr, in hist_entry__addr_from_snprintf()
1031 he->level, bf, size, width); in hist_entry__addr_from_snprintf()
1034 return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A"); in hist_entry__addr_from_snprintf()
1040 if (he->branch_info) { in hist_entry__addr_to_snprintf()
1041 struct addr_map_symbol *to = &he->branch_info->to; in hist_entry__addr_to_snprintf()
1043 return _hist_entry__addr_snprintf(&to->ms, to->al_addr, in hist_entry__addr_to_snprintf()
1044 he->level, bf, size, width); in hist_entry__addr_to_snprintf()
1047 return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A"); in hist_entry__addr_to_snprintf()
1051 sort__addr_from_cmp(struct hist_entry *left, struct hist_entry *right) in sort__addr_from_cmp() argument
1057 if (!left->branch_info || !right->branch_info) in sort__addr_from_cmp()
1058 return cmp_null(left->branch_info, right->branch_info); in sort__addr_from_cmp()
1060 from_l = &left->branch_info->from; in sort__addr_from_cmp()
1061 from_r = &right->branch_info->from; in sort__addr_from_cmp()
1067 ret = _sort__dso_cmp(from_l->ms.map, from_r->ms.map); in sort__addr_from_cmp()
1071 return _sort__addr_cmp(from_l->addr, from_r->addr); in sort__addr_from_cmp()
1075 sort__addr_to_cmp(struct hist_entry *left, struct hist_entry *right) in sort__addr_to_cmp() argument
1081 if (!left->branch_info || !right->branch_info) in sort__addr_to_cmp()
1082 return cmp_null(left->branch_info, right->branch_info); in sort__addr_to_cmp()
1084 to_l = &left->branch_info->to; in sort__addr_to_cmp()
1085 to_r = &right->branch_info->to; in sort__addr_to_cmp()
1091 ret = _sort__dso_cmp(to_l->ms.map, to_r->ms.map); in sort__addr_to_cmp()
1095 return _sort__addr_cmp(to_l->addr, to_r->addr); in sort__addr_to_cmp()
1116 sort__mispredict_cmp(struct hist_entry *left, struct hist_entry *right) in sort__mispredict_cmp() argument
1120 if (!left->branch_info || !right->branch_info) in sort__mispredict_cmp()
1121 return cmp_null(left->branch_info, right->branch_info); in sort__mispredict_cmp()
1123 mp = left->branch_info->flags.mispred != right->branch_info->flags.mispred; in sort__mispredict_cmp()
1124 p = left->branch_info->flags.predicted != right->branch_info->flags.predicted; in sort__mispredict_cmp()
1132 if (he->branch_info) { in hist_entry__mispredict_snprintf()
1133 if (he->branch_info->flags.predicted) in hist_entry__mispredict_snprintf()
1135 else if (he->branch_info->flags.mispred) in hist_entry__mispredict_snprintf()
1139 return repsep_snprintf(bf, size, "%-*.*s", width, width, out); in hist_entry__mispredict_snprintf()
1143 sort__cycles_cmp(struct hist_entry *left, struct hist_entry *right) in sort__cycles_cmp() argument
1145 if (!left->branch_info || !right->branch_info) in sort__cycles_cmp()
1146 return cmp_null(left->branch_info, right->branch_info); in sort__cycles_cmp()
1148 return left->branch_info->flags.cycles - in sort__cycles_cmp()
1149 right->branch_info->flags.cycles; in sort__cycles_cmp()
1155 if (!he->branch_info) in hist_entry__cycles_snprintf()
1156 return scnprintf(bf, size, "%-.*s", width, "N/A"); in hist_entry__cycles_snprintf()
1157 if (he->branch_info->flags.cycles == 0) in hist_entry__cycles_snprintf()
1158 return repsep_snprintf(bf, size, "%-*s", width, "-"); in hist_entry__cycles_snprintf()
1159 return repsep_snprintf(bf, size, "%-*hd", width, in hist_entry__cycles_snprintf()
1160 he->branch_info->flags.cycles); in hist_entry__cycles_snprintf()
1170 /* --sort daddr_sym */
1172 sort__daddr_cmp(struct hist_entry *left, struct hist_entry *right) in sort__daddr_cmp() argument
1176 if (left->mem_info) in sort__daddr_cmp()
1177 l = left->mem_info->daddr.addr; in sort__daddr_cmp()
1178 if (right->mem_info) in sort__daddr_cmp()
1179 r = right->mem_info->daddr.addr; in sort__daddr_cmp()
1181 return (int64_t)(r - l); in sort__daddr_cmp()
1190 if (he->mem_info) { in hist_entry__daddr_snprintf()
1191 addr = he->mem_info->daddr.addr; in hist_entry__daddr_snprintf()
1192 ms = &he->mem_info->daddr.ms; in hist_entry__daddr_snprintf()
1194 return _hist_entry__sym_snprintf(ms, addr, he->level, bf, size, width); in hist_entry__daddr_snprintf()
1198 sort__iaddr_cmp(struct hist_entry *left, struct hist_entry *right) in sort__iaddr_cmp() argument
1202 if (left->mem_info) in sort__iaddr_cmp()
1203 l = left->mem_info->iaddr.addr; in sort__iaddr_cmp()
1204 if (right->mem_info) in sort__iaddr_cmp()
1205 r = right->mem_info->iaddr.addr; in sort__iaddr_cmp()
1207 return (int64_t)(r - l); in sort__iaddr_cmp()
1216 if (he->mem_info) { in hist_entry__iaddr_snprintf()
1217 addr = he->mem_info->iaddr.addr; in hist_entry__iaddr_snprintf()
1218 ms = &he->mem_info->iaddr.ms; in hist_entry__iaddr_snprintf()
1220 return _hist_entry__sym_snprintf(ms, addr, he->level, bf, size, width); in hist_entry__iaddr_snprintf()
1224 sort__dso_daddr_cmp(struct hist_entry *left, struct hist_entry *right) in sort__dso_daddr_cmp() argument
1229 if (left->mem_info) in sort__dso_daddr_cmp()
1230 map_l = left->mem_info->daddr.ms.map; in sort__dso_daddr_cmp()
1231 if (right->mem_info) in sort__dso_daddr_cmp()
1232 map_r = right->mem_info->daddr.ms.map; in sort__dso_daddr_cmp()
1242 if (he->mem_info) in hist_entry__dso_daddr_snprintf()
1243 map = he->mem_info->daddr.ms.map; in hist_entry__dso_daddr_snprintf()
1249 sort__locked_cmp(struct hist_entry *left, struct hist_entry *right) in sort__locked_cmp() argument
1254 if (left->mem_info) in sort__locked_cmp()
1255 data_src_l = left->mem_info->data_src; in sort__locked_cmp()
1259 if (right->mem_info) in sort__locked_cmp()
1260 data_src_r = right->mem_info->data_src; in sort__locked_cmp()
1264 return (int64_t)(data_src_r.mem_lock - data_src_l.mem_lock); in sort__locked_cmp()
1272 perf_mem__lck_scnprintf(out, sizeof(out), he->mem_info); in hist_entry__locked_snprintf()
1277 sort__tlb_cmp(struct hist_entry *left, struct hist_entry *right) in sort__tlb_cmp() argument
1282 if (left->mem_info) in sort__tlb_cmp()
1283 data_src_l = left->mem_info->data_src; in sort__tlb_cmp()
1287 if (right->mem_info) in sort__tlb_cmp()
1288 data_src_r = right->mem_info->data_src; in sort__tlb_cmp()
1292 return (int64_t)(data_src_r.mem_dtlb - data_src_l.mem_dtlb); in sort__tlb_cmp()
1300 perf_mem__tlb_scnprintf(out, sizeof(out), he->mem_info); in hist_entry__tlb_snprintf()
1301 return repsep_snprintf(bf, size, "%-*s", width, out); in hist_entry__tlb_snprintf()
1305 sort__lvl_cmp(struct hist_entry *left, struct hist_entry *right) in sort__lvl_cmp() argument
1310 if (left->mem_info) in sort__lvl_cmp()
1311 data_src_l = left->mem_info->data_src; in sort__lvl_cmp()
1315 if (right->mem_info) in sort__lvl_cmp()
1316 data_src_r = right->mem_info->data_src; in sort__lvl_cmp()
1320 return (int64_t)(data_src_r.mem_lvl - data_src_l.mem_lvl); in sort__lvl_cmp()
1328 perf_mem__lvl_scnprintf(out, sizeof(out), he->mem_info); in hist_entry__lvl_snprintf()
1329 return repsep_snprintf(bf, size, "%-*s", width, out); in hist_entry__lvl_snprintf()
1333 sort__snoop_cmp(struct hist_entry *left, struct hist_entry *right) in sort__snoop_cmp() argument
1338 if (left->mem_info) in sort__snoop_cmp()
1339 data_src_l = left->mem_info->data_src; in sort__snoop_cmp()
1343 if (right->mem_info) in sort__snoop_cmp()
1344 data_src_r = right->mem_info->data_src; in sort__snoop_cmp()
1348 return (int64_t)(data_src_r.mem_snoop - data_src_l.mem_snoop); in sort__snoop_cmp()
1356 perf_mem__snp_scnprintf(out, sizeof(out), he->mem_info); in hist_entry__snoop_snprintf()
1357 return repsep_snprintf(bf, size, "%-*s", width, out); in hist_entry__snoop_snprintf()
1361 sort__dcacheline_cmp(struct hist_entry *left, struct hist_entry *right) in sort__dcacheline_cmp() argument
1367 if (!left->mem_info) return -1; in sort__dcacheline_cmp()
1368 if (!right->mem_info) return 1; in sort__dcacheline_cmp()
1371 if (left->cpumode > right->cpumode) return -1; in sort__dcacheline_cmp()
1372 if (left->cpumode < right->cpumode) return 1; in sort__dcacheline_cmp()
1374 l_map = left->mem_info->daddr.ms.map; in sort__dcacheline_cmp()
1375 r_map = right->mem_info->daddr.ms.map; in sort__dcacheline_cmp()
1381 if (!l_map) return -1; in sort__dcacheline_cmp()
1384 rc = dso__cmp_id(l_map->dso, r_map->dso); in sort__dcacheline_cmp()
1391 * The kernel and non-zero major/minor mapped areas are in sort__dcacheline_cmp()
1395 if ((left->cpumode != PERF_RECORD_MISC_KERNEL) && in sort__dcacheline_cmp()
1396 (!(l_map->flags & MAP_SHARED)) && in sort__dcacheline_cmp()
1397 !l_map->dso->id.maj && !l_map->dso->id.min && in sort__dcacheline_cmp()
1398 !l_map->dso->id.ino && !l_map->dso->id.ino_generation) { in sort__dcacheline_cmp()
1401 if (left->thread->pid_ > right->thread->pid_) return -1; in sort__dcacheline_cmp()
1402 if (left->thread->pid_ < right->thread->pid_) return 1; in sort__dcacheline_cmp()
1406 /* al_addr does all the right addr - start + offset calculations */ in sort__dcacheline_cmp()
1407 l = cl_address(left->mem_info->daddr.al_addr); in sort__dcacheline_cmp()
1408 r = cl_address(right->mem_info->daddr.al_addr); in sort__dcacheline_cmp()
1410 if (l > r) return -1; in sort__dcacheline_cmp()
1422 char level = he->level; in hist_entry__dcacheline_snprintf()
1424 if (he->mem_info) { in hist_entry__dcacheline_snprintf()
1425 struct map *map = he->mem_info->daddr.ms.map; in hist_entry__dcacheline_snprintf()
1427 addr = cl_address(he->mem_info->daddr.al_addr); in hist_entry__dcacheline_snprintf()
1428 ms = &he->mem_info->daddr.ms; in hist_entry__dcacheline_snprintf()
1431 if ((he->cpumode != PERF_RECORD_MISC_KERNEL) && in hist_entry__dcacheline_snprintf()
1432 map && !(map->prot & PROT_EXEC) && in hist_entry__dcacheline_snprintf()
1433 (map->flags & MAP_SHARED) && in hist_entry__dcacheline_snprintf()
1434 (map->dso->id.maj || map->dso->id.min || in hist_entry__dcacheline_snprintf()
1435 map->dso->id.ino || map->dso->id.ino_generation)) in hist_entry__dcacheline_snprintf()
1451 sort__weight_cmp(struct hist_entry *left, struct hist_entry *right) in sort__weight_cmp() argument
1453 return left->weight - right->weight; in sort__weight_cmp()
1459 return repsep_snprintf(bf, size, "%-*llu", width, he->weight); in hist_entry__local_weight_snprintf()
1472 return repsep_snprintf(bf, size, "%-*llu", width, in hist_entry__global_weight_snprintf()
1473 he->weight * he->stat.nr_events); in hist_entry__global_weight_snprintf()
1484 sort__ins_lat_cmp(struct hist_entry *left, struct hist_entry *right) in sort__ins_lat_cmp() argument
1486 return left->ins_lat - right->ins_lat; in sort__ins_lat_cmp()
1492 return repsep_snprintf(bf, size, "%-*u", width, he->ins_lat); in hist_entry__local_ins_lat_snprintf()
1505 return repsep_snprintf(bf, size, "%-*u", width, in hist_entry__global_ins_lat_snprintf()
1506 he->ins_lat * he->stat.nr_events); in hist_entry__global_ins_lat_snprintf()
1517 sort__p_stage_cyc_cmp(struct hist_entry *left, struct hist_entry *right) in sort__p_stage_cyc_cmp() argument
1519 return left->p_stage_cyc - right->p_stage_cyc; in sort__p_stage_cyc_cmp()
1525 return repsep_snprintf(bf, size, "%-*u", width, in hist_entry__global_p_stage_cyc_snprintf()
1526 he->p_stage_cyc * he->stat.nr_events); in hist_entry__global_p_stage_cyc_snprintf()
1533 return repsep_snprintf(bf, size, "%-*u", width, he->p_stage_cyc); in hist_entry__p_stage_cyc_snprintf()
1607 sort__blocked_cmp(struct hist_entry *left, struct hist_entry *right) in sort__blocked_cmp() argument
1612 if (left->mem_info) in sort__blocked_cmp()
1613 data_src_l = left->mem_info->data_src; in sort__blocked_cmp()
1617 if (right->mem_info) in sort__blocked_cmp()
1618 data_src_r = right->mem_info->data_src; in sort__blocked_cmp()
1622 return (int64_t)(data_src_r.mem_blk - data_src_l.mem_blk); in sort__blocked_cmp()
1630 perf_mem__blk_scnprintf(out, sizeof(out), he->mem_info); in hist_entry__blocked_snprintf()
1642 sort__phys_daddr_cmp(struct hist_entry *left, struct hist_entry *right) in sort__phys_daddr_cmp() argument
1646 if (left->mem_info) in sort__phys_daddr_cmp()
1647 l = left->mem_info->daddr.phys_addr; in sort__phys_daddr_cmp()
1648 if (right->mem_info) in sort__phys_daddr_cmp()
1649 r = right->mem_info->daddr.phys_addr; in sort__phys_daddr_cmp()
1651 return (int64_t)(r - l); in sort__phys_daddr_cmp()
1661 addr = he->mem_info->daddr.phys_addr; in hist_entry__phys_daddr_snprintf()
1663 ret += repsep_snprintf(bf + ret, size - ret, "[%c] ", he->level); in hist_entry__phys_daddr_snprintf()
1665 ret += repsep_snprintf(bf + ret, size - ret, "%-#.*llx", len, addr); in hist_entry__phys_daddr_snprintf()
1667 ret += repsep_snprintf(bf + ret, size - ret, "%-*s", width - ret, ""); in hist_entry__phys_daddr_snprintf()
1683 sort__data_page_size_cmp(struct hist_entry *left, struct hist_entry *right) in sort__data_page_size_cmp() argument
1687 if (left->mem_info) in sort__data_page_size_cmp()
1688 l = left->mem_info->daddr.data_page_size; in sort__data_page_size_cmp()
1689 if (right->mem_info) in sort__data_page_size_cmp()
1690 r = right->mem_info->daddr.data_page_size; in sort__data_page_size_cmp()
1692 return (int64_t)(r - l); in sort__data_page_size_cmp()
1700 return repsep_snprintf(bf, size, "%-*s", width, in hist_entry__data_page_size_snprintf()
1701 get_page_size_name(he->mem_info->daddr.data_page_size, str)); in hist_entry__data_page_size_snprintf()
1712 sort__code_page_size_cmp(struct hist_entry *left, struct hist_entry *right) in sort__code_page_size_cmp() argument
1714 uint64_t l = left->code_page_size; in sort__code_page_size_cmp()
1715 uint64_t r = right->code_page_size; in sort__code_page_size_cmp()
1717 return (int64_t)(r - l); in sort__code_page_size_cmp()
1725 return repsep_snprintf(bf, size, "%-*s", width, in hist_entry__code_page_size_snprintf()
1726 get_page_size_name(he->code_page_size, str)); in hist_entry__code_page_size_snprintf()
1737 sort__abort_cmp(struct hist_entry *left, struct hist_entry *right) in sort__abort_cmp() argument
1739 if (!left->branch_info || !right->branch_info) in sort__abort_cmp()
1740 return cmp_null(left->branch_info, right->branch_info); in sort__abort_cmp()
1742 return left->branch_info->flags.abort != in sort__abort_cmp()
1743 right->branch_info->flags.abort; in sort__abort_cmp()
1751 if (he->branch_info) { in hist_entry__abort_snprintf()
1752 if (he->branch_info->flags.abort) in hist_entry__abort_snprintf()
1758 return repsep_snprintf(bf, size, "%-*s", width, out); in hist_entry__abort_snprintf()
1769 sort__in_tx_cmp(struct hist_entry *left, struct hist_entry *right) in sort__in_tx_cmp() argument
1771 if (!left->branch_info || !right->branch_info) in sort__in_tx_cmp()
1772 return cmp_null(left->branch_info, right->branch_info); in sort__in_tx_cmp()
1774 return left->branch_info->flags.in_tx != in sort__in_tx_cmp()
1775 right->branch_info->flags.in_tx; in sort__in_tx_cmp()
1783 if (he->branch_info) { in hist_entry__in_tx_snprintf()
1784 if (he->branch_info->flags.in_tx) in hist_entry__in_tx_snprintf()
1790 return repsep_snprintf(bf, size, "%-*s", width, out); in hist_entry__in_tx_snprintf()
1801 sort__transaction_cmp(struct hist_entry *left, struct hist_entry *right) in sort__transaction_cmp() argument
1803 return left->transaction - right->transaction; in sort__transaction_cmp()
1823 { PERF_TXN_CAPACITY_WRITE, "CAP-WRITE ", 1 },
1824 { PERF_TXN_CAPACITY_READ, "CAP-READ ", 0 },
1844 u64 t = he->transaction; in hist_entry__transaction_snprintf()
1862 return repsep_snprintf(bf, size, "%-*s", width, buf); in hist_entry__transaction_snprintf()
1872 /* --sort symbol_size */
1879 return size_l < size_r ? -1 : in _sort__sym_size_cmp()
1884 sort__sym_size_cmp(struct hist_entry *left, struct hist_entry *right) in sort__sym_size_cmp() argument
1886 return _sort__sym_size_cmp(right->ms.sym, left->ms.sym); in sort__sym_size_cmp()
1901 return _hist_entry__sym_size_snprintf(he->ms.sym, bf, size, width); in hist_entry__sym_size_snprintf()
1911 /* --sort dso_size */
1918 return size_l < size_r ? -1 : in _sort__dso_size_cmp()
1923 sort__dso_size_cmp(struct hist_entry *left, struct hist_entry *right) in sort__dso_size_cmp() argument
1925 return _sort__dso_size_cmp(right->ms.map, left->ms.map); in sort__dso_size_cmp()
1931 if (map && map->dso) in _hist_entry__dso_size_snprintf()
1941 return _hist_entry__dso_size_snprintf(he->ms.map, bf, size, width); in hist_entry__dso_size_snprintf()
1951 /* --sort dso_size */
1954 sort__addr_cmp(struct hist_entry *left, struct hist_entry *right) in sort__addr_cmp() argument
1956 u64 left_ip = left->ip; in sort__addr_cmp()
1957 u64 right_ip = right->ip; in sort__addr_cmp()
1958 struct map *left_map = left->ms.map; in sort__addr_cmp()
1959 struct map *right_map = right->ms.map; in sort__addr_cmp()
1962 left_ip = left_map->unmap_ip(left_map, left_ip); in sort__addr_cmp()
1964 right_ip = right_map->unmap_ip(right_map, right_ip); in sort__addr_cmp()
1972 u64 ip = he->ip; in hist_entry__addr_snprintf()
1973 struct map *map = he->ms.map; in hist_entry__addr_snprintf()
1976 ip = map->unmap_ip(map, ip); in hist_entry__addr_snprintf()
1978 return repsep_snprintf(bf, size, "%-#*llx", width, ip); in hist_entry__addr_snprintf()
2007 sd->entry->se_header = arch_perf_header_entry(sd->entry->se_header); in sort_dimension_add_dynamic_header()
2042 #define DIM(d, n, func) [d - __SORT_BRANCH_STACK] = { .name = n, .entry = &(func) }
2062 #define DIM(d, n, func) [d - __SORT_MEMORY_MODE] = { .name = n, .entry = &(func) }
2114 hists__new_col_len(hists, hse->se->se_width_idx, strlen(fmt->name)); in perf_hpp__reset_sort_width()
2122 size_t len = fmt->user_len; in __sort__hpp_header()
2127 len = hists__col_len(hists, hse->se->se_width_idx); in __sort__hpp_header()
2129 return scnprintf(hpp->buf, hpp->size, "%-*.*s", len, len, fmt->name); in __sort__hpp_header()
2137 size_t len = fmt->user_len; in __sort__hpp_width()
2142 len = hists__col_len(hists, hse->se->se_width_idx); in __sort__hpp_width()
2151 size_t len = fmt->user_len; in __sort__hpp_entry()
2156 len = hists__col_len(he->hists, hse->se->se_width_idx); in __sort__hpp_entry()
2158 return hse->se->se_snprintf(he, hpp->buf, hpp->size, len); in __sort__hpp_entry()
2167 return hse->se->se_cmp(a, b); in __sort__hpp_cmp()
2177 collapse_fn = hse->se->se_collapse ?: hse->se->se_cmp; in __sort__hpp_collapse()
2188 sort_fn = hse->se->se_sort ?: hse->se->se_cmp; in __sort__hpp_sort()
2194 return format->header == __sort__hpp_header; in perf_hpp__is_sort_entry()
2206 return hse->se == &sort_ ## key ; \
2229 return hse_a->se == hse_b->se; in MK_SORT_ENTRY_CHK()
2251 hse->se = sd->entry; in __sort_dimension__alloc_hpp()
2252 hse->hpp.name = sd->entry->se_header; in __sort_dimension__alloc_hpp()
2253 hse->hpp.header = __sort__hpp_header; in __sort_dimension__alloc_hpp()
2254 hse->hpp.width = __sort__hpp_width; in __sort_dimension__alloc_hpp()
2255 hse->hpp.entry = __sort__hpp_entry; in __sort_dimension__alloc_hpp()
2256 hse->hpp.color = NULL; in __sort_dimension__alloc_hpp()
2258 hse->hpp.cmp = __sort__hpp_cmp; in __sort_dimension__alloc_hpp()
2259 hse->hpp.collapse = __sort__hpp_collapse; in __sort_dimension__alloc_hpp()
2260 hse->hpp.sort = __sort__hpp_sort; in __sort_dimension__alloc_hpp()
2261 hse->hpp.equal = __sort__hpp_equal; in __sort_dimension__alloc_hpp()
2262 hse->hpp.free = hse_free; in __sort_dimension__alloc_hpp()
2264 INIT_LIST_HEAD(&hse->hpp.list); in __sort_dimension__alloc_hpp()
2265 INIT_LIST_HEAD(&hse->hpp.sort_list); in __sort_dimension__alloc_hpp()
2266 hse->hpp.elide = false; in __sort_dimension__alloc_hpp()
2267 hse->hpp.len = 0; in __sort_dimension__alloc_hpp()
2268 hse->hpp.user_len = 0; in __sort_dimension__alloc_hpp()
2269 hse->hpp.level = level; in __sort_dimension__alloc_hpp()
2284 fmt = memdup(hd->fmt, sizeof(*fmt)); in __hpp_dimension__alloc_hpp()
2286 INIT_LIST_HEAD(&fmt->list); in __hpp_dimension__alloc_hpp()
2287 INIT_LIST_HEAD(&fmt->sort_list); in __hpp_dimension__alloc_hpp()
2288 fmt->free = hpp_free; in __hpp_dimension__alloc_hpp()
2289 fmt->level = level; in __hpp_dimension__alloc_hpp()
2299 int ret = -1; in hist_entry__filter()
2302 perf_hpp_list__for_each_format(he->hpp_list, fmt) { in hist_entry__filter()
2307 if (hse->se->se_filter == NULL) in hist_entry__filter()
2312 * is applied. But it should skip non-matched filter types. in hist_entry__filter()
2314 r = hse->se->se_filter(he, type, arg); in hist_entry__filter()
2332 return -1; in __sort_dimension__add_hpp_sort()
2334 perf_hpp_list__register_sort_field(list, &hse->hpp); in __sort_dimension__add_hpp_sort()
2344 return -1; in __sort_dimension__add_hpp_output()
2346 perf_hpp_list__column_register(list, &hse->hpp); in __sort_dimension__add_hpp_output()
2360 if (!hde->hpp.len) { in hde_width()
2361 int len = hde->dynamic_len; in hde_width()
2362 int namelen = strlen(hde->field->name); in hde_width()
2363 int fieldlen = hde->field->size; in hde_width()
2368 if (!(hde->field->flags & TEP_FIELD_IS_STRING)) { in hde_width()
2370 fieldlen = hde->field->size * 2 + 2; in hde_width()
2375 hde->hpp.len = len; in hde_width()
2377 return hde->hpp.len; in hde_width()
2384 struct tep_format_field *field = hde->field; in update_dynamic_len()
2388 if (hde->raw_trace) in update_dynamic_len()
2392 if (!he->trace_output) in update_dynamic_len()
2393 he->trace_output = get_trace_output(he); in update_dynamic_len()
2395 namelen = strlen(field->name); in update_dynamic_len()
2396 str = he->trace_output; in update_dynamic_len()
2405 if (!strncmp(str, field->name, namelen)) { in update_dynamic_len()
2409 len = pos - str; in update_dynamic_len()
2411 if (len > hde->dynamic_len) in update_dynamic_len()
2412 hde->dynamic_len = len; in update_dynamic_len()
2429 size_t len = fmt->user_len; in __sort__hde_header()
2436 return scnprintf(hpp->buf, hpp->size, "%*.*s", len, len, hde->field->name); in __sort__hde_header()
2444 size_t len = fmt->user_len; in __sort__hde_width()
2460 return hists_to_evsel(hists) == hde->evsel; in perf_hpp__defined_dynamic_entry()
2467 size_t len = fmt->user_len; in __sort__hde_entry()
2479 if (hde->raw_trace) in __sort__hde_entry()
2482 if (!he->trace_output) in __sort__hde_entry()
2483 he->trace_output = get_trace_output(he); in __sort__hde_entry()
2485 field = hde->field; in __sort__hde_entry()
2486 namelen = strlen(field->name); in __sort__hde_entry()
2487 str = he->trace_output; in __sort__hde_entry()
2496 if (!strncmp(str, field->name, namelen)) { in __sort__hde_entry()
2498 str = strndup(str, pos - str); in __sort__hde_entry()
2501 return scnprintf(hpp->buf, hpp->size, in __sort__hde_entry()
2516 tep_print_field(&seq, he->raw_data, hde->field); in __sort__hde_entry()
2520 ret = scnprintf(hpp->buf, hpp->size, "%*.*s", len, len, str); in __sort__hde_entry()
2539 field = hde->field; in __sort__hde_cmp()
2540 if (field->flags & TEP_FIELD_IS_DYNAMIC) { in __sort__hde_cmp()
2543 tep_read_number_field(field, a->raw_data, &dyn); in __sort__hde_cmp()
2546 if (field->flags & TEP_FIELD_IS_RELATIVE) in __sort__hde_cmp()
2547 offset += field->offset + field->size; in __sort__hde_cmp()
2550 if (size > hde->dynamic_len) in __sort__hde_cmp()
2551 hde->dynamic_len = size; in __sort__hde_cmp()
2553 offset = field->offset; in __sort__hde_cmp()
2554 size = field->size; in __sort__hde_cmp()
2557 return memcmp(a->raw_data + offset, b->raw_data + offset, size); in __sort__hde_cmp()
2562 return fmt->cmp == __sort__hde_cmp; in perf_hpp__is_dynamic_entry()
2576 return hde_a->field == hde_b->field; in __sort__hde_equal()
2599 hde->evsel = evsel; in __alloc_dynamic_entry()
2600 hde->field = field; in __alloc_dynamic_entry()
2601 hde->dynamic_len = 0; in __alloc_dynamic_entry()
2603 hde->hpp.name = field->name; in __alloc_dynamic_entry()
2604 hde->hpp.header = __sort__hde_header; in __alloc_dynamic_entry()
2605 hde->hpp.width = __sort__hde_width; in __alloc_dynamic_entry()
2606 hde->hpp.entry = __sort__hde_entry; in __alloc_dynamic_entry()
2607 hde->hpp.color = NULL; in __alloc_dynamic_entry()
2609 hde->hpp.cmp = __sort__hde_cmp; in __alloc_dynamic_entry()
2610 hde->hpp.collapse = __sort__hde_cmp; in __alloc_dynamic_entry()
2611 hde->hpp.sort = __sort__hde_cmp; in __alloc_dynamic_entry()
2612 hde->hpp.equal = __sort__hde_equal; in __alloc_dynamic_entry()
2613 hde->hpp.free = hde_free; in __alloc_dynamic_entry()
2615 INIT_LIST_HEAD(&hde->hpp.list); in __alloc_dynamic_entry()
2616 INIT_LIST_HEAD(&hde->hpp.sort_list); in __alloc_dynamic_entry()
2617 hde->hpp.elide = false; in __alloc_dynamic_entry()
2618 hde->hpp.len = 0; in __alloc_dynamic_entry()
2619 hde->hpp.user_len = 0; in __alloc_dynamic_entry()
2620 hde->hpp.level = level; in __alloc_dynamic_entry()
2635 new_fmt = &new_hse->hpp; in perf_hpp_fmt__dup()
2642 new_fmt = &new_hde->hpp; in perf_hpp_fmt__dup()
2647 INIT_LIST_HEAD(&new_fmt->list); in perf_hpp_fmt__dup()
2648 INIT_LIST_HEAD(&new_fmt->sort_list); in perf_hpp_fmt__dup()
2693 if (nr > evlist->core.nr_entries) in find_evsel()
2697 while (--nr > 0) in find_evsel()
2706 if (full_name && !strcmp(pos->name, event_name)) in find_evsel()
2709 if (!full_name && strstr(pos->name, event_name)) { in find_evsel()
2712 event_name, evsel->name, pos->name); in find_evsel()
2730 return -ENOMEM; in __dynamic_dimension__add()
2732 hde->raw_trace = raw_trace; in __dynamic_dimension__add()
2734 perf_hpp__register_sort_field(&hde->hpp); in __dynamic_dimension__add()
2743 field = evsel->tp_format->format.fields; in add_evsel_fields()
2749 field = field->next; in add_evsel_fields()
2761 if (evsel->core.attr.type != PERF_TYPE_TRACEPOINT) in add_all_dynamic_fields()
2774 int ret = -ESRCH; in add_all_matching_fields()
2779 if (evsel->core.attr.type != PERF_TYPE_TRACEPOINT) in add_all_matching_fields()
2782 field = tep_find_any_field(evsel->tp_format, field_name); in add_all_matching_fields()
2803 return -ENOENT; in add_dynamic_entry()
2807 return -ENOMEM; in add_dynamic_entry()
2810 ret = -EINVAL; in add_dynamic_entry()
2817 ret = -EINVAL; in add_dynamic_entry()
2836 ret = -ENOENT; in add_dynamic_entry()
2840 if (evsel->core.attr.type != PERF_TYPE_TRACEPOINT) { in add_dynamic_entry()
2842 ret = -EINVAL; in add_dynamic_entry()
2849 field = tep_find_any_field(evsel->tp_format, field_name); in add_dynamic_entry()
2853 return -ENOENT; in add_dynamic_entry()
2868 if (sd->taken) in __sort_dimension__add()
2872 return -1; in __sort_dimension__add()
2874 if (sd->entry->se_collapse) in __sort_dimension__add()
2875 list->need_collapse = 1; in __sort_dimension__add()
2877 sd->taken = 1; in __sort_dimension__add()
2888 if (hd->taken) in __hpp_dimension__add()
2893 return -1; in __hpp_dimension__add()
2895 hd->taken = 1; in __hpp_dimension__add()
2903 if (sd->taken) in __sort_dimension__add_output()
2907 return -1; in __sort_dimension__add_output()
2909 sd->taken = 1; in __sort_dimension__add_output()
2918 if (hd->taken) in __hpp_dimension__add_output()
2923 return -1; in __hpp_dimension__add_output()
2925 hd->taken = 1; in __hpp_dimension__add_output()
2958 if (strncasecmp(tok, sd->name, strlen(tok))) in sort_dimension__add()
2962 if (!strcmp(dynamic_headers[j], sd->name)) in sort_dimension__add()
2966 if (sd->entry == &sort_parent) { in sort_dimension__add()
2973 return -EINVAL; in sort_dimension__add()
2975 list->parent = 1; in sort_dimension__add()
2976 } else if (sd->entry == &sort_sym) { in sort_dimension__add()
2977 list->sym = 1; in sort_dimension__add()
2985 sd->entry->se_collapse = sort__sym_sort; in sort_dimension__add()
2987 } else if (sd->entry == &sort_dso) { in sort_dimension__add()
2988 list->dso = 1; in sort_dimension__add()
2989 } else if (sd->entry == &sort_socket) { in sort_dimension__add()
2990 list->socket = 1; in sort_dimension__add()
2991 } else if (sd->entry == &sort_thread) { in sort_dimension__add()
2992 list->thread = 1; in sort_dimension__add()
2993 } else if (sd->entry == &sort_comm) { in sort_dimension__add()
2994 list->comm = 1; in sort_dimension__add()
3003 if (strncasecmp(tok, hd->name, strlen(tok))) in sort_dimension__add()
3012 if (strncasecmp(tok, sd->name, strlen(tok))) in sort_dimension__add()
3016 return -EINVAL; in sort_dimension__add()
3018 if (sd->entry == &sort_sym_from || sd->entry == &sort_sym_to) in sort_dimension__add()
3019 list->sym = 1; in sort_dimension__add()
3028 if (strncasecmp(tok, sd->name, strlen(tok))) in sort_dimension__add()
3032 return -EINVAL; in sort_dimension__add()
3034 if (sd->entry == &sort_mem_dcacheline && cacheline_size() == 0) in sort_dimension__add()
3035 return -EINVAL; in sort_dimension__add()
3037 if (sd->entry == &sort_mem_daddr_sym) in sort_dimension__add()
3038 list->sym = 1; in sort_dimension__add()
3047 return -ESRCH; in sort_dimension__add()
3079 if (ret == -EINVAL) { in setup_sort_list()
3081 …ui__error("The \"dcacheline\" --sort key needs to know the cacheline size and it couldn't be deter… in setup_sort_list()
3083 ui__error("Invalid --sort key: `%s'", tok); in setup_sort_list()
3085 } else if (ret == -ESRCH) { in setup_sort_list()
3086 ui__error("Unknown --sort key: `%s'", tok); in setup_sort_list()
3116 if (evsel->core.attr.type != PERF_TYPE_TRACEPOINT) { in get_default_sort_order()
3136 * Append '+'-prefixed sort order to the default sort in setup_sort_order()
3143 ui__error("Invalid --sort key: `+'"); in setup_sort_order()
3144 return -EINVAL; in setup_sort_order()
3153 pr_err("Not enough memory to set up --sort"); in setup_sort_order()
3154 return -ENOMEM; in setup_sort_order()
3218 return -ENOMEM; in __setup_sorting()
3228 return -ENOMEM; in __setup_sorting()
3248 if (hse->se->se_width_idx == idx) { in perf_hpp__set_elide()
3249 fmt->elide = elide; in perf_hpp__set_elide()
3260 strlist__entry(list, 0)->s); in __get_elide()
3312 fmt->elide = get_elide(hse->se->se_width_idx, output); in sort__setup_elide()
3323 if (!fmt->elide) in sort__setup_elide()
3331 fmt->elide = false; in sort__setup_elide()
3342 if (strncasecmp(tok, sd->name, strlen(tok))) in output_field_add()
3351 if (strncasecmp(tok, hd->name, strlen(tok))) in output_field_add()
3360 if (strncasecmp(tok, sd->name, strlen(tok))) in output_field_add()
3364 return -EINVAL; in output_field_add()
3372 if (strncasecmp(tok, sd->name, strlen(tok))) in output_field_add()
3376 return -EINVAL; in output_field_add()
3381 return -ESRCH; in output_field_add()
3392 if (ret == -EINVAL) { in setup_output_list()
3393 ui__error("Invalid --fields key: `%s'", tok); in setup_output_list()
3395 } else if (ret == -ESRCH) { in setup_output_list()
3396 ui__error("Unknown --fields key: `%s'", tok); in setup_output_list()
3429 int ret = -EINVAL; in __setup_output_field()
3437 return -ENOMEM; in __setup_output_field()
3444 ui__error("Invalid --fields key: `+'"); in __setup_output_field()
3464 err = sort_dimension__add(&perf_hpp_list, "parent", evlist, -1); in setup_sorting()
3486 /* setup hists-specific output fields */ in setup_sorting()
3488 return -1; in setup_sorting()