Lines Matching +full:left +full:-
1 // SPDX-License-Identifier: GPL-2.0
25 #include "mem-events.h"
26 #include "mem-info.h"
28 #include "annotate-data.h"
30 #include "time-utils.h"
33 #include "trace-event.h"
38 #include <traceevent/event-parse.h>
68 * -t, --field-separator
94 return size - 1; in repsep_snprintf()
103 return -1; in cmp_null()
108 /* --sort pid */
111 sort__thread_cmp(struct hist_entry *left, struct hist_entry *right) in sort__thread_cmp() argument
113 return thread__tid(right->thread) - thread__tid(left->thread); in sort__thread_cmp()
119 const char *comm = thread__comm_str(he->thread); in hist_entry__thread_snprintf()
121 width = max(7U, width) - 8; in hist_entry__thread_snprintf()
122 return repsep_snprintf(bf, size, "%7d:%-*.*s", thread__tid(he->thread), in hist_entry__thread_snprintf()
131 return -1; in hist_entry__thread_filter()
133 return th && !RC_CHK_EQUAL(he->thread, th); in hist_entry__thread_filter()
144 /* --sort simd */
147 sort__simd_cmp(struct hist_entry *left, struct hist_entry *right) in sort__simd_cmp() argument
149 if (left->simd_flags.arch != right->simd_flags.arch) in sort__simd_cmp()
150 return (int64_t) left->simd_flags.arch - right->simd_flags.arch; in sort__simd_cmp()
152 return (int64_t) left->simd_flags.pred - right->simd_flags.pred; in sort__simd_cmp()
157 u64 arch = simd_flags->arch; in hist_entry__get_simd_name()
170 if (!he->simd_flags.arch) in hist_entry__simd_snprintf()
173 name = hist_entry__get_simd_name(&he->simd_flags); in hist_entry__simd_snprintf()
175 if (he->simd_flags.pred & SIMD_OP_FLAGS_PRED_EMPTY) in hist_entry__simd_snprintf()
177 else if (he->simd_flags.pred & SIMD_OP_FLAGS_PRED_PARTIAL) in hist_entry__simd_snprintf()
190 /* --sort comm */
198 sort__comm_cmp(struct hist_entry *left, struct hist_entry *right) in sort__comm_cmp() argument
200 return strcmp(comm__str(right->comm), comm__str(left->comm)); in sort__comm_cmp()
204 sort__comm_collapse(struct hist_entry *left, struct hist_entry *right) in sort__comm_collapse() argument
206 return strcmp(comm__str(right->comm), comm__str(left->comm)); in sort__comm_collapse()
210 sort__comm_sort(struct hist_entry *left, struct hist_entry *right) in sort__comm_sort() argument
212 return strcmp(comm__str(right->comm), comm__str(left->comm)); in sort__comm_sort()
218 return repsep_snprintf(bf, size, "%-*.*s", width, width, comm__str(he->comm)); in hist_entry__comm_snprintf()
231 /* --sort dso */
254 sort__dso_cmp(struct hist_entry *left, struct hist_entry *right) in sort__dso_cmp() argument
256 return _sort__dso_cmp(right->ms.map, left->ms.map); in sort__dso_cmp()
268 return repsep_snprintf(bf, size, "%-*.*s", width, width, dso_name); in _hist_entry__dso_snprintf()
274 return _hist_entry__dso_snprintf(he->ms.map, bf, size, width); in hist_entry__dso_snprintf()
282 return -1; in hist_entry__dso_filter()
284 return dso && (!he->ms.map || map__dso(he->ms.map) != dso); in hist_entry__dso_filter()
295 /* --sort symbol */
299 return (int64_t)(right_ip - left_ip); in _sort__addr_cmp()
310 if (sym_l->inlined || sym_r->inlined) { in _sort__sym_cmp()
311 int ret = strcmp(sym_l->name, sym_r->name); in _sort__sym_cmp()
315 if ((sym_l->start <= sym_r->end) && (sym_l->end >= sym_r->start)) in _sort__sym_cmp()
319 if (sym_l->start != sym_r->start) in _sort__sym_cmp()
320 return (int64_t)(sym_r->start - sym_l->start); in _sort__sym_cmp()
322 return (int64_t)(sym_r->end - sym_l->end); in _sort__sym_cmp()
326 sort__sym_cmp(struct hist_entry *left, struct hist_entry *right) in sort__sym_cmp() argument
330 if (!left->ms.sym && !right->ms.sym) in sort__sym_cmp()
331 return _sort__addr_cmp(left->ip, right->ip); in sort__sym_cmp()
337 if (!hists__has(left->hists, dso)) { in sort__sym_cmp()
338 ret = sort__dso_cmp(left, right); in sort__sym_cmp()
343 return _sort__sym_cmp(left->ms.sym, right->ms.sym); in sort__sym_cmp()
347 sort__sym_sort(struct hist_entry *left, struct hist_entry *right) in sort__sym_sort() argument
349 if (!left->ms.sym || !right->ms.sym) in sort__sym_sort()
350 return cmp_null(left->ms.sym, right->ms.sym); in sort__sym_sort()
352 return strcmp(right->ms.sym->name, left->ms.sym->name); in sort__sym_sort()
359 struct symbol *sym = ms->sym; in _hist_entry__sym_snprintf()
360 struct map *map = ms->map; in _hist_entry__sym_snprintf()
371 ret += repsep_snprintf(bf, size, "%-#*llx %c ", in _hist_entry__sym_snprintf()
375 ret += repsep_snprintf(bf + ret, size - ret, "[%c] ", level); in _hist_entry__sym_snprintf()
377 if (sym->type == STT_OBJECT) { in _hist_entry__sym_snprintf()
378 ret += repsep_snprintf(bf + ret, size - ret, "%s", sym->name); in _hist_entry__sym_snprintf()
379 ret += repsep_snprintf(bf + ret, size - ret, "+0x%llx", in _hist_entry__sym_snprintf()
380 ip - map__unmap_ip(map, sym->start)); in _hist_entry__sym_snprintf()
382 ret += repsep_snprintf(bf + ret, size - ret, "%.*s", in _hist_entry__sym_snprintf()
383 width - ret, in _hist_entry__sym_snprintf()
384 sym->name); in _hist_entry__sym_snprintf()
385 if (sym->inlined) in _hist_entry__sym_snprintf()
386 ret += repsep_snprintf(bf + ret, size - ret, in _hist_entry__sym_snprintf()
391 ret += repsep_snprintf(bf + ret, size - ret, "%-#.*llx", in _hist_entry__sym_snprintf()
400 return _hist_entry__sym_snprintf(&he->ms, he->ip, in hist_entry__sym_snprintf()
401 he->level, bf, size, width); in hist_entry__sym_snprintf()
409 return -1; in hist_entry__sym_filter()
411 return sym && (!he->ms.sym || !strstr(he->ms.sym->name, sym)); in hist_entry__sym_filter()
423 /* --sort symoff */
426 sort__symoff_cmp(struct hist_entry *left, struct hist_entry *right) in sort__symoff_cmp() argument
430 ret = sort__sym_cmp(left, right); in sort__symoff_cmp()
434 return left->ip - right->ip; in sort__symoff_cmp()
438 sort__symoff_sort(struct hist_entry *left, struct hist_entry *right) in sort__symoff_sort() argument
442 ret = sort__sym_sort(left, right); in sort__symoff_sort()
446 return left->ip - right->ip; in sort__symoff_sort()
452 struct symbol *sym = he->ms.sym; in hist_entry__symoff_snprintf()
455 return repsep_snprintf(bf, size, "[%c] %-#.*llx", he->level, width - 4, he->ip); in hist_entry__symoff_snprintf()
457 return repsep_snprintf(bf, size, "[%c] %s+0x%llx", he->level, sym->name, he->ip - sym->start); in hist_entry__symoff_snprintf()
469 /* --sort srcline */
473 return map__srcline(he->ms.map, he->ip, he->ms.sym); in hist_entry__srcline()
477 sort__srcline_cmp(struct hist_entry *left, struct hist_entry *right) in sort__srcline_cmp() argument
481 ret = _sort__addr_cmp(left->ip, right->ip); in sort__srcline_cmp()
485 return sort__dso_cmp(left, right); in sort__srcline_cmp()
489 sort__srcline_collapse(struct hist_entry *left, struct hist_entry *right) in sort__srcline_collapse() argument
491 if (!left->srcline) in sort__srcline_collapse()
492 left->srcline = hist_entry__srcline(left); in sort__srcline_collapse()
493 if (!right->srcline) in sort__srcline_collapse()
494 right->srcline = hist_entry__srcline(right); in sort__srcline_collapse()
496 return strcmp(right->srcline, left->srcline); in sort__srcline_collapse()
500 sort__srcline_sort(struct hist_entry *left, struct hist_entry *right) in sort__srcline_sort() argument
502 return sort__srcline_collapse(left, right); in sort__srcline_sort()
508 if (!he->srcline) in sort__srcline_init()
509 he->srcline = hist_entry__srcline(he); in sort__srcline_init()
515 return repsep_snprintf(bf, size, "%-.*s", width, he->srcline); in hist_entry__srcline_snprintf()
528 /* --sort srcline_from */
532 return map__srcline(ams->ms.map, ams->al_addr, ams->ms.sym); in addr_map_symbol__srcline()
536 sort__srcline_from_cmp(struct hist_entry *left, struct hist_entry *right) in sort__srcline_from_cmp() argument
538 return left->branch_info->from.addr - right->branch_info->from.addr; in sort__srcline_from_cmp()
542 sort__srcline_from_collapse(struct hist_entry *left, struct hist_entry *right) in sort__srcline_from_collapse() argument
544 if (!left->branch_info->srcline_from) in sort__srcline_from_collapse()
545 left->branch_info->srcline_from = addr_map_symbol__srcline(&left->branch_info->from); in sort__srcline_from_collapse()
547 if (!right->branch_info->srcline_from) in sort__srcline_from_collapse()
548 right->branch_info->srcline_from = addr_map_symbol__srcline(&right->branch_info->from); in sort__srcline_from_collapse()
550 return strcmp(right->branch_info->srcline_from, left->branch_info->srcline_from); in sort__srcline_from_collapse()
554 sort__srcline_from_sort(struct hist_entry *left, struct hist_entry *right) in sort__srcline_from_sort() argument
556 return sort__srcline_from_collapse(left, right); in sort__srcline_from_sort()
561 if (!he->branch_info->srcline_from) in sort__srcline_from_init()
562 he->branch_info->srcline_from = addr_map_symbol__srcline(&he->branch_info->from); in sort__srcline_from_init()
568 return repsep_snprintf(bf, size, "%-*.*s", width, width, he->branch_info->srcline_from); in hist_entry__srcline_from_snprintf()
581 /* --sort srcline_to */
584 sort__srcline_to_cmp(struct hist_entry *left, struct hist_entry *right) in sort__srcline_to_cmp() argument
586 return left->branch_info->to.addr - right->branch_info->to.addr; in sort__srcline_to_cmp()
590 sort__srcline_to_collapse(struct hist_entry *left, struct hist_entry *right) in sort__srcline_to_collapse() argument
592 if (!left->branch_info->srcline_to) in sort__srcline_to_collapse()
593 left->branch_info->srcline_to = addr_map_symbol__srcline(&left->branch_info->to); in sort__srcline_to_collapse()
595 if (!right->branch_info->srcline_to) in sort__srcline_to_collapse()
596 right->branch_info->srcline_to = addr_map_symbol__srcline(&right->branch_info->to); in sort__srcline_to_collapse()
598 return strcmp(right->branch_info->srcline_to, left->branch_info->srcline_to); in sort__srcline_to_collapse()
602 sort__srcline_to_sort(struct hist_entry *left, struct hist_entry *right) in sort__srcline_to_sort() argument
604 return sort__srcline_to_collapse(left, right); in sort__srcline_to_sort()
609 if (!he->branch_info->srcline_to) in sort__srcline_to_init()
610 he->branch_info->srcline_to = addr_map_symbol__srcline(&he->branch_info->to); in sort__srcline_to_init()
616 return repsep_snprintf(bf, size, "%-*.*s", width, width, he->branch_info->srcline_to); in hist_entry__srcline_to_snprintf()
633 struct symbol *sym = he->ms.sym; in hist_entry__sym_ipc_snprintf()
639 return repsep_snprintf(bf, size, "%-*s", width, "-"); in hist_entry__sym_ipc_snprintf()
641 branch = symbol__annotation(sym)->branch; in hist_entry__sym_ipc_snprintf()
643 if (branch && branch->hit_cycles) in hist_entry__sym_ipc_snprintf()
644 ipc = branch->hit_insn / ((double)branch->hit_cycles); in hist_entry__sym_ipc_snprintf()
646 if (branch && branch->total_insn) { in hist_entry__sym_ipc_snprintf()
647 coverage = branch->cover_insn * 100.0 / in hist_entry__sym_ipc_snprintf()
648 ((double)branch->total_insn); in hist_entry__sym_ipc_snprintf()
651 snprintf(tmp, sizeof(tmp), "%-5.2f [%5.1f%%]", ipc, coverage); in hist_entry__sym_ipc_snprintf()
652 return repsep_snprintf(bf, size, "%-*s", width, tmp); in hist_entry__sym_ipc_snprintf()
669 snprintf(tmp, sizeof(tmp), "%-5s %2s", "-", "-"); in hist_entry__sym_ipc_null_snprintf()
670 return repsep_snprintf(bf, size, "%-*s", width, tmp); in hist_entry__sym_ipc_null_snprintf()
680 /* --sort srcfile */
687 struct map *map = e->ms.map; in hist_entry__get_srcfile()
692 sf = __get_srcline(map__dso(map), map__rip_2objdump(map, e->ip), in hist_entry__get_srcfile()
693 e->ms.sym, false, true, true, e->ip); in hist_entry__get_srcfile()
706 sort__srcfile_cmp(struct hist_entry *left, struct hist_entry *right) in sort__srcfile_cmp() argument
708 return sort__srcline_cmp(left, right); in sort__srcfile_cmp()
712 sort__srcfile_collapse(struct hist_entry *left, struct hist_entry *right) in sort__srcfile_collapse() argument
714 if (!left->srcfile) in sort__srcfile_collapse()
715 left->srcfile = hist_entry__get_srcfile(left); in sort__srcfile_collapse()
716 if (!right->srcfile) in sort__srcfile_collapse()
717 right->srcfile = hist_entry__get_srcfile(right); in sort__srcfile_collapse()
719 return strcmp(right->srcfile, left->srcfile); in sort__srcfile_collapse()
723 sort__srcfile_sort(struct hist_entry *left, struct hist_entry *right) in sort__srcfile_sort() argument
725 return sort__srcfile_collapse(left, right); in sort__srcfile_sort()
730 if (!he->srcfile) in sort__srcfile_init()
731 he->srcfile = hist_entry__get_srcfile(he); in sort__srcfile_init()
737 return repsep_snprintf(bf, size, "%-.*s", width, he->srcfile); in hist_entry__srcfile_snprintf()
750 /* --sort parent */
753 sort__parent_cmp(struct hist_entry *left, struct hist_entry *right) in sort__parent_cmp() argument
755 struct symbol *sym_l = left->parent; in sort__parent_cmp()
756 struct symbol *sym_r = right->parent; in sort__parent_cmp()
761 return strcmp(sym_r->name, sym_l->name); in sort__parent_cmp()
767 return repsep_snprintf(bf, size, "%-*.*s", width, width, in hist_entry__parent_snprintf()
768 he->parent ? he->parent->name : "[other]"); in hist_entry__parent_snprintf()
778 /* --sort cpu */
781 sort__cpu_cmp(struct hist_entry *left, struct hist_entry *right) in sort__cpu_cmp() argument
783 return right->cpu - left->cpu; in sort__cpu_cmp()
789 return repsep_snprintf(bf, size, "%*.*d", width, width, he->cpu); in hist_entry__cpu_snprintf()
799 /* --sort cgroup_id */
803 return (int64_t)(right_dev - left_dev); in _sort__cgroup_dev_cmp()
808 return (int64_t)(right_ino - left_ino); in _sort__cgroup_inode_cmp()
812 sort__cgroup_id_cmp(struct hist_entry *left, struct hist_entry *right) in sort__cgroup_id_cmp() argument
816 ret = _sort__cgroup_dev_cmp(right->cgroup_id.dev, left->cgroup_id.dev); in sort__cgroup_id_cmp()
820 return _sort__cgroup_inode_cmp(right->cgroup_id.ino, in sort__cgroup_id_cmp()
821 left->cgroup_id.ino); in sort__cgroup_id_cmp()
828 return repsep_snprintf(bf, size, "%lu/0x%lx", he->cgroup_id.dev, in hist_entry__cgroup_id_snprintf()
829 he->cgroup_id.ino); in hist_entry__cgroup_id_snprintf()
839 /* --sort cgroup */
842 sort__cgroup_cmp(struct hist_entry *left, struct hist_entry *right) in sort__cgroup_cmp() argument
844 return right->cgroup - left->cgroup; in sort__cgroup_cmp()
853 if (he->cgroup) { in hist_entry__cgroup_snprintf()
854 struct cgroup *cgrp = cgroup__find(maps__machine(he->ms.maps)->env, in hist_entry__cgroup_snprintf()
855 he->cgroup); in hist_entry__cgroup_snprintf()
857 cgrp_name = cgrp->name; in hist_entry__cgroup_snprintf()
872 /* --sort socket */
875 sort__socket_cmp(struct hist_entry *left, struct hist_entry *right) in sort__socket_cmp() argument
877 return right->socket - left->socket; in sort__socket_cmp()
883 return repsep_snprintf(bf, size, "%*.*d", width, width-3, he->socket); in hist_entry__socket_snprintf()
891 return -1; in hist_entry__socket_filter()
893 return sk >= 0 && he->socket != sk; in hist_entry__socket_filter()
904 /* --sort time */
907 sort__time_cmp(struct hist_entry *left, struct hist_entry *right) in sort__time_cmp() argument
909 return right->time - left->time; in sort__time_cmp()
918 timestamp__scnprintf_nsec(he->time, he_time, in hist_entry__time_snprintf()
921 timestamp__scnprintf_usec(he->time, he_time, in hist_entry__time_snprintf()
924 return repsep_snprintf(bf, size, "%-.*s", width, he_time); in hist_entry__time_snprintf()
934 /* --sort trace */
942 .data = he->raw_data, in get_trace_output()
943 .size = he->raw_size, in get_trace_output()
946 evsel = hists_to_evsel(he->hists); in get_trace_output()
950 tep_print_fields(&seq, he->raw_data, he->raw_size, in get_trace_output()
951 evsel->tp_format); in get_trace_output()
953 tep_print_event(evsel->tp_format->tep, in get_trace_output()
964 sort__trace_cmp(struct hist_entry *left, struct hist_entry *right) in sort__trace_cmp() argument
968 evsel = hists_to_evsel(left->hists); in sort__trace_cmp()
969 if (evsel->core.attr.type != PERF_TYPE_TRACEPOINT) in sort__trace_cmp()
972 if (left->trace_output == NULL) in sort__trace_cmp()
973 left->trace_output = get_trace_output(left); in sort__trace_cmp()
974 if (right->trace_output == NULL) in sort__trace_cmp()
975 right->trace_output = get_trace_output(right); in sort__trace_cmp()
977 return strcmp(right->trace_output, left->trace_output); in sort__trace_cmp()
985 evsel = hists_to_evsel(he->hists); in hist_entry__trace_snprintf()
986 if (evsel->core.attr.type != PERF_TYPE_TRACEPOINT) in hist_entry__trace_snprintf()
987 return scnprintf(bf, size, "%-.*s", width, "N/A"); in hist_entry__trace_snprintf()
989 if (he->trace_output == NULL) in hist_entry__trace_snprintf()
990 he->trace_output = get_trace_output(he); in hist_entry__trace_snprintf()
991 return repsep_snprintf(bf, size, "%-.*s", width, he->trace_output); in hist_entry__trace_snprintf()
1005 sort__dso_from_cmp(struct hist_entry *left, struct hist_entry *right) in sort__dso_from_cmp() argument
1007 if (!left->branch_info || !right->branch_info) in sort__dso_from_cmp()
1008 return cmp_null(left->branch_info, right->branch_info); in sort__dso_from_cmp()
1010 return _sort__dso_cmp(left->branch_info->from.ms.map, in sort__dso_from_cmp()
1011 right->branch_info->from.ms.map); in sort__dso_from_cmp()
1017 if (he->branch_info) in hist_entry__dso_from_snprintf()
1018 return _hist_entry__dso_snprintf(he->branch_info->from.ms.map, in hist_entry__dso_from_snprintf()
1021 return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A"); in hist_entry__dso_from_snprintf()
1030 return -1; in hist_entry__dso_from_filter()
1032 return dso && (!he->branch_info || !he->branch_info->from.ms.map || in hist_entry__dso_from_filter()
1033 map__dso(he->branch_info->from.ms.map) != dso); in hist_entry__dso_from_filter()
1037 sort__dso_to_cmp(struct hist_entry *left, struct hist_entry *right) in sort__dso_to_cmp() argument
1039 if (!left->branch_info || !right->branch_info) in sort__dso_to_cmp()
1040 return cmp_null(left->branch_info, right->branch_info); in sort__dso_to_cmp()
1042 return _sort__dso_cmp(left->branch_info->to.ms.map, in sort__dso_to_cmp()
1043 right->branch_info->to.ms.map); in sort__dso_to_cmp()
1049 if (he->branch_info) in hist_entry__dso_to_snprintf()
1050 return _hist_entry__dso_snprintf(he->branch_info->to.ms.map, in hist_entry__dso_to_snprintf()
1053 return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A"); in hist_entry__dso_to_snprintf()
1062 return -1; in hist_entry__dso_to_filter()
1064 return dso && (!he->branch_info || !he->branch_info->to.ms.map || in hist_entry__dso_to_filter()
1065 map__dso(he->branch_info->to.ms.map) != dso); in hist_entry__dso_to_filter()
1069 sort__sym_from_cmp(struct hist_entry *left, struct hist_entry *right) in sort__sym_from_cmp() argument
1073 if (!left->branch_info || !right->branch_info) in sort__sym_from_cmp()
1074 return cmp_null(left->branch_info, right->branch_info); in sort__sym_from_cmp()
1076 from_l = &left->branch_info->from; in sort__sym_from_cmp()
1077 from_r = &right->branch_info->from; in sort__sym_from_cmp()
1079 if (!from_l->ms.sym && !from_r->ms.sym) in sort__sym_from_cmp()
1080 return _sort__addr_cmp(from_l->addr, from_r->addr); in sort__sym_from_cmp()
1082 return _sort__sym_cmp(from_l->ms.sym, from_r->ms.sym); in sort__sym_from_cmp()
1086 sort__sym_to_cmp(struct hist_entry *left, struct hist_entry *right) in sort__sym_to_cmp() argument
1090 if (!left->branch_info || !right->branch_info) in sort__sym_to_cmp()
1091 return cmp_null(left->branch_info, right->branch_info); in sort__sym_to_cmp()
1093 to_l = &left->branch_info->to; in sort__sym_to_cmp()
1094 to_r = &right->branch_info->to; in sort__sym_to_cmp()
1096 if (!to_l->ms.sym && !to_r->ms.sym) in sort__sym_to_cmp()
1097 return _sort__addr_cmp(to_l->addr, to_r->addr); in sort__sym_to_cmp()
1099 return _sort__sym_cmp(to_l->ms.sym, to_r->ms.sym); in sort__sym_to_cmp()
1105 if (he->branch_info) { in hist_entry__sym_from_snprintf()
1106 struct addr_map_symbol *from = &he->branch_info->from; in hist_entry__sym_from_snprintf()
1108 return _hist_entry__sym_snprintf(&from->ms, from->al_addr, in hist_entry__sym_from_snprintf()
1109 from->al_level, bf, size, width); in hist_entry__sym_from_snprintf()
1112 return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A"); in hist_entry__sym_from_snprintf()
1118 if (he->branch_info) { in hist_entry__sym_to_snprintf()
1119 struct addr_map_symbol *to = &he->branch_info->to; in hist_entry__sym_to_snprintf()
1121 return _hist_entry__sym_snprintf(&to->ms, to->al_addr, in hist_entry__sym_to_snprintf()
1122 to->al_level, bf, size, width); in hist_entry__sym_to_snprintf()
1125 return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A"); in hist_entry__sym_to_snprintf()
1134 return -1; in hist_entry__sym_from_filter()
1136 return sym && !(he->branch_info && he->branch_info->from.ms.sym && in hist_entry__sym_from_filter()
1137 strstr(he->branch_info->from.ms.sym->name, sym)); in hist_entry__sym_from_filter()
1146 return -1; in hist_entry__sym_to_filter()
1148 return sym && !(he->branch_info && he->branch_info->to.ms.sym && in hist_entry__sym_to_filter()
1149 strstr(he->branch_info->to.ms.sym->name, sym)); in hist_entry__sym_to_filter()
1188 struct symbol *sym = ms->sym; in _hist_entry__addr_snprintf()
1189 struct map *map = ms->map; in _hist_entry__addr_snprintf()
1192 ret += repsep_snprintf(bf + ret, size - ret, "[%c] ", level); in _hist_entry__addr_snprintf()
1194 if (sym->type == STT_OBJECT) { in _hist_entry__addr_snprintf()
1195 ret += repsep_snprintf(bf + ret, size - ret, "%s", sym->name); in _hist_entry__addr_snprintf()
1196 ret += repsep_snprintf(bf + ret, size - ret, "+0x%llx", in _hist_entry__addr_snprintf()
1197 ip - map__unmap_ip(map, sym->start)); in _hist_entry__addr_snprintf()
1199 ret += repsep_snprintf(bf + ret, size - ret, "%.*s", in _hist_entry__addr_snprintf()
1200 width - ret, in _hist_entry__addr_snprintf()
1201 sym->name); in _hist_entry__addr_snprintf()
1202 offs = ip - sym->start; in _hist_entry__addr_snprintf()
1204 ret += repsep_snprintf(bf + ret, size - ret, "+0x%llx", offs); in _hist_entry__addr_snprintf()
1208 ret += repsep_snprintf(bf + ret, size - ret, "%-#.*llx", in _hist_entry__addr_snprintf()
1218 if (he->branch_info) { in hist_entry__addr_from_snprintf()
1219 struct addr_map_symbol *from = &he->branch_info->from; in hist_entry__addr_from_snprintf()
1221 return _hist_entry__addr_snprintf(&from->ms, from->al_addr, in hist_entry__addr_from_snprintf()
1222 he->level, bf, size, width); in hist_entry__addr_from_snprintf()
1225 return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A"); in hist_entry__addr_from_snprintf()
1231 if (he->branch_info) { in hist_entry__addr_to_snprintf()
1232 struct addr_map_symbol *to = &he->branch_info->to; in hist_entry__addr_to_snprintf()
1234 return _hist_entry__addr_snprintf(&to->ms, to->al_addr, in hist_entry__addr_to_snprintf()
1235 he->level, bf, size, width); in hist_entry__addr_to_snprintf()
1238 return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A"); in hist_entry__addr_to_snprintf()
1242 sort__addr_from_cmp(struct hist_entry *left, struct hist_entry *right) in sort__addr_from_cmp() argument
1248 if (!left->branch_info || !right->branch_info) in sort__addr_from_cmp()
1249 return cmp_null(left->branch_info, right->branch_info); in sort__addr_from_cmp()
1251 from_l = &left->branch_info->from; in sort__addr_from_cmp()
1252 from_r = &right->branch_info->from; in sort__addr_from_cmp()
1258 ret = _sort__dso_cmp(from_l->ms.map, from_r->ms.map); in sort__addr_from_cmp()
1262 return _sort__addr_cmp(from_l->addr, from_r->addr); in sort__addr_from_cmp()
1266 sort__addr_to_cmp(struct hist_entry *left, struct hist_entry *right) in sort__addr_to_cmp() argument
1272 if (!left->branch_info || !right->branch_info) in sort__addr_to_cmp()
1273 return cmp_null(left->branch_info, right->branch_info); in sort__addr_to_cmp()
1275 to_l = &left->branch_info->to; in sort__addr_to_cmp()
1276 to_r = &right->branch_info->to; in sort__addr_to_cmp()
1282 ret = _sort__dso_cmp(to_l->ms.map, to_r->ms.map); in sort__addr_to_cmp()
1286 return _sort__addr_cmp(to_l->addr, to_r->addr); in sort__addr_to_cmp()
1307 sort__mispredict_cmp(struct hist_entry *left, struct hist_entry *right) in sort__mispredict_cmp() argument
1311 if (!left->branch_info || !right->branch_info) in sort__mispredict_cmp()
1312 return cmp_null(left->branch_info, right->branch_info); in sort__mispredict_cmp()
1314 mp = left->branch_info->flags.mispred != right->branch_info->flags.mispred; in sort__mispredict_cmp()
1315 p = left->branch_info->flags.predicted != right->branch_info->flags.predicted; in sort__mispredict_cmp()
1323 if (he->branch_info) { in hist_entry__mispredict_snprintf()
1324 if (he->branch_info->flags.predicted) in hist_entry__mispredict_snprintf()
1326 else if (he->branch_info->flags.mispred) in hist_entry__mispredict_snprintf()
1330 return repsep_snprintf(bf, size, "%-*.*s", width, width, out); in hist_entry__mispredict_snprintf()
1334 sort__cycles_cmp(struct hist_entry *left, struct hist_entry *right) in sort__cycles_cmp() argument
1336 if (!left->branch_info || !right->branch_info) in sort__cycles_cmp()
1337 return cmp_null(left->branch_info, right->branch_info); in sort__cycles_cmp()
1339 return left->branch_info->flags.cycles - in sort__cycles_cmp()
1340 right->branch_info->flags.cycles; in sort__cycles_cmp()
1346 if (!he->branch_info) in hist_entry__cycles_snprintf()
1347 return scnprintf(bf, size, "%-.*s", width, "N/A"); in hist_entry__cycles_snprintf()
1348 if (he->branch_info->flags.cycles == 0) in hist_entry__cycles_snprintf()
1349 return repsep_snprintf(bf, size, "%-*s", width, "-"); in hist_entry__cycles_snprintf()
1350 return repsep_snprintf(bf, size, "%-*hd", width, in hist_entry__cycles_snprintf()
1351 he->branch_info->flags.cycles); in hist_entry__cycles_snprintf()
1361 /* --sort daddr_sym */
1363 sort__daddr_cmp(struct hist_entry *left, struct hist_entry *right) in sort__daddr_cmp() argument
1367 if (left->mem_info) in sort__daddr_cmp()
1368 l = mem_info__daddr(left->mem_info)->addr; in sort__daddr_cmp()
1369 if (right->mem_info) in sort__daddr_cmp()
1370 r = mem_info__daddr(right->mem_info)->addr; in sort__daddr_cmp()
1372 return (int64_t)(r - l); in sort__daddr_cmp()
1381 if (he->mem_info) { in hist_entry__daddr_snprintf()
1382 addr = mem_info__daddr(he->mem_info)->addr; in hist_entry__daddr_snprintf()
1383 ms = &mem_info__daddr(he->mem_info)->ms; in hist_entry__daddr_snprintf()
1385 return _hist_entry__sym_snprintf(ms, addr, he->level, bf, size, width); in hist_entry__daddr_snprintf()
1389 sort__iaddr_cmp(struct hist_entry *left, struct hist_entry *right) in sort__iaddr_cmp() argument
1393 if (left->mem_info) in sort__iaddr_cmp()
1394 l = mem_info__iaddr(left->mem_info)->addr; in sort__iaddr_cmp()
1395 if (right->mem_info) in sort__iaddr_cmp()
1396 r = mem_info__iaddr(right->mem_info)->addr; in sort__iaddr_cmp()
1398 return (int64_t)(r - l); in sort__iaddr_cmp()
1407 if (he->mem_info) { in hist_entry__iaddr_snprintf()
1408 addr = mem_info__iaddr(he->mem_info)->addr; in hist_entry__iaddr_snprintf()
1409 ms = &mem_info__iaddr(he->mem_info)->ms; in hist_entry__iaddr_snprintf()
1411 return _hist_entry__sym_snprintf(ms, addr, he->level, bf, size, width); in hist_entry__iaddr_snprintf()
1415 sort__dso_daddr_cmp(struct hist_entry *left, struct hist_entry *right) in sort__dso_daddr_cmp() argument
1420 if (left->mem_info) in sort__dso_daddr_cmp()
1421 map_l = mem_info__daddr(left->mem_info)->ms.map; in sort__dso_daddr_cmp()
1422 if (right->mem_info) in sort__dso_daddr_cmp()
1423 map_r = mem_info__daddr(right->mem_info)->ms.map; in sort__dso_daddr_cmp()
1433 if (he->mem_info) in hist_entry__dso_daddr_snprintf()
1434 map = mem_info__daddr(he->mem_info)->ms.map; in hist_entry__dso_daddr_snprintf()
1440 sort__locked_cmp(struct hist_entry *left, struct hist_entry *right) in sort__locked_cmp() argument
1445 if (left->mem_info) in sort__locked_cmp()
1446 data_src_l = *mem_info__data_src(left->mem_info); in sort__locked_cmp()
1450 if (right->mem_info) in sort__locked_cmp()
1451 data_src_r = *mem_info__data_src(right->mem_info); in sort__locked_cmp()
1455 return (int64_t)(data_src_r.mem_lock - data_src_l.mem_lock); in sort__locked_cmp()
1463 perf_mem__lck_scnprintf(out, sizeof(out), he->mem_info); in hist_entry__locked_snprintf()
1468 sort__tlb_cmp(struct hist_entry *left, struct hist_entry *right) in sort__tlb_cmp() argument
1473 if (left->mem_info) in sort__tlb_cmp()
1474 data_src_l = *mem_info__data_src(left->mem_info); in sort__tlb_cmp()
1478 if (right->mem_info) in sort__tlb_cmp()
1479 data_src_r = *mem_info__data_src(right->mem_info); in sort__tlb_cmp()
1483 return (int64_t)(data_src_r.mem_dtlb - data_src_l.mem_dtlb); in sort__tlb_cmp()
1491 perf_mem__tlb_scnprintf(out, sizeof(out), he->mem_info); in hist_entry__tlb_snprintf()
1492 return repsep_snprintf(bf, size, "%-*s", width, out); in hist_entry__tlb_snprintf()
1496 sort__lvl_cmp(struct hist_entry *left, struct hist_entry *right) in sort__lvl_cmp() argument
1501 if (left->mem_info) in sort__lvl_cmp()
1502 data_src_l = *mem_info__data_src(left->mem_info); in sort__lvl_cmp()
1506 if (right->mem_info) in sort__lvl_cmp()
1507 data_src_r = *mem_info__data_src(right->mem_info); in sort__lvl_cmp()
1511 return (int64_t)(data_src_r.mem_lvl - data_src_l.mem_lvl); in sort__lvl_cmp()
1519 perf_mem__lvl_scnprintf(out, sizeof(out), he->mem_info); in hist_entry__lvl_snprintf()
1520 return repsep_snprintf(bf, size, "%-*s", width, out); in hist_entry__lvl_snprintf()
1524 sort__snoop_cmp(struct hist_entry *left, struct hist_entry *right) in sort__snoop_cmp() argument
1529 if (left->mem_info) in sort__snoop_cmp()
1530 data_src_l = *mem_info__data_src(left->mem_info); in sort__snoop_cmp()
1534 if (right->mem_info) in sort__snoop_cmp()
1535 data_src_r = *mem_info__data_src(right->mem_info); in sort__snoop_cmp()
1539 return (int64_t)(data_src_r.mem_snoop - data_src_l.mem_snoop); in sort__snoop_cmp()
1547 perf_mem__snp_scnprintf(out, sizeof(out), he->mem_info); in hist_entry__snoop_snprintf()
1548 return repsep_snprintf(bf, size, "%-*s", width, out); in hist_entry__snoop_snprintf()
1552 sort__dcacheline_cmp(struct hist_entry *left, struct hist_entry *right) in sort__dcacheline_cmp() argument
1559 if (!left->mem_info) return -1; in sort__dcacheline_cmp()
1560 if (!right->mem_info) return 1; in sort__dcacheline_cmp()
1563 if (left->cpumode > right->cpumode) return -1; in sort__dcacheline_cmp()
1564 if (left->cpumode < right->cpumode) return 1; in sort__dcacheline_cmp()
1566 l_map = mem_info__daddr(left->mem_info)->ms.map; in sort__dcacheline_cmp()
1567 r_map = mem_info__daddr(right->mem_info)->ms.map; in sort__dcacheline_cmp()
1573 if (!l_map) return -1; in sort__dcacheline_cmp()
1585 * The kernel and non-zero major/minor mapped areas are in sort__dcacheline_cmp()
1589 if ((left->cpumode != PERF_RECORD_MISC_KERNEL) && in sort__dcacheline_cmp()
1590 (!(map__flags(l_map) & MAP_SHARED)) && !dso__id(l_dso)->maj && !dso__id(l_dso)->min && in sort__dcacheline_cmp()
1591 !dso__id(l_dso)->ino && !dso__id(l_dso)->ino_generation) { in sort__dcacheline_cmp()
1594 if (thread__pid(left->thread) > thread__pid(right->thread)) in sort__dcacheline_cmp()
1595 return -1; in sort__dcacheline_cmp()
1596 if (thread__pid(left->thread) < thread__pid(right->thread)) in sort__dcacheline_cmp()
1601 /* al_addr does all the right addr - start + offset calculations */ in sort__dcacheline_cmp()
1602 l = cl_address(mem_info__daddr(left->mem_info)->al_addr, chk_double_cl); in sort__dcacheline_cmp()
1603 r = cl_address(mem_info__daddr(right->mem_info)->al_addr, chk_double_cl); in sort__dcacheline_cmp()
1605 if (l > r) return -1; in sort__dcacheline_cmp()
1617 char level = he->level; in hist_entry__dcacheline_snprintf()
1619 if (he->mem_info) { in hist_entry__dcacheline_snprintf()
1620 struct map *map = mem_info__daddr(he->mem_info)->ms.map; in hist_entry__dcacheline_snprintf()
1623 addr = cl_address(mem_info__daddr(he->mem_info)->al_addr, chk_double_cl); in hist_entry__dcacheline_snprintf()
1624 ms = &mem_info__daddr(he->mem_info)->ms; in hist_entry__dcacheline_snprintf()
1627 if ((he->cpumode != PERF_RECORD_MISC_KERNEL) && in hist_entry__dcacheline_snprintf()
1630 (dso__id(dso)->maj || dso__id(dso)->min || dso__id(dso)->ino || in hist_entry__dcacheline_snprintf()
1631 dso__id(dso)->ino_generation)) in hist_entry__dcacheline_snprintf()
1647 sort__weight_cmp(struct hist_entry *left, struct hist_entry *right) in sort__weight_cmp() argument
1649 return left->weight - right->weight; in sort__weight_cmp()
1655 return repsep_snprintf(bf, size, "%-*llu", width, he->weight); in hist_entry__local_weight_snprintf()
1668 return repsep_snprintf(bf, size, "%-*llu", width, in hist_entry__global_weight_snprintf()
1669 he->weight * he->stat.nr_events); in hist_entry__global_weight_snprintf()
1680 sort__ins_lat_cmp(struct hist_entry *left, struct hist_entry *right) in sort__ins_lat_cmp() argument
1682 return left->ins_lat - right->ins_lat; in sort__ins_lat_cmp()
1688 return repsep_snprintf(bf, size, "%-*u", width, he->ins_lat); in hist_entry__local_ins_lat_snprintf()
1701 return repsep_snprintf(bf, size, "%-*u", width, in hist_entry__global_ins_lat_snprintf()
1702 he->ins_lat * he->stat.nr_events); in hist_entry__global_ins_lat_snprintf()
1713 sort__p_stage_cyc_cmp(struct hist_entry *left, struct hist_entry *right) in sort__p_stage_cyc_cmp() argument
1715 return left->p_stage_cyc - right->p_stage_cyc; in sort__p_stage_cyc_cmp()
1721 return repsep_snprintf(bf, size, "%-*u", width, in hist_entry__global_p_stage_cyc_snprintf()
1722 he->p_stage_cyc * he->stat.nr_events); in hist_entry__global_p_stage_cyc_snprintf()
1729 return repsep_snprintf(bf, size, "%-*u", width, he->p_stage_cyc); in hist_entry__p_stage_cyc_snprintf()
1803 sort__blocked_cmp(struct hist_entry *left, struct hist_entry *right) in sort__blocked_cmp() argument
1808 if (left->mem_info) in sort__blocked_cmp()
1809 data_src_l = *mem_info__data_src(left->mem_info); in sort__blocked_cmp()
1813 if (right->mem_info) in sort__blocked_cmp()
1814 data_src_r = *mem_info__data_src(right->mem_info); in sort__blocked_cmp()
1818 return (int64_t)(data_src_r.mem_blk - data_src_l.mem_blk); in sort__blocked_cmp()
1826 perf_mem__blk_scnprintf(out, sizeof(out), he->mem_info); in hist_entry__blocked_snprintf()
1838 sort__phys_daddr_cmp(struct hist_entry *left, struct hist_entry *right) in sort__phys_daddr_cmp() argument
1842 if (left->mem_info) in sort__phys_daddr_cmp()
1843 l = mem_info__daddr(left->mem_info)->phys_addr; in sort__phys_daddr_cmp()
1844 if (right->mem_info) in sort__phys_daddr_cmp()
1845 r = mem_info__daddr(right->mem_info)->phys_addr; in sort__phys_daddr_cmp()
1847 return (int64_t)(r - l); in sort__phys_daddr_cmp()
1857 addr = mem_info__daddr(he->mem_info)->phys_addr; in hist_entry__phys_daddr_snprintf()
1859 ret += repsep_snprintf(bf + ret, size - ret, "[%c] ", he->level); in hist_entry__phys_daddr_snprintf()
1861 ret += repsep_snprintf(bf + ret, size - ret, "%-#.*llx", len, addr); in hist_entry__phys_daddr_snprintf()
1863 ret += repsep_snprintf(bf + ret, size - ret, "%-*s", width - ret, ""); in hist_entry__phys_daddr_snprintf()
1879 sort__data_page_size_cmp(struct hist_entry *left, struct hist_entry *right) in sort__data_page_size_cmp() argument
1883 if (left->mem_info) in sort__data_page_size_cmp()
1884 l = mem_info__daddr(left->mem_info)->data_page_size; in sort__data_page_size_cmp()
1885 if (right->mem_info) in sort__data_page_size_cmp()
1886 r = mem_info__daddr(right->mem_info)->data_page_size; in sort__data_page_size_cmp()
1888 return (int64_t)(r - l); in sort__data_page_size_cmp()
1896 return repsep_snprintf(bf, size, "%-*s", width, in hist_entry__data_page_size_snprintf()
1897 get_page_size_name(mem_info__daddr(he->mem_info)->data_page_size, str)); in hist_entry__data_page_size_snprintf()
1908 sort__code_page_size_cmp(struct hist_entry *left, struct hist_entry *right) in sort__code_page_size_cmp() argument
1910 uint64_t l = left->code_page_size; in sort__code_page_size_cmp()
1911 uint64_t r = right->code_page_size; in sort__code_page_size_cmp()
1913 return (int64_t)(r - l); in sort__code_page_size_cmp()
1921 return repsep_snprintf(bf, size, "%-*s", width, in hist_entry__code_page_size_snprintf()
1922 get_page_size_name(he->code_page_size, str)); in hist_entry__code_page_size_snprintf()
1933 sort__abort_cmp(struct hist_entry *left, struct hist_entry *right) in sort__abort_cmp() argument
1935 if (!left->branch_info || !right->branch_info) in sort__abort_cmp()
1936 return cmp_null(left->branch_info, right->branch_info); in sort__abort_cmp()
1938 return left->branch_info->flags.abort != in sort__abort_cmp()
1939 right->branch_info->flags.abort; in sort__abort_cmp()
1947 if (he->branch_info) { in hist_entry__abort_snprintf()
1948 if (he->branch_info->flags.abort) in hist_entry__abort_snprintf()
1954 return repsep_snprintf(bf, size, "%-*s", width, out); in hist_entry__abort_snprintf()
1965 sort__in_tx_cmp(struct hist_entry *left, struct hist_entry *right) in sort__in_tx_cmp() argument
1967 if (!left->branch_info || !right->branch_info) in sort__in_tx_cmp()
1968 return cmp_null(left->branch_info, right->branch_info); in sort__in_tx_cmp()
1970 return left->branch_info->flags.in_tx != in sort__in_tx_cmp()
1971 right->branch_info->flags.in_tx; in sort__in_tx_cmp()
1979 if (he->branch_info) { in hist_entry__in_tx_snprintf()
1980 if (he->branch_info->flags.in_tx) in hist_entry__in_tx_snprintf()
1986 return repsep_snprintf(bf, size, "%-*s", width, out); in hist_entry__in_tx_snprintf()
1997 sort__transaction_cmp(struct hist_entry *left, struct hist_entry *right) in sort__transaction_cmp() argument
1999 return left->transaction - right->transaction; in sort__transaction_cmp()
2019 { PERF_TXN_CAPACITY_WRITE, "CAP-WRITE ", 1 },
2020 { PERF_TXN_CAPACITY_READ, "CAP-READ ", 0 },
2040 u64 t = he->transaction; in hist_entry__transaction_snprintf()
2058 return repsep_snprintf(bf, size, "%-*s", width, buf); in hist_entry__transaction_snprintf()
2068 /* --sort symbol_size */
2075 return size_l < size_r ? -1 : in _sort__sym_size_cmp()
2080 sort__sym_size_cmp(struct hist_entry *left, struct hist_entry *right) in sort__sym_size_cmp() argument
2082 return _sort__sym_size_cmp(right->ms.sym, left->ms.sym); in sort__sym_size_cmp()
2097 return _hist_entry__sym_size_snprintf(he->ms.sym, bf, size, width); in hist_entry__sym_size_snprintf()
2107 /* --sort dso_size */
2114 return size_l < size_r ? -1 : in _sort__dso_size_cmp()
2119 sort__dso_size_cmp(struct hist_entry *left, struct hist_entry *right) in sort__dso_size_cmp() argument
2121 return _sort__dso_size_cmp(right->ms.map, left->ms.map); in sort__dso_size_cmp()
2136 return _hist_entry__dso_size_snprintf(he->ms.map, bf, size, width); in hist_entry__dso_size_snprintf()
2146 /* --sort addr */
2149 sort__addr_cmp(struct hist_entry *left, struct hist_entry *right) in sort__addr_cmp() argument
2151 u64 left_ip = left->ip; in sort__addr_cmp()
2152 u64 right_ip = right->ip; in sort__addr_cmp()
2153 struct map *left_map = left->ms.map; in sort__addr_cmp()
2154 struct map *right_map = right->ms.map; in sort__addr_cmp()
2167 u64 ip = he->ip; in hist_entry__addr_snprintf()
2168 struct map *map = he->ms.map; in hist_entry__addr_snprintf()
2173 return repsep_snprintf(bf, size, "%-#*llx", width, ip); in hist_entry__addr_snprintf()
2183 /* --sort type */
2193 sort__type_cmp(struct hist_entry *left, struct hist_entry *right) in sort__type_cmp() argument
2195 return sort__addr_cmp(left, right); in sort__type_cmp()
2200 if (he->mem_type) in sort__type_init()
2203 he->mem_type = hist_entry__get_data_type(he); in sort__type_init()
2204 if (he->mem_type == NULL) { in sort__type_init()
2205 he->mem_type = &unknown_type; in sort__type_init()
2206 he->mem_type_off = 0; in sort__type_init()
2211 sort__type_collapse(struct hist_entry *left, struct hist_entry *right) in sort__type_collapse() argument
2213 struct annotated_data_type *left_type = left->mem_type; in sort__type_collapse()
2214 struct annotated_data_type *right_type = right->mem_type; in sort__type_collapse()
2217 sort__type_init(left); in sort__type_collapse()
2218 left_type = left->mem_type; in sort__type_collapse()
2223 right_type = right->mem_type; in sort__type_collapse()
2226 return strcmp(left_type->self.type_name, right_type->self.type_name); in sort__type_collapse()
2230 sort__type_sort(struct hist_entry *left, struct hist_entry *right) in sort__type_sort() argument
2232 return sort__type_collapse(left, right); in sort__type_sort()
2238 return repsep_snprintf(bf, size, "%-*s", width, he->mem_type->self.type_name); in hist_entry__type_snprintf()
2251 /* --sort typeoff */
2254 sort__typeoff_sort(struct hist_entry *left, struct hist_entry *right) in sort__typeoff_sort() argument
2256 struct annotated_data_type *left_type = left->mem_type; in sort__typeoff_sort()
2257 struct annotated_data_type *right_type = right->mem_type; in sort__typeoff_sort()
2261 sort__type_init(left); in sort__typeoff_sort()
2262 left_type = left->mem_type; in sort__typeoff_sort()
2267 right_type = right->mem_type; in sort__typeoff_sort()
2270 ret = strcmp(left_type->self.type_name, right_type->self.type_name); in sort__typeoff_sort()
2273 return left->mem_type_off - right->mem_type_off; in sort__typeoff_sort()
2281 if (list_empty(&m->children)) in fill_member_name()
2284 list_for_each_entry(child, &m->children, node) { in fill_member_name()
2285 if (child->offset <= offset && offset < child->offset + child->size) { in fill_member_name()
2289 if (child->var_name) { in fill_member_name()
2291 first ? "" : ".", child->var_name); in fill_member_name()
2295 fill_member_name(buf + len, sz - len, child, offset, first); in fill_member_name()
2304 struct annotated_data_type *he_type = he->mem_type; in hist_entry__typeoff_snprintf()
2308 if (list_empty(&he_type->self.children)) in hist_entry__typeoff_snprintf()
2311 fill_member_name(buf, sizeof(buf), &he_type->self, in hist_entry__typeoff_snprintf()
2312 he->mem_type_off, true); in hist_entry__typeoff_snprintf()
2315 return repsep_snprintf(bf, size, "%s +%#x (%s)", he_type->self.type_name, in hist_entry__typeoff_snprintf()
2316 he->mem_type_off, buf); in hist_entry__typeoff_snprintf()
2329 /* --sort typecln */
2335 sort__typecln_sort(struct hist_entry *left, struct hist_entry *right) in sort__typecln_sort() argument
2337 struct annotated_data_type *left_type = left->mem_type; in sort__typecln_sort()
2338 struct annotated_data_type *right_type = right->mem_type; in sort__typecln_sort()
2343 sort__type_init(left); in sort__typecln_sort()
2344 left_type = left->mem_type; in sort__typecln_sort()
2349 right_type = right->mem_type; in sort__typecln_sort()
2352 ret = strcmp(left_type->self.type_name, right_type->self.type_name); in sort__typecln_sort()
2356 left_cln = left->mem_type_off / TYPE_CACHELINE_SIZE; in sort__typecln_sort()
2357 right_cln = right->mem_type_off / TYPE_CACHELINE_SIZE; in sort__typecln_sort()
2358 return left_cln - right_cln; in sort__typecln_sort()
2364 struct annotated_data_type *he_type = he->mem_type; in hist_entry__typecln_snprintf()
2366 return repsep_snprintf(bf, size, "%s: cache-line %d", he_type->self.type_name, in hist_entry__typecln_snprintf()
2367 he->mem_type_off / TYPE_CACHELINE_SIZE); in hist_entry__typecln_snprintf()
2399 sd->entry->se_header = arch_perf_header_entry(sd->entry->se_header); in sort_dimension_add_dynamic_header()
2443 #define DIM(d, n, func) [d - __SORT_BRANCH_STACK] = { .name = n, .entry = &(func) }
2463 #define DIM(d, n, func) [d - __SORT_MEMORY_MODE] = { .name = n, .entry = &(func) }
2522 hists__new_col_len(hists, hse->se->se_width_idx, strlen(fmt->name)); in perf_hpp__reset_sort_width()
2530 size_t len = fmt->user_len; in __sort__hpp_header()
2535 len = hists__col_len(hists, hse->se->se_width_idx); in __sort__hpp_header()
2537 return scnprintf(hpp->buf, hpp->size, "%-*.*s", len, len, fmt->name); in __sort__hpp_header()
2545 size_t len = fmt->user_len; in __sort__hpp_width()
2550 len = hists__col_len(hists, hse->se->se_width_idx); in __sort__hpp_width()
2559 size_t len = fmt->user_len; in __sort__hpp_entry()
2564 len = hists__col_len(he->hists, hse->se->se_width_idx); in __sort__hpp_entry()
2566 return hse->se->se_snprintf(he, hpp->buf, hpp->size, len); in __sort__hpp_entry()
2575 return hse->se->se_cmp(a, b); in __sort__hpp_cmp()
2585 collapse_fn = hse->se->se_collapse ?: hse->se->se_cmp; in __sort__hpp_collapse()
2596 sort_fn = hse->se->se_sort ?: hse->se->se_cmp; in __sort__hpp_sort()
2602 return format->header == __sort__hpp_header; in perf_hpp__is_sort_entry()
2614 return hse->se == &sort_ ## key ; \
2644 return hse_a->se == hse_b->se; in MK_SORT_ENTRY_CHK()
2664 if (hse->se->se_init) in hse_init()
2665 hse->se->se_init(he); in hse_init()
2679 hse->se = sd->entry; in __sort_dimension__alloc_hpp()
2680 hse->hpp.name = sd->entry->se_header; in __sort_dimension__alloc_hpp()
2681 hse->hpp.header = __sort__hpp_header; in __sort_dimension__alloc_hpp()
2682 hse->hpp.width = __sort__hpp_width; in __sort_dimension__alloc_hpp()
2683 hse->hpp.entry = __sort__hpp_entry; in __sort_dimension__alloc_hpp()
2684 hse->hpp.color = NULL; in __sort_dimension__alloc_hpp()
2686 hse->hpp.cmp = __sort__hpp_cmp; in __sort_dimension__alloc_hpp()
2687 hse->hpp.collapse = __sort__hpp_collapse; in __sort_dimension__alloc_hpp()
2688 hse->hpp.sort = __sort__hpp_sort; in __sort_dimension__alloc_hpp()
2689 hse->hpp.equal = __sort__hpp_equal; in __sort_dimension__alloc_hpp()
2690 hse->hpp.free = hse_free; in __sort_dimension__alloc_hpp()
2691 hse->hpp.init = hse_init; in __sort_dimension__alloc_hpp()
2693 INIT_LIST_HEAD(&hse->hpp.list); in __sort_dimension__alloc_hpp()
2694 INIT_LIST_HEAD(&hse->hpp.sort_list); in __sort_dimension__alloc_hpp()
2695 hse->hpp.elide = false; in __sort_dimension__alloc_hpp()
2696 hse->hpp.len = 0; in __sort_dimension__alloc_hpp()
2697 hse->hpp.user_len = 0; in __sort_dimension__alloc_hpp()
2698 hse->hpp.level = level; in __sort_dimension__alloc_hpp()
2713 fmt = memdup(hd->fmt, sizeof(*fmt)); in __hpp_dimension__alloc_hpp()
2715 INIT_LIST_HEAD(&fmt->list); in __hpp_dimension__alloc_hpp()
2716 INIT_LIST_HEAD(&fmt->sort_list); in __hpp_dimension__alloc_hpp()
2717 fmt->free = hpp_free; in __hpp_dimension__alloc_hpp()
2718 fmt->level = level; in __hpp_dimension__alloc_hpp()
2728 int ret = -1; in hist_entry__filter()
2731 perf_hpp_list__for_each_format(he->hpp_list, fmt) { in hist_entry__filter()
2736 if (hse->se->se_filter == NULL) in hist_entry__filter()
2741 * is applied. But it should skip non-matched filter types. in hist_entry__filter()
2743 r = hse->se->se_filter(he, type, arg); in hist_entry__filter()
2761 return -1; in __sort_dimension__add_hpp_sort()
2763 perf_hpp_list__register_sort_field(list, &hse->hpp); in __sort_dimension__add_hpp_sort()
2773 return -1; in __sort_dimension__add_hpp_output()
2775 perf_hpp_list__column_register(list, &hse->hpp); in __sort_dimension__add_hpp_output()
2800 if (!hde->hpp.len) { in hde_width()
2801 int len = hde->dynamic_len; in hde_width()
2802 int namelen = strlen(hde->field->name); in hde_width()
2803 int fieldlen = hde->field->size; in hde_width()
2808 if (!(hde->field->flags & TEP_FIELD_IS_STRING)) { in hde_width()
2810 fieldlen = hde->field->size * 2 + 2; in hde_width()
2815 hde->hpp.len = len; in hde_width()
2817 return hde->hpp.len; in hde_width()
2824 struct tep_format_field *field = hde->field; in update_dynamic_len()
2828 if (hde->raw_trace) in update_dynamic_len()
2832 if (!he->trace_output) in update_dynamic_len()
2833 he->trace_output = get_trace_output(he); in update_dynamic_len()
2835 namelen = strlen(field->name); in update_dynamic_len()
2836 str = he->trace_output; in update_dynamic_len()
2845 if (!strncmp(str, field->name, namelen)) { in update_dynamic_len()
2849 len = pos - str; in update_dynamic_len()
2851 if (len > hde->dynamic_len) in update_dynamic_len()
2852 hde->dynamic_len = len; in update_dynamic_len()
2869 size_t len = fmt->user_len; in __sort__hde_header()
2876 return scnprintf(hpp->buf, hpp->size, "%*.*s", len, len, hde->field->name); in __sort__hde_header()
2884 size_t len = fmt->user_len; in __sort__hde_width()
2900 return hists_to_evsel(hists) == hde->evsel; in perf_hpp__defined_dynamic_entry()
2907 size_t len = fmt->user_len; in __sort__hde_entry()
2919 if (hde->raw_trace) in __sort__hde_entry()
2922 if (!he->trace_output) in __sort__hde_entry()
2923 he->trace_output = get_trace_output(he); in __sort__hde_entry()
2925 field = hde->field; in __sort__hde_entry()
2926 namelen = strlen(field->name); in __sort__hde_entry()
2927 str = he->trace_output; in __sort__hde_entry()
2936 if (!strncmp(str, field->name, namelen)) { in __sort__hde_entry()
2938 str = strndup(str, pos - str); in __sort__hde_entry()
2941 return scnprintf(hpp->buf, hpp->size, in __sort__hde_entry()
2956 tep_print_field(&seq, he->raw_data, hde->field); in __sort__hde_entry()
2960 ret = scnprintf(hpp->buf, hpp->size, "%*.*s", len, len, str); in __sort__hde_entry()
2974 field = hde->field; in __sort__hde_cmp()
2975 if (field->flags & TEP_FIELD_IS_DYNAMIC) { in __sort__hde_cmp()
2978 tep_read_number_field(field, a->raw_data, &dyn); in __sort__hde_cmp()
2981 if (tep_field_is_relative(field->flags)) in __sort__hde_cmp()
2982 offset += field->offset + field->size; in __sort__hde_cmp()
2984 if (size > hde->dynamic_len) in __sort__hde_cmp()
2985 hde->dynamic_len = size; in __sort__hde_cmp()
2987 offset = field->offset; in __sort__hde_cmp()
2988 size = field->size; in __sort__hde_cmp()
2991 return memcmp(a->raw_data + offset, b->raw_data + offset, size); in __sort__hde_cmp()
2996 return fmt->cmp == __sort__hde_cmp; in perf_hpp__is_dynamic_entry()
3010 return hde_a->field == hde_b->field; in __sort__hde_equal()
3044 hde->evsel = evsel; in __alloc_dynamic_entry()
3045 hde->field = field; in __alloc_dynamic_entry()
3046 hde->dynamic_len = 0; in __alloc_dynamic_entry()
3048 hde->hpp.name = field->name; in __alloc_dynamic_entry()
3049 hde->hpp.header = __sort__hde_header; in __alloc_dynamic_entry()
3050 hde->hpp.width = __sort__hde_width; in __alloc_dynamic_entry()
3051 hde->hpp.entry = __sort__hde_entry; in __alloc_dynamic_entry()
3052 hde->hpp.color = NULL; in __alloc_dynamic_entry()
3054 hde->hpp.init = __sort__hde_init; in __alloc_dynamic_entry()
3055 hde->hpp.cmp = __sort__hde_cmp; in __alloc_dynamic_entry()
3056 hde->hpp.collapse = __sort__hde_cmp; in __alloc_dynamic_entry()
3057 hde->hpp.sort = __sort__hde_cmp; in __alloc_dynamic_entry()
3058 hde->hpp.equal = __sort__hde_equal; in __alloc_dynamic_entry()
3059 hde->hpp.free = hde_free; in __alloc_dynamic_entry()
3061 INIT_LIST_HEAD(&hde->hpp.list); in __alloc_dynamic_entry()
3062 INIT_LIST_HEAD(&hde->hpp.sort_list); in __alloc_dynamic_entry()
3063 hde->hpp.elide = false; in __alloc_dynamic_entry()
3064 hde->hpp.len = 0; in __alloc_dynamic_entry()
3065 hde->hpp.user_len = 0; in __alloc_dynamic_entry()
3066 hde->hpp.level = level; in __alloc_dynamic_entry()
3082 new_fmt = &new_hse->hpp; in perf_hpp_fmt__dup()
3090 new_fmt = &new_hde->hpp; in perf_hpp_fmt__dup()
3096 INIT_LIST_HEAD(&new_fmt->list); in perf_hpp_fmt__dup()
3097 INIT_LIST_HEAD(&new_fmt->sort_list); in perf_hpp_fmt__dup()
3142 if (nr > evlist->core.nr_entries) in find_evsel()
3146 while (--nr > 0) in find_evsel()
3158 if (!full_name && strstr(pos->name, event_name)) { in find_evsel()
3161 event_name, evsel->name, pos->name); in find_evsel()
3180 return -ENOMEM; in __dynamic_dimension__add()
3182 hde->raw_trace = raw_trace; in __dynamic_dimension__add()
3184 perf_hpp__register_sort_field(&hde->hpp); in __dynamic_dimension__add()
3193 field = evsel->tp_format->format.fields; in add_evsel_fields()
3199 field = field->next; in add_evsel_fields()
3211 if (evsel->core.attr.type != PERF_TYPE_TRACEPOINT) in add_all_dynamic_fields()
3224 int ret = -ESRCH; in add_all_matching_fields()
3229 if (evsel->core.attr.type != PERF_TYPE_TRACEPOINT) in add_all_matching_fields()
3232 field = tep_find_any_field(evsel->tp_format, field_name); in add_all_matching_fields()
3253 return -ENOENT; in add_dynamic_entry()
3257 return -ENOMEM; in add_dynamic_entry()
3260 ret = -EINVAL; in add_dynamic_entry()
3267 ret = -EINVAL; in add_dynamic_entry()
3285 if (evsel->core.attr.type == PERF_TYPE_TRACEPOINT) { in add_dynamic_entry()
3287 ret = -ENOTSUP; in add_dynamic_entry()
3300 ret = -ENOENT; in add_dynamic_entry()
3304 if (evsel->core.attr.type != PERF_TYPE_TRACEPOINT) { in add_dynamic_entry()
3306 ret = -EINVAL; in add_dynamic_entry()
3314 struct tep_format_field *field = tep_find_any_field(evsel->tp_format, field_name); in add_dynamic_entry()
3319 return -ENOENT; in add_dynamic_entry()
3338 if (sd->taken) in __sort_dimension__add()
3342 return -1; in __sort_dimension__add()
3344 if (sd->entry->se_collapse) in __sort_dimension__add()
3345 list->need_collapse = 1; in __sort_dimension__add()
3347 sd->taken = 1; in __sort_dimension__add()
3358 if (hd->taken) in __hpp_dimension__add()
3363 return -1; in __hpp_dimension__add()
3365 hd->taken = 1; in __hpp_dimension__add()
3373 if (sd->taken) in __sort_dimension__add_output()
3377 return -1; in __sort_dimension__add_output()
3379 sd->taken = 1; in __sort_dimension__add_output()
3388 if (hd->taken) in __hpp_dimension__add_output()
3393 return -1; in __hpp_dimension__add_output()
3395 hd->taken = 1; in __hpp_dimension__add_output()
3428 if (!sd->name || strncasecmp(tok, sd->name, strlen(tok))) in sort_dimension__add()
3432 if (sd->name && !strcmp(dynamic_headers[j], sd->name)) in sort_dimension__add()
3436 if (sd->entry == &sort_parent && parent_pattern) { in sort_dimension__add()
3443 return -EINVAL; in sort_dimension__add()
3445 list->parent = 1; in sort_dimension__add()
3446 } else if (sd->entry == &sort_sym) { in sort_dimension__add()
3447 list->sym = 1; in sort_dimension__add()
3455 sd->entry->se_collapse = sort__sym_sort; in sort_dimension__add()
3457 } else if (sd->entry == &sort_dso) { in sort_dimension__add()
3458 list->dso = 1; in sort_dimension__add()
3459 } else if (sd->entry == &sort_socket) { in sort_dimension__add()
3460 list->socket = 1; in sort_dimension__add()
3461 } else if (sd->entry == &sort_thread) { in sort_dimension__add()
3462 list->thread = 1; in sort_dimension__add()
3463 } else if (sd->entry == &sort_comm) { in sort_dimension__add()
3464 list->comm = 1; in sort_dimension__add()
3465 } else if (sd->entry == &sort_type_offset) { in sort_dimension__add()
3475 if (strncasecmp(tok, hd->name, strlen(tok))) in sort_dimension__add()
3484 if (!sd->name || strncasecmp(tok, sd->name, strlen(tok))) in sort_dimension__add()
3488 return -EINVAL; in sort_dimension__add()
3490 if (sd->entry == &sort_sym_from || sd->entry == &sort_sym_to) in sort_dimension__add()
3491 list->sym = 1; in sort_dimension__add()
3500 if (!sd->name || strncasecmp(tok, sd->name, strlen(tok))) in sort_dimension__add()
3504 return -EINVAL; in sort_dimension__add()
3506 if (sd->entry == &sort_mem_dcacheline && cacheline_size() == 0) in sort_dimension__add()
3507 return -EINVAL; in sort_dimension__add()
3509 if (sd->entry == &sort_mem_daddr_sym) in sort_dimension__add()
3510 list->sym = 1; in sort_dimension__add()
3519 return -ESRCH; in sort_dimension__add()
3551 if (ret == -EINVAL) { in setup_sort_list()
3553 …ui__error("The \"dcacheline\" --sort key needs to know the cacheline size and it couldn't be deter… in setup_sort_list()
3555 ui__error("Invalid --sort key: `%s'", tok); in setup_sort_list()
3557 } else if (ret == -ESRCH) { in setup_sort_list()
3558 ui__error("Unknown --sort key: `%s'", tok); in setup_sort_list()
3588 if (evsel->core.attr.type != PERF_TYPE_TRACEPOINT) { in get_default_sort_order()
3608 * Append '+'-prefixed sort order to the default sort in setup_sort_order()
3615 ui__error("Invalid --sort key: `+'"); in setup_sort_order()
3616 return -EINVAL; in setup_sort_order()
3625 pr_err("Not enough memory to set up --sort"); in setup_sort_order()
3626 return -ENOMEM; in setup_sort_order()
3690 return -ENOMEM; in __setup_sorting()
3700 return -ENOMEM; in __setup_sorting()
3720 if (hse->se->se_width_idx == idx) { in perf_hpp__set_elide()
3721 fmt->elide = elide; in perf_hpp__set_elide()
3732 strlist__entry(list, 0)->s); in __get_elide()
3784 fmt->elide = get_elide(hse->se->se_width_idx, output); in sort__setup_elide()
3795 if (!fmt->elide) in sort__setup_elide()
3803 fmt->elide = false; in sort__setup_elide()
3814 if (strncasecmp(tok, hd->name, strlen(tok))) in output_field_add()
3818 ui__warning("--fields weight shows the average value unlike in the --sort key.\n"); in output_field_add()
3826 if (!sd->name || strncasecmp(tok, sd->name, strlen(tok))) in output_field_add()
3835 if (!sd->name || strncasecmp(tok, sd->name, strlen(tok))) in output_field_add()
3839 return -EINVAL; in output_field_add()
3847 if (!sd->name || strncasecmp(tok, sd->name, strlen(tok))) in output_field_add()
3851 return -EINVAL; in output_field_add()
3856 return -ESRCH; in output_field_add()
3867 if (ret == -EINVAL) { in setup_output_list()
3868 ui__error("Invalid --fields key: `%s'", tok); in setup_output_list()
3870 } else if (ret == -ESRCH) { in setup_output_list()
3871 ui__error("Unknown --fields key: `%s'", tok); in setup_output_list()
3904 int ret = -EINVAL; in __setup_output_field()
3912 return -ENOMEM; in __setup_output_field()
3919 ui__error("Invalid --fields key: `+'"); in __setup_output_field()
3939 err = sort_dimension__add(&perf_hpp_list, "parent", evlist, -1); in setup_sorting()
3961 /* setup hists-specific output fields */ in setup_sorting()
3963 return -1; in setup_sorting()