linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Jiri Olsa <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, acme@redhat.com,
	eranian@google.com, dsahern@gmail.com, peterz@infradead.org,
	mingo@kernel.org, namhyung@kernel.org, jolsa@kernel.org,
	alexander.shishkin@linux.intel.com, hpa@zytor.com,
	tglx@linutronix.de
Subject: [tip:perf/urgent] perf annotate: Add support to toggle percent type
Date: Sat, 18 Aug 2018 04:33:45 -0700	[thread overview]
Message-ID: <tip-3e0d79531984c731951d9a8a5be406df3a78ac97@git.kernel.org> (raw)
In-Reply-To: <20180804130521.11408-17-jolsa@kernel.org>

Commit-ID:  3e0d79531984c731951d9a8a5be406df3a78ac97
Gitweb:     https://git.kernel.org/tip/3e0d79531984c731951d9a8a5be406df3a78ac97
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Sat, 4 Aug 2018 15:05:17 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 8 Aug 2018 15:55:52 -0300

perf annotate: Add support to toggle percent type

Add new key bindings to toggle percent type/base in annotation UI browser:

 'p' to switch between local and global percent type
 'b' to switch between hits and perdio percent base

Add the following help messages to the UI browser '?' window:

  ...
  p             Toggle percent type [local/global]
  b             Toggle percent base [period/hits]
  ...

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20180804130521.11408-17-jolsa@kernel.org
[ Moved percent_type to be the last arg to sym_title(), its an arg to what is being formmated (buf, size) ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/browsers/annotate.c | 52 ++++++++++++++++++++++++++++++++++++---
 tools/perf/util/annotate.h        | 16 ++++++++++++
 2 files changed, 64 insertions(+), 4 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 2a3a34d450d5..1d00e5ec7906 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -15,6 +15,7 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <sys/ttydefaults.h>
+#include <asm/bug.h>
 
 struct disasm_line_samples {
 	double		      percent;
@@ -383,9 +384,10 @@ static void ui_browser__init_asm_mode(struct ui_browser *browser)
 #define SYM_TITLE_MAX_SIZE (PATH_MAX + 64)
 
 static int sym_title(struct symbol *sym, struct map *map, char *title,
-		     size_t sz)
+		     size_t sz, int percent_type)
 {
-	return snprintf(title, sz, "%s  %s", sym->name, map->dso->long_name);
+	return snprintf(title, sz, "%s  %s [Percent: %s]", sym->name, map->dso->long_name,
+			percent_type_str(percent_type));
 }
 
 /*
@@ -423,7 +425,7 @@ static bool annotate_browser__callq(struct annotate_browser *browser,
 
 	pthread_mutex_unlock(&notes->lock);
 	symbol__tui_annotate(dl->ops.target.sym, ms->map, evsel, hbt, browser->opts);
-	sym_title(ms->sym, ms->map, title, sizeof(title));
+	sym_title(ms->sym, ms->map, title, sizeof(title), browser->opts->percent_type);
 	ui_browser__show_title(&browser->b, title);
 	return true;
 }
@@ -598,6 +600,7 @@ bool annotate_browser__continue_search_reverse(struct annotate_browser *browser,
 
 static int annotate_browser__show(struct ui_browser *browser, char *title, const char *help)
 {
+	struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
 	struct map_symbol *ms = browser->priv;
 	struct symbol *sym = ms->sym;
 	char symbol_dso[SYM_TITLE_MAX_SIZE];
@@ -605,7 +608,7 @@ static int annotate_browser__show(struct ui_browser *browser, char *title, const
 	if (ui_browser__show(browser, title, help) < 0)
 		return -1;
 
-	sym_title(sym, ms->map, symbol_dso, sizeof(symbol_dso));
+	sym_title(sym, ms->map, symbol_dso, sizeof(symbol_dso), ab->opts->percent_type);
 
 	ui_browser__gotorc_title(browser, 0, 0);
 	ui_browser__set_color(browser, HE_COLORSET_ROOT);
@@ -613,6 +616,39 @@ static int annotate_browser__show(struct ui_browser *browser, char *title, const
 	return 0;
 }
 
+static void
+switch_percent_type(struct annotation_options *opts, bool base)
+{
+	switch (opts->percent_type) {
+	case PERCENT_HITS_LOCAL:
+		if (base)
+			opts->percent_type = PERCENT_PERIOD_LOCAL;
+		else
+			opts->percent_type = PERCENT_HITS_GLOBAL;
+		break;
+	case PERCENT_HITS_GLOBAL:
+		if (base)
+			opts->percent_type = PERCENT_PERIOD_GLOBAL;
+		else
+			opts->percent_type = PERCENT_HITS_LOCAL;
+		break;
+	case PERCENT_PERIOD_LOCAL:
+		if (base)
+			opts->percent_type = PERCENT_HITS_LOCAL;
+		else
+			opts->percent_type = PERCENT_PERIOD_GLOBAL;
+		break;
+	case PERCENT_PERIOD_GLOBAL:
+		if (base)
+			opts->percent_type = PERCENT_HITS_GLOBAL;
+		else
+			opts->percent_type = PERCENT_PERIOD_LOCAL;
+		break;
+	default:
+		WARN_ON(1);
+	}
+}
+
 static int annotate_browser__run(struct annotate_browser *browser,
 				 struct perf_evsel *evsel,
 				 struct hist_browser_timer *hbt)
@@ -703,6 +739,8 @@ static int annotate_browser__run(struct annotate_browser *browser,
 		"k             Toggle line numbers\n"
 		"P             Print to [symbol_name].annotation file.\n"
 		"r             Run available scripts\n"
+		"p             Toggle percent type [local/global]\n"
+		"b             Toggle percent base [period/hits]\n"
 		"?             Search string backwards\n");
 			continue;
 		case 'r':
@@ -802,6 +840,12 @@ show_sup_ins:
 				notes->options->show_minmax_cycle = true;
 			annotation__update_column_widths(notes);
 			continue;
+		case 'p':
+		case 'b':
+			switch_percent_type(browser->opts, key == 'b');
+			hists__scnprintf_title(hists, title, sizeof(title));
+			annotate_browser__show(&browser->b, title, help);
+			continue;
 		case K_LEFT:
 		case K_ESC:
 		case 'q':
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index 3d4579e68d28..760a6678edff 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -11,6 +11,7 @@
 #include <linux/list.h>
 #include <linux/rbtree.h>
 #include <pthread.h>
+#include <asm/bug.h>
 
 struct ins_ops;
 
@@ -149,6 +150,21 @@ static inline double annotation_data__percent(struct annotation_data *data,
 	return which < PERCENT_MAX ? data->percent[which] : -1;
 }
 
+static inline const char *percent_type_str(unsigned int type)
+{
+	static const char *str[PERCENT_MAX] = {
+		"local hits",
+		"global hits",
+		"local period",
+		"global period",
+	};
+
+	if (WARN_ON(type >= PERCENT_MAX))
+		return "N/A";
+
+	return str[type];
+}
+
 static inline struct disasm_line *disasm_line(struct annotation_line *al)
 {
 	return al ? container_of(al, struct disasm_line, al) : NULL;

  parent reply	other threads:[~2018-08-18 11:34 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-04 13:05 [PATCH 00/20] perf annotate: Make symbol__annotate_fprintf2 local Jiri Olsa
2018-08-04 13:05 ` [PATCH 01/20] " Jiri Olsa
2018-08-06 15:00   ` Arnaldo Carvalho de Melo
2018-08-18 11:25   ` [tip:perf/urgent] perf annotate: Make symbol__annotate_fprintf2() local tip-bot for Jiri Olsa
2018-08-04 13:05 ` [PATCH 02/20] perf annotate: Make annotation_line__max_percent static Jiri Olsa
2018-08-06 15:01   ` Arnaldo Carvalho de Melo
2018-08-18 11:26   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2018-08-04 13:05 ` [PATCH 03/20] perf annotate: Get rid of annotation__scnprintf_samples_period Jiri Olsa
2018-08-06 15:07   ` Arnaldo Carvalho de Melo
2018-08-18 11:26   ` [tip:perf/urgent] perf annotate: Get rid of annotation__scnprintf_samples_period() tip-bot for Jiri Olsa
2018-08-04 13:05 ` [PATCH 04/20] perf annotate: Rename struct annotation_line::samples* to data* Jiri Olsa
2018-08-06 15:08   ` Arnaldo Carvalho de Melo
2018-08-18 11:27   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2018-08-04 13:05 ` [PATCH 05/20] perf annotate: Rename local sample variables to data Jiri Olsa
2018-08-06 15:09   ` Arnaldo Carvalho de Melo
2018-08-18 11:27   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2018-08-04 13:05 ` [PATCH 06/20] perf annotate: Rename hist to sym_hist in annotation__calc_percent Jiri Olsa
2018-08-06 15:10   ` Arnaldo Carvalho de Melo
2018-08-18 11:28   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2018-08-04 13:05 ` [PATCH 07/20] perf annotate: Loop group events directly " Jiri Olsa
2018-08-06 15:12   ` Arnaldo Carvalho de Melo
2018-08-18 11:28   ` [tip:perf/urgent] perf annotate: Loop group events directly in annotation__calc_percent() tip-bot for Jiri Olsa
2018-08-04 13:05 ` [PATCH 08/20] perf annotate: Switch struct annotation_data::percent to array Jiri Olsa
2018-08-06 15:14   ` Arnaldo Carvalho de Melo
2018-08-18 11:29   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2018-08-04 13:05 ` [PATCH 09/20] perf annotate: Add PERCENT_HITS_GLOBAL percent value Jiri Olsa
2018-08-06 15:15   ` Arnaldo Carvalho de Melo
2018-08-18 11:29   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2018-08-04 13:05 ` [PATCH 10/20] perf annotate: Add PERCENT_PERIOD_LOCAL " Jiri Olsa
2018-08-06 15:16   ` Arnaldo Carvalho de Melo
2018-08-18 11:30   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2018-08-04 13:05 ` [PATCH 11/20] perf annotate: Add PERCENT_PERIOD_GLOBAL " Jiri Olsa
2018-08-06 15:16   ` Arnaldo Carvalho de Melo
2018-08-18 11:30   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2018-08-04 13:05 ` [PATCH 12/20] perf annotate: Add percent_type to struct annotation_options Jiri Olsa
2018-08-06 15:17   ` Arnaldo Carvalho de Melo
2018-08-18 11:31   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2018-08-04 13:05 ` [PATCH 13/20] perf annotate: Pass struct annotation_options to symbol__calc_lines Jiri Olsa
2018-08-06 15:18   ` Arnaldo Carvalho de Melo
2018-08-18 11:32   ` [tip:perf/urgent] perf annotate: Pass struct annotation_options to symbol__calc_lines() tip-bot for Jiri Olsa
2018-08-04 13:05 ` [PATCH 14/20] perf annotate: Pass struct annotation_options to map_symbol__annotation_dump Jiri Olsa
2018-08-06 13:45   ` Namhyung Kim
2018-08-06 14:24     ` Jiri Olsa
2018-08-06 15:22       ` Arnaldo Carvalho de Melo
2018-08-06 15:29         ` Jiri Olsa
2018-08-18 11:32   ` [tip:perf/urgent] perf annotate: Pass 'struct annotation_options' to map_symbol__annotation_dump() tip-bot for Jiri Olsa
2018-08-04 13:05 ` [PATCH 15/20] perf annotate: Pass browser percent_type in annotate_browser__calc_percent Jiri Olsa
2018-08-06 15:23   ` Arnaldo Carvalho de Melo
2018-08-18 11:33   ` [tip:perf/urgent] perf annotate: Pass browser percent_type in annotate_browser__calc_percent() tip-bot for Jiri Olsa
2018-08-04 13:05 ` [PATCH 16/20] perf annotate: Add support to togle percent type Jiri Olsa
2018-08-06 18:24   ` Arnaldo Carvalho de Melo
2018-08-18 11:33   ` tip-bot for Jiri Olsa [this message]
2018-08-04 13:05 ` [PATCH 17/20] perf annotate: Make local period the default " Jiri Olsa
2018-08-06 18:26   ` Arnaldo Carvalho de Melo
2018-08-18 11:34   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2018-08-04 13:05 ` [PATCH 18/20] perf annotate: Display percent type in stdio output Jiri Olsa
2018-08-06 18:27   ` Arnaldo Carvalho de Melo
2018-08-18 11:34   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2018-08-04 13:05 ` [PATCH 19/20] perf annotate: Add --percent-type option Jiri Olsa
2018-08-06 13:49   ` Namhyung Kim
2018-08-06 14:26     ` Jiri Olsa
2018-08-06 18:33       ` Arnaldo Carvalho de Melo
2018-08-06 18:32   ` Arnaldo Carvalho de Melo
2018-08-18 11:35   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2018-08-04 13:05 ` [PATCH 20/20] perf report: " Jiri Olsa
2018-08-06 18:48   ` Arnaldo Carvalho de Melo
2018-08-18 11:35   ` [tip:perf/urgent] " tip-bot for Jiri Olsa

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=tip-3e0d79531984c731951d9a8a5be406df3a78ac97@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).