Skip to content

Commit

Permalink
Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/lin…
Browse files Browse the repository at this point in the history
…ux/kernel/git/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>
  • Loading branch information
Ingo Molnar committed Jan 8, 2015
2 parents 5b5e762 + e7024fc commit ed9eb84
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 6 deletions.
44 changes: 44 additions & 0 deletions tools/perf/builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,42 @@ hist_entry__cmp_compute(struct hist_entry *left, struct hist_entry *right,
return __hist_entry__cmp_compute(p_left, p_right, c);
}

static int64_t
hist_entry__cmp_nop(struct hist_entry *left __maybe_unused,
struct hist_entry *right __maybe_unused)
{
return 0;
}

static int64_t
hist_entry__cmp_baseline(struct hist_entry *left, struct hist_entry *right)
{
if (sort_compute)
return 0;

if (left->stat.period == right->stat.period)
return 0;
return left->stat.period > right->stat.period ? 1 : -1;
}

static int64_t
hist_entry__cmp_delta(struct hist_entry *left, struct hist_entry *right)
{
return hist_entry__cmp_compute(right, left, COMPUTE_DELTA);
}

static int64_t
hist_entry__cmp_ratio(struct hist_entry *left, struct hist_entry *right)
{
return hist_entry__cmp_compute(right, left, COMPUTE_RATIO);
}

static int64_t
hist_entry__cmp_wdiff(struct hist_entry *left, struct hist_entry *right)
{
return hist_entry__cmp_compute(right, left, COMPUTE_WEIGHTED_DIFF);
}

static void insert_hist_entry_by_compute(struct rb_root *root,
struct hist_entry *he,
int c)
Expand Down Expand Up @@ -1038,27 +1074,35 @@ static void data__hpp_register(struct data__file *d, int idx)
fmt->header = hpp__header;
fmt->width = hpp__width;
fmt->entry = hpp__entry_global;
fmt->cmp = hist_entry__cmp_nop;
fmt->collapse = hist_entry__cmp_nop;

/* TODO more colors */
switch (idx) {
case PERF_HPP_DIFF__BASELINE:
fmt->color = hpp__color_baseline;
fmt->sort = hist_entry__cmp_baseline;
break;
case PERF_HPP_DIFF__DELTA:
fmt->color = hpp__color_delta;
fmt->sort = hist_entry__cmp_delta;
break;
case PERF_HPP_DIFF__RATIO:
fmt->color = hpp__color_ratio;
fmt->sort = hist_entry__cmp_ratio;
break;
case PERF_HPP_DIFF__WEIGHTED_DIFF:
fmt->color = hpp__color_wdiff;
fmt->sort = hist_entry__cmp_wdiff;
break;
default:
fmt->sort = hist_entry__cmp_nop;
break;
}

init_header(d, dfmt);
perf_hpp__column_register(fmt);
perf_hpp__register_sort_field(fmt);
}

static void ui_init(void)
Expand Down
13 changes: 10 additions & 3 deletions tools/perf/builtin-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,28 @@
int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
{
int i;
const struct option list_options[] = {
bool raw_dump = false;
struct option list_options[] = {
OPT_BOOLEAN(0, "raw-dump", &raw_dump, "Dump raw events"),
OPT_END()
};
const char * const list_usage[] = {
"perf list [hw|sw|cache|tracepoint|pmu|event_glob]",
NULL
};

set_option_flag(list_options, 0, "raw-dump", PARSE_OPT_HIDDEN);

argc = parse_options(argc, argv, list_options, list_usage,
PARSE_OPT_STOP_AT_NON_OPTION);

setup_pager();

if (raw_dump) {
print_events(NULL, true);
return 0;
}

if (argc == 0) {
print_events(NULL, false);
return 0;
Expand All @@ -53,8 +62,6 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
print_hwcache_events(NULL, false);
else if (strcmp(argv[i], "pmu") == 0)
print_pmu_events(NULL, false);
else if (strcmp(argv[i], "--raw-dump") == 0)
print_events(NULL, true);
else {
char *sep = strchr(argv[i], ':'), *s;
int sep_idx;
Expand Down
6 changes: 4 additions & 2 deletions tools/perf/util/probe-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,9 +495,11 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev,
}

if (ntevs == 0) { /* No error but failed to find probe point. */
pr_warning("Probe point '%s' not found.\n",
pr_warning("Probe point '%s' not found in debuginfo.\n",
synthesize_perf_probe_point(&pev->point));
return -ENOENT;
if (need_dwarf)
return -ENOENT;
return 0;
}
/* Error path : ntevs < 0 */
pr_debug("An error occurred in debuginfo analysis (%d).\n", ntevs);
Expand Down
18 changes: 17 additions & 1 deletion tools/perf/util/probe-finder.c
Original file line number Diff line number Diff line change
Expand Up @@ -989,8 +989,24 @@ static int debuginfo__find_probes(struct debuginfo *dbg,
int ret = 0;

#if _ELFUTILS_PREREQ(0, 142)
Elf *elf;
GElf_Ehdr ehdr;
GElf_Shdr shdr;

/* Get the call frame information from this dwarf */
pf->cfi = dwarf_getcfi_elf(dwarf_getelf(dbg->dbg));
elf = dwarf_getelf(dbg->dbg);
if (elf == NULL)
return -EINVAL;

if (gelf_getehdr(elf, &ehdr) == NULL)
return -EINVAL;

if (elf_section_by_name(elf, &ehdr, &shdr, ".eh_frame", NULL) &&
shdr.sh_type == SHT_PROGBITS) {
pf->cfi = dwarf_getcfi_elf(elf);
} else {
pf->cfi = dwarf_getcfi(dbg->dbg);
}
#endif

off = 0;
Expand Down

0 comments on commit ed9eb84

Please sign in to comment.