lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1431265926-4766-7-git-send-email-andi@firstfloor.org>
Date:	Sun, 10 May 2015 06:52:02 -0700
From:	Andi Kleen <andi@...stfloor.org>
To:	acme@...nel.org
Cc:	jolsa@...hat.com, linux-kernel@...r.kernel.org,
	namhyung@...nel.org, eranian@...gle.com,
	Andi Kleen <ak@...ux.intel.com>
Subject: [PATCH 06/10] perf, tools, annotate: Finally display IPC and cycle accounting

From: Andi Kleen <ak@...ux.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 13.67     │       push   %rbp
  0.01 13.67     │       mov    %rsp,%rbp
                 │            c = a / b;
  9.87 13.67     │       mov    a,%eax
       13.67     │       mov    b,%ecx
       13.67     │       cltd
  4.92 13.67  123│       idiv   %ecx
 70.79 13.67     │       mov    %eax,__TMC_END__
                 │    }
  9.25 13.67     │       pop    %rbp
  0.01 13.67  123│     ← retq

Signed-off-by: Andi Kleen <ak@...ux.intel.com>
---
 tools/perf/ui/browsers/annotate.c | 50 +++++++++++++++++++++++++++++----------
 1 file changed, 38 insertions(+), 12 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 6c135b5..af22061 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -11,6 +11,9 @@
 #include "../../util/evsel.h"
 #include <pthread.h>
 
+#define IPC_WIDTH 6
+#define CYCLES_WIDTH 6
+
 struct browser_disasm_line {
 	struct rb_node	rb_node;
 	u32		idx;
@@ -91,6 +94,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);
@@ -101,7 +113,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];
 
@@ -110,11 +122,29 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
 			percent_max = bdl->percent[i];
 	}
 
-	if (dl->offset != -1 && percent_max != 0.0) {
-		for (i = 0; i < ab->nr_events; i++) {
-			ui_browser__set_percent_color(browser, bdl->percent[i],
-						      current_entry);
-			slsmg_printf("%6.2f ", bdl->percent[i]);
+	if (dl->offset != -1) {
+		if (percent_max != 0.0) {
+			for (i = 0; i < ab->nr_events; i++) {
+				ui_browser__set_percent_color(browser,
+							      bdl->percent[i],
+							      current_entry);
+				slsmg_printf("%6.2f ", bdl->percent[i]);
+			}
+		} else {
+			slsmg_write_nstring(" ", 7 * ab->nr_events);
+		}
+
+		if (ab->have_cycles) {
+			ui_browser__set_color(browser, HE_COLORSET_NORMAL);
+			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);
 		}
 	} else {
 		ui_browser__set_percent_color(browser, 0, current_entry);
@@ -221,7 +251,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"))
@@ -245,8 +275,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);
@@ -256,9 +284,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);
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ