Commit ed9eb845d7916b2bc863e5b93c82e18be8faf032

Authored by Ingo Molnar

Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/g…

…it/acme/linux into perf/urgent

Pull perf/urgent fixes from Arnaldo Carvalho de Melo:

"
  - 'perf probe' should fall back to find probe point in symbols when failing
    to do so in a debuginfo file (Masami Hiramatsu)

  - Fix 'perf probe' crash in dwarf_getcfi_elf (Namhyung Kim)

  - Fix shell completion with 'perf list' --raw-dump option (Taesoo Kim)

  - Fix 'perf diff' to sort by baseline field by default (Namhyung Kim)
"

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>

Showing 4 changed files Side-by-side Diff

tools/perf/builtin-diff.c
... ... @@ -545,6 +545,42 @@
545 545 return __hist_entry__cmp_compute(p_left, p_right, c);
546 546 }
547 547  
  548 +static int64_t
  549 +hist_entry__cmp_nop(struct hist_entry *left __maybe_unused,
  550 + struct hist_entry *right __maybe_unused)
  551 +{
  552 + return 0;
  553 +}
  554 +
  555 +static int64_t
  556 +hist_entry__cmp_baseline(struct hist_entry *left, struct hist_entry *right)
  557 +{
  558 + if (sort_compute)
  559 + return 0;
  560 +
  561 + if (left->stat.period == right->stat.period)
  562 + return 0;
  563 + return left->stat.period > right->stat.period ? 1 : -1;
  564 +}
  565 +
  566 +static int64_t
  567 +hist_entry__cmp_delta(struct hist_entry *left, struct hist_entry *right)
  568 +{
  569 + return hist_entry__cmp_compute(right, left, COMPUTE_DELTA);
  570 +}
  571 +
  572 +static int64_t
  573 +hist_entry__cmp_ratio(struct hist_entry *left, struct hist_entry *right)
  574 +{
  575 + return hist_entry__cmp_compute(right, left, COMPUTE_RATIO);
  576 +}
  577 +
  578 +static int64_t
  579 +hist_entry__cmp_wdiff(struct hist_entry *left, struct hist_entry *right)
  580 +{
  581 + return hist_entry__cmp_compute(right, left, COMPUTE_WEIGHTED_DIFF);
  582 +}
  583 +
548 584 static void insert_hist_entry_by_compute(struct rb_root *root,
549 585 struct hist_entry *he,
550 586 int c)
551 587  
552 588  
553 589  
554 590  
555 591  
556 592  
... ... @@ -1038,27 +1074,35 @@
1038 1074 fmt->header = hpp__header;
1039 1075 fmt->width = hpp__width;
1040 1076 fmt->entry = hpp__entry_global;
  1077 + fmt->cmp = hist_entry__cmp_nop;
  1078 + fmt->collapse = hist_entry__cmp_nop;
1041 1079  
1042 1080 /* TODO more colors */
1043 1081 switch (idx) {
1044 1082 case PERF_HPP_DIFF__BASELINE:
1045 1083 fmt->color = hpp__color_baseline;
  1084 + fmt->sort = hist_entry__cmp_baseline;
1046 1085 break;
1047 1086 case PERF_HPP_DIFF__DELTA:
1048 1087 fmt->color = hpp__color_delta;
  1088 + fmt->sort = hist_entry__cmp_delta;
1049 1089 break;
1050 1090 case PERF_HPP_DIFF__RATIO:
1051 1091 fmt->color = hpp__color_ratio;
  1092 + fmt->sort = hist_entry__cmp_ratio;
1052 1093 break;
1053 1094 case PERF_HPP_DIFF__WEIGHTED_DIFF:
1054 1095 fmt->color = hpp__color_wdiff;
  1096 + fmt->sort = hist_entry__cmp_wdiff;
1055 1097 break;
1056 1098 default:
  1099 + fmt->sort = hist_entry__cmp_nop;
1057 1100 break;
1058 1101 }
1059 1102  
1060 1103 init_header(d, dfmt);
1061 1104 perf_hpp__column_register(fmt);
  1105 + perf_hpp__register_sort_field(fmt);
1062 1106 }
1063 1107  
1064 1108 static void ui_init(void)
tools/perf/builtin-list.c
... ... @@ -19,7 +19,9 @@
19 19 int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
20 20 {
21 21 int i;
22   - const struct option list_options[] = {
  22 + bool raw_dump = false;
  23 + struct option list_options[] = {
  24 + OPT_BOOLEAN(0, "raw-dump", &raw_dump, "Dump raw events"),
23 25 OPT_END()
24 26 };
25 27 const char * const list_usage[] = {
26 28  
... ... @@ -27,11 +29,18 @@
27 29 NULL
28 30 };
29 31  
  32 + set_option_flag(list_options, 0, "raw-dump", PARSE_OPT_HIDDEN);
  33 +
30 34 argc = parse_options(argc, argv, list_options, list_usage,
31 35 PARSE_OPT_STOP_AT_NON_OPTION);
32 36  
33 37 setup_pager();
34 38  
  39 + if (raw_dump) {
  40 + print_events(NULL, true);
  41 + return 0;
  42 + }
  43 +
35 44 if (argc == 0) {
36 45 print_events(NULL, false);
37 46 return 0;
... ... @@ -53,8 +62,6 @@
53 62 print_hwcache_events(NULL, false);
54 63 else if (strcmp(argv[i], "pmu") == 0)
55 64 print_pmu_events(NULL, false);
56   - else if (strcmp(argv[i], "--raw-dump") == 0)
57   - print_events(NULL, true);
58 65 else {
59 66 char *sep = strchr(argv[i], ':'), *s;
60 67 int sep_idx;
tools/perf/util/probe-event.c
... ... @@ -495,9 +495,11 @@
495 495 }
496 496  
497 497 if (ntevs == 0) { /* No error but failed to find probe point. */
498   - pr_warning("Probe point '%s' not found.\n",
  498 + pr_warning("Probe point '%s' not found in debuginfo.\n",
499 499 synthesize_perf_probe_point(&pev->point));
500   - return -ENOENT;
  500 + if (need_dwarf)
  501 + return -ENOENT;
  502 + return 0;
501 503 }
502 504 /* Error path : ntevs < 0 */
503 505 pr_debug("An error occurred in debuginfo analysis (%d).\n", ntevs);
tools/perf/util/probe-finder.c
... ... @@ -989,8 +989,24 @@
989 989 int ret = 0;
990 990  
991 991 #if _ELFUTILS_PREREQ(0, 142)
  992 + Elf *elf;
  993 + GElf_Ehdr ehdr;
  994 + GElf_Shdr shdr;
  995 +
992 996 /* Get the call frame information from this dwarf */
993   - pf->cfi = dwarf_getcfi_elf(dwarf_getelf(dbg->dbg));
  997 + elf = dwarf_getelf(dbg->dbg);
  998 + if (elf == NULL)
  999 + return -EINVAL;
  1000 +
  1001 + if (gelf_getehdr(elf, &ehdr) == NULL)
  1002 + return -EINVAL;
  1003 +
  1004 + if (elf_section_by_name(elf, &ehdr, &shdr, ".eh_frame", NULL) &&
  1005 + shdr.sh_type == SHT_PROGBITS) {
  1006 + pf->cfi = dwarf_getcfi_elf(elf);
  1007 + } else {
  1008 + pf->cfi = dwarf_getcfi(dbg->dbg);
  1009 + }
994 1010 #endif
995 1011  
996 1012 off = 0;