perf report: Add processing for cycle histograms
authorAndi Kleen <ak@linux.intel.com>
Sat, 18 Jul 2015 15:24:49 +0000 (08:24 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 6 Aug 2015 19:35:30 +0000 (16:35 -0300)
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>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1437233094-12844-5-git-send-email-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-report.c
tools/perf/util/hist.c
tools/perf/util/hist.h

index 3ba0e9737dc578ad406ad65e88ff96d44ad36d89..3a9d1b659fcd353a1b4df9222c13b83cda045efb 100644 (file)
@@ -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);
index 54fc0033dd6af5fdfffac2b43e52cbd62e1892f8..a6e9ddd37913088c7a427d8c97a55c59e5de3813 100644 (file)
@@ -1415,6 +1415,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)
 {
index 3881d98153093dd3b712f28a112414cffa6256c2..e2f712f85d2e401b5f906b04b564cb86d9917e9b 100644 (file)
@@ -350,6 +350,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);
This page took 0.029218 seconds and 5 git commands to generate.