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 18/26] perf annotate: Finally display IPC and cycle accounting
Date: Thu, 6 Aug 2015 22:58:27 -0300 [thread overview]
Message-ID: <1438912715-4000-19-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>
Add two new columns to the annotate display and display the average
cycles and the compute IPC if available.
When the LBR was not in any branch mode the IPC computation is
automatically disabled. We still display the cycle information.
Example output (with made up numbers):
The second column is the IPC and third average cycles.
│ __attribute__((noinline)) f2()
│ {
5.15 0.07 │ push %rbp
0.01 0.07 │ mov %rsp,%rbp
│ c = a / b;
9.87 0.07 │ mov a,%eax
0.07 │ mov b,%ecx
0.07 │ cltd
4.92 0.07 123│ idiv %ecx
70.79 0.07 │ mov %eax,__TMC_END__
│ }
9.25 0.07 │ pop %rbp
0.01 0.07 123│ ← retq
v2: Fix display problems.
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-7-git-send-email-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/ui/browsers/annotate.c | 57 +++++++++++++++++++++++++++------------
1 file changed, 40 insertions(+), 17 deletions(-)
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 6ec179547f72..b5fc847f9660 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -16,6 +16,9 @@ struct disasm_line_samples {
u64 nr;
};
+#define IPC_WIDTH 6
+#define CYCLES_WIDTH 6
+
struct browser_disasm_line {
struct rb_node rb_node;
u32 idx;
@@ -97,6 +100,15 @@ static int annotate_browser__set_jumps_percent_color(struct annotate_browser *br
return ui_browser__set_color(&browser->b, color);
}
+static int annotate_browser__pcnt_width(struct annotate_browser *ab)
+{
+ int w = 7 * ab->nr_events;
+
+ if (ab->have_cycles)
+ w += IPC_WIDTH + CYCLES_WIDTH;
+ return w;
+}
+
static void annotate_browser__write(struct ui_browser *browser, void *entry, int row)
{
struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
@@ -107,7 +119,7 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
(!current_entry || (browser->use_navkeypressed &&
!browser->navkeypressed)));
int width = browser->width, printed;
- int i, pcnt_width = 7 * ab->nr_events;
+ int i, pcnt_width = annotate_browser__pcnt_width(ab);
double percent_max = 0.0;
char bf[256];
@@ -117,19 +129,34 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
}
if (dl->offset != -1 && percent_max != 0.0) {
- for (i = 0; i < ab->nr_events; i++) {
- ui_browser__set_percent_color(browser,
- bdl->samples[i].percent,
- current_entry);
- if (annotate_browser__opts.show_total_period)
- slsmg_printf("%6" PRIu64 " ",
- bdl->samples[i].nr);
- else
- slsmg_printf("%6.2f ", bdl->samples[i].percent);
+ if (percent_max != 0.0) {
+ for (i = 0; i < ab->nr_events; i++) {
+ ui_browser__set_percent_color(browser,
+ bdl->samples[i].percent,
+ current_entry);
+ if (annotate_browser__opts.show_total_period)
+ slsmg_printf("%6" PRIu64 " ",
+ bdl->samples[i].nr);
+ else
+ slsmg_printf("%6.2f ", bdl->samples[i].percent);
+ }
+ } else {
+ slsmg_write_nstring(" ", 7 * ab->nr_events);
}
} else {
ui_browser__set_percent_color(browser, 0, current_entry);
- slsmg_write_nstring(" ", pcnt_width);
+ slsmg_write_nstring(" ", 7 * ab->nr_events);
+ }
+ if (ab->have_cycles) {
+ if (dl->ipc)
+ slsmg_printf("%*.2f ", IPC_WIDTH - 1, dl->ipc);
+ else
+ slsmg_write_nstring(" ", IPC_WIDTH);
+ if (dl->cycles)
+ slsmg_printf("%*" PRIu64 " ",
+ CYCLES_WIDTH - 1, dl->cycles);
+ else
+ slsmg_write_nstring(" ", CYCLES_WIDTH);
}
SLsmg_write_char(' ');
@@ -232,7 +259,7 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser)
unsigned int from, to;
struct map_symbol *ms = ab->b.priv;
struct symbol *sym = ms->sym;
- u8 pcnt_width = 7;
+ u8 pcnt_width = annotate_browser__pcnt_width(ab);
/* PLT symbols contain external offsets */
if (strstr(sym->name, "@plt"))
@@ -256,8 +283,6 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser)
to = (u64)btarget->idx;
}
- pcnt_width *= ab->nr_events;
-
ui_browser__set_color(browser, HE_COLORSET_CODE);
__ui_browser__line_arrow(browser, pcnt_width + 2 + ab->addr_width,
from, to);
@@ -267,9 +292,7 @@ static unsigned int annotate_browser__refresh(struct ui_browser *browser)
{
struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
int ret = ui_browser__list_head_refresh(browser);
- int pcnt_width;
-
- pcnt_width = 7 * ab->nr_events;
+ int pcnt_width = annotate_browser__pcnt_width(ab);
if (annotate_browser__opts.jump_arrows)
annotate_browser__draw_current_jump(browser);
--
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 ` [PATCH 16/26] perf report: Add processing for cycle histograms Arnaldo Carvalho de Melo
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 ` Arnaldo Carvalho de Melo [this message]
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-19-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.