From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Andi Kleen <ak@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 16/26] perf report: Add processing for cycle histograms
Date: Thu, 6 Aug 2015 22:58:25 -0300 [thread overview]
Message-ID: <1438912715-4000-17-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1438912715-4000-1-git-send-email-acme@kernel.org>
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>
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 | 3 +++
tools/perf/util/hist.c | 33 +++++++++++++++++++++++++++++++++
tools/perf/util/hist.h | 3 +++
3 files changed, 39 insertions(+)
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 3ba0e9737dc5..3a9d1b659fcd 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);
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 54fc0033dd6a..a6e9ddd37913 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -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)
{
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 3881d9815309..e2f712f85d2e 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -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);
--
2.1.0
next prev parent reply other threads:[~2015-08-07 2:01 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-07 1:58 [GIT PULL 00/26] perf/core improvements and fixes Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 01/26] perf trace: Add total time column to summary Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 02/26] bpf: Use correct #ifdef controller for trace_call_bpf() Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 03/26] tracing, perf: Implement BPF programs attached to uprobes Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 04/26] perf tools: Introduce veprintf Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 05/26] perf tools: Add missing forward declaration of struct map to probe-event.h Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 06/26] perf stat: Introduce struct perf_stat_config Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 07/26] perf stat: Move 'scale' into " Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 08/26] perf stat: Move 'output' " Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 09/26] perf stat: Move 'interval' " Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 10/26] perf stat: Pass 'struct perf_stat_config' into process_counter() Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 11/26] perf stat: Move counter processing code into stat object Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 12/26] perf tools: Add empty Build files for architectures lacking them Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 13/26] perf tools: Add support for cycles, weight branch_info field Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 14/26] perf report: Add flag for non ANY branch mode Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 15/26] perf report: Add infrastructure for a cycles histogram Arnaldo Carvalho de Melo
2015-08-07 1:58 ` Arnaldo Carvalho de Melo [this message]
2015-08-07 1:58 ` [PATCH 17/26] perf annotate: Compute IPC and basic block cycles Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 18/26] perf annotate: Finally display IPC and cycle accounting Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 19/26] perf top: Add branch annotation code to top Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 20/26] perf report: Display cycles in branch sort mode Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 21/26] perf tools xtensa: Add DWARF register names Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 22/26] perf auxtrace: Fix period type 'i' not working Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 23/26] perf tools: Fix perf-with-kcore handling of arguments containing spaces Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 24/26] perf tools: Add perf_pmu__format_bits() Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 25/26] perf tools: Validate config term maximum value Arnaldo Carvalho de Melo
2015-08-07 1:58 ` [PATCH 26/26] perf tools: Extend the event parser maximum error index Arnaldo Carvalho de Melo
2015-08-07 7:13 ` [GIT PULL 00/26] perf/core improvements and fixes Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1438912715-4000-17-git-send-email-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=ak@linux.intel.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.