lkml.org 
[lkml]   [2015]   [May]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 05/11] perf, tools, report: Add processing for cycle histograms
Date
From: Andi Kleen <ak@linux.intel.com>

Call the earlier added cycle histogram infrastructure from the perf report
hist iter callback. For this we walk the branch records.

This allows to use cycle histograms when browsing perf report annotate.

v2: Rename flag
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
tools/perf/builtin-report.c | 4 +++-
tools/perf/util/hist.c | 33 +++++++++++++++++++++++++++++++++
tools/perf/util/hist.h | 3 +++
3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index bb15896..b2b1232 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -103,6 +103,9 @@ static int hist_iter__report_callback(struct hist_entry_iter *iter,
if (!ui__has_annotation())
return 0;

+ hist__account_cycles(iter->sample->branch_stack, al, iter->sample,
+ rep->nonany_branch_mode);
+
if (sort__mode == SORT_MODE__BRANCH) {
bi = he->branch_info;
err = addr_map_symbol__inc_samples(&bi->from, evsel->idx);
@@ -110,7 +113,6 @@ static int hist_iter__report_callback(struct hist_entry_iter *iter,
goto out;

err = addr_map_symbol__inc_samples(&bi->to, evsel->idx);
-
} else if (rep->mem_mode) {
mi = he->mem_info;
err = addr_map_symbol__inc_samples(&mi->daddr, evsel->idx);
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 302fc05..6f1e411 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1412,6 +1412,39 @@ int hists__link(struct hists *leader, struct hists *other)
return 0;
}

+void hist__account_cycles(struct branch_stack *bs, struct addr_location *al,
+ struct perf_sample *sample, bool nonany_branch_mode)
+{
+ struct branch_info *bi;
+
+ /* If we have branch cycles always annotate them. */
+ if (bs && bs->nr && bs->entries[0].flags.cycles) {
+ int i;
+
+ bi = sample__resolve_bstack(sample, al);
+ if (bi) {
+ struct addr_map_symbol *prev = NULL;
+
+ /*
+ * Ignore errors, still want to process the
+ * other entries.
+ *
+ * For non standard branch modes always
+ * force no IPC (prev == NULL)
+ *
+ * Note that perf stores branches reversed from
+ * program order!
+ */
+ for (i = bs->nr - 1; i >= 0; i--) {
+ addr_map_symbol__account_cycles(&bi[i].from,
+ nonany_branch_mode ? NULL : prev,
+ bi[i].flags.cycles);
+ prev = &bi[i].to;
+ }
+ free(bi);
+ }
+ }
+}

size_t perf_evlist__fprintf_nr_events(struct perf_evlist *evlist, FILE *fp)
{
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index b55c904..77e5739 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -351,6 +351,9 @@ static inline int script_browse(const char *script_opt __maybe_unused)

unsigned int hists__sort_list_width(struct hists *hists);

+void hist__account_cycles(struct branch_stack *bs, struct addr_location *al,
+ struct perf_sample *sample, bool nonany_branch_mode);
+
struct option;
int parse_filter_percentage(const struct option *opt __maybe_unused,
const char *arg, int unset __maybe_unused);
--
2.1.0


\
 
 \ /
  Last update: 2015-05-27 20:41    [W:0.124 / U:0.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site