diff options
author | Jiri Olsa <jolsa@kernel.org> | 2018-08-04 09:05:04 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-08-08 14:55:46 -0400 |
commit | 0683d13c1afbf5cca147b6f578d1463be132b11b (patch) | |
tree | d628676f38dddd26e3f0066de9043126a3a9d7f3 /tools/perf/util/annotate.c | |
parent | 5ecf7d30eb4f9c046f5284f20133d7b69729c315 (diff) |
perf annotate: Get rid of annotation__scnprintf_samples_period()
We have more current function tto get the title for annotation,
which is hists__scnprintf_title. They both have same output as
far as the annotation's header line goes.
They differ in counting of the nr_samples, hists__scnprintf_title
provides more accurate number based on the setup of the
symbol_conf.filter_relative variable.
Plus it also displays any uid/thread/dso/socket filters/zooms
if there are set any, which annotation__scnprintf_samples_period
does not.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20180804130521.11408-4-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/annotate.c')
-rw-r--r-- | tools/perf/util/annotate.c | 44 |
1 files changed, 2 insertions, 42 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 956c9b19d81c..0d40cee13f6b 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -2389,7 +2389,7 @@ int symbol__tty_annotate2(struct symbol *sym, struct map *map, | |||
2389 | { | 2389 | { |
2390 | struct dso *dso = map->dso; | 2390 | struct dso *dso = map->dso; |
2391 | struct rb_root source_line = RB_ROOT; | 2391 | struct rb_root source_line = RB_ROOT; |
2392 | struct annotation *notes = symbol__annotation(sym); | 2392 | struct hists *hists = evsel__hists(evsel); |
2393 | char buf[1024]; | 2393 | char buf[1024]; |
2394 | 2394 | ||
2395 | if (symbol__annotate2(sym, map, evsel, opts, NULL) < 0) | 2395 | if (symbol__annotate2(sym, map, evsel, opts, NULL) < 0) |
@@ -2401,7 +2401,7 @@ int symbol__tty_annotate2(struct symbol *sym, struct map *map, | |||
2401 | print_summary(&source_line, dso->long_name); | 2401 | print_summary(&source_line, dso->long_name); |
2402 | } | 2402 | } |
2403 | 2403 | ||
2404 | annotation__scnprintf_samples_period(notes, buf, sizeof(buf), evsel); | 2404 | hists__scnprintf_title(hists, buf, sizeof(buf)); |
2405 | fprintf(stdout, "%s\n%s() %s\n", buf, sym->name, dso->long_name); | 2405 | fprintf(stdout, "%s\n%s() %s\n", buf, sym->name, dso->long_name); |
2406 | symbol__annotate_fprintf2(sym, stdout); | 2406 | symbol__annotate_fprintf2(sym, stdout); |
2407 | 2407 | ||
@@ -2689,46 +2689,6 @@ out_free_offsets: | |||
2689 | return -1; | 2689 | return -1; |
2690 | } | 2690 | } |
2691 | 2691 | ||
2692 | int __annotation__scnprintf_samples_period(struct annotation *notes, | ||
2693 | char *bf, size_t size, | ||
2694 | struct perf_evsel *evsel, | ||
2695 | bool show_freq) | ||
2696 | { | ||
2697 | const char *ev_name = perf_evsel__name(evsel); | ||
2698 | char buf[1024], ref[30] = " show reference callgraph, "; | ||
2699 | char sample_freq_str[64] = ""; | ||
2700 | unsigned long nr_samples = 0; | ||
2701 | int nr_members = 1; | ||
2702 | bool enable_ref = false; | ||
2703 | u64 nr_events = 0; | ||
2704 | char unit; | ||
2705 | int i; | ||
2706 | |||
2707 | if (perf_evsel__is_group_event(evsel)) { | ||
2708 | perf_evsel__group_desc(evsel, buf, sizeof(buf)); | ||
2709 | ev_name = buf; | ||
2710 | nr_members = evsel->nr_members; | ||
2711 | } | ||
2712 | |||
2713 | for (i = 0; i < nr_members; i++) { | ||
2714 | struct sym_hist *ah = annotation__histogram(notes, evsel->idx + i); | ||
2715 | |||
2716 | nr_samples += ah->nr_samples; | ||
2717 | nr_events += ah->period; | ||
2718 | } | ||
2719 | |||
2720 | if (symbol_conf.show_ref_callgraph && strstr(ev_name, "call-graph=no")) | ||
2721 | enable_ref = true; | ||
2722 | |||
2723 | if (show_freq) | ||
2724 | scnprintf(sample_freq_str, sizeof(sample_freq_str), " %d Hz,", evsel->attr.sample_freq); | ||
2725 | |||
2726 | nr_samples = convert_unit(nr_samples, &unit); | ||
2727 | return scnprintf(bf, size, "Samples: %lu%c of event%s '%s',%s%sEvent count (approx.): %" PRIu64, | ||
2728 | nr_samples, unit, evsel->nr_members > 1 ? "s" : "", | ||
2729 | ev_name, sample_freq_str, enable_ref ? ref : " ", nr_events); | ||
2730 | } | ||
2731 | |||
2732 | #define ANNOTATION__CFG(n) \ | 2692 | #define ANNOTATION__CFG(n) \ |
2733 | { .name = #n, .value = &annotation__default_options.n, } | 2693 | { .name = #n, .value = &annotation__default_options.n, } |
2734 | 2694 | ||