linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] perf annotate/config: More fixes
@ 2020-02-13  6:42 Ravi Bangoria
  2020-02-13  6:42 ` [PATCH 1/8] perf annotate/tui: Re-render title bar after switching back from script browser Ravi Bangoria
                   ` (9 more replies)
  0 siblings, 10 replies; 26+ messages in thread
From: Ravi Bangoria @ 2020-02-13  6:42 UTC (permalink / raw)
  To: acme, jolsa
  Cc: xieyisheng1, alexey.budankov, treeze.taeung, adrian.hunter,
	tmricht, namhyung, irogers, songliubraving, yao.jin, changbin.du,
	leo.yan, linux-kernel, Ravi Bangoria

These are the additional set of fixes on top of previous series:
http://lore.kernel.org/r/20200204045233.474937-1-ravi.bangoria@linux.ibm.com

Note for the last patch:
I couldn't understand what intel-pt.cache-divisor is really used for.
Adrian, can you please help.

Ravi Bangoria (8):
  perf annotate/tui: Re-render title bar after switching back from
    script browser
  perf annotate: Fix --show-total-period for tui/stdio2
  perf annotate: Fix --show-nr-samples for tui/stdio2
  perf config: Introduce perf_config_u8()
  perf annotate: Make perf config effective
  perf annotate: Prefer cmdline option over default config
  perf annotate: Fix perf config option description
  perf config: Document missing config options

 tools/perf/Documentation/perf-config.txt | 74 +++++++++++++++++++-
 tools/perf/builtin-annotate.c            |  4 +-
 tools/perf/builtin-report.c              |  2 +-
 tools/perf/builtin-top.c                 |  2 +-
 tools/perf/ui/browsers/annotate.c        | 19 +++--
 tools/perf/util/annotate.c               | 89 +++++++++---------------
 tools/perf/util/annotate.h               |  6 +-
 tools/perf/util/config.c                 | 12 ++++
 tools/perf/util/config.h                 |  1 +
 9 files changed, 134 insertions(+), 75 deletions(-)

-- 
2.24.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 1/8] perf annotate/tui: Re-render title bar after switching back from script browser
  2020-02-13  6:42 [PATCH 0/8] perf annotate/config: More fixes Ravi Bangoria
@ 2020-02-13  6:42 ` Ravi Bangoria
  2020-02-27 13:11   ` Arnaldo Carvalho de Melo
  2020-02-29  9:16   ` [tip: perf/urgent] " tip-bot2 for Ravi Bangoria
  2020-02-13  6:43 ` [PATCH 2/8] perf annotate: Fix --show-total-period for tui/stdio2 Ravi Bangoria
                   ` (8 subsequent siblings)
  9 siblings, 2 replies; 26+ messages in thread
From: Ravi Bangoria @ 2020-02-13  6:42 UTC (permalink / raw)
  To: acme, jolsa
  Cc: xieyisheng1, alexey.budankov, treeze.taeung, adrian.hunter,
	tmricht, namhyung, irogers, songliubraving, yao.jin, changbin.du,
	leo.yan, linux-kernel, Ravi Bangoria

Perf annotate tui browser provides a hot key 'r' to switch to script
browser. But the annotate browser title bar becomes hidden while
switching back from script browser. Fix it.

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
---
 tools/perf/ui/browsers/annotate.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index badbddbb30f8..0dbbf35e6ed1 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -754,10 +754,9 @@ static int annotate_browser__run(struct annotate_browser *browser,
 		"?             Search string backwards\n");
 			continue;
 		case 'r':
-			{
-				script_browse(NULL, NULL);
-				continue;
-			}
+			script_browse(NULL, NULL);
+			annotate_browser__show(&browser->b, title, help);
+			continue;
 		case 'k':
 			notes->options->show_linenr = !notes->options->show_linenr;
 			break;
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 2/8] perf annotate: Fix --show-total-period for tui/stdio2
  2020-02-13  6:42 [PATCH 0/8] perf annotate/config: More fixes Ravi Bangoria
  2020-02-13  6:42 ` [PATCH 1/8] perf annotate/tui: Re-render title bar after switching back from script browser Ravi Bangoria
@ 2020-02-13  6:43 ` Ravi Bangoria
  2020-02-27 13:14   ` Arnaldo Carvalho de Melo
  2020-02-29  9:16   ` [tip: perf/urgent] " tip-bot2 for Ravi Bangoria
  2020-02-13  6:43 ` [PATCH 3/8] perf annotate: Fix --show-nr-samples " Ravi Bangoria
                   ` (7 subsequent siblings)
  9 siblings, 2 replies; 26+ messages in thread
From: Ravi Bangoria @ 2020-02-13  6:43 UTC (permalink / raw)
  To: acme, jolsa
  Cc: xieyisheng1, alexey.budankov, treeze.taeung, adrian.hunter,
	tmricht, namhyung, irogers, songliubraving, yao.jin, changbin.du,
	leo.yan, linux-kernel, Ravi Bangoria

perf annotate --show-total-period does not really show total period.
The reason is we have two separate variables for the same purpose.
One is in symbol_conf.show_total_period and another is
annotation_options.show_total_period. We save command line option
in symbol_conf.show_total_period but uses
annotation_option.show_total_period while rendering tui/stdio2 browser.

Though, we copy symbol_conf.show_total_period to
annotation__default_options.show_total_period but that is not really
effective as we don't use annotation__default_options once we copy
default options to dynamic variable annotate.opts in cmd_annotate().

Instead of all these complication, keep only one variable and use it
all over. symbol_conf.show_total_period is used by perf report/top as
well. So let's kill annotation_options.show_total_period.

On a side note, I've kept annotation_options.show_total_period definition
because it's still used by perf-config code. Follow up patch to fix
perf-config for annotate will remove annotation_options.show_total_period.

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
---
 tools/perf/ui/browsers/annotate.c | 6 +++---
 tools/perf/util/annotate.c        | 5 ++---
 tools/perf/util/annotate.h        | 2 +-
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 0dbbf35e6ed1..7e5b44becb5c 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -833,13 +833,13 @@ static int annotate_browser__run(struct annotate_browser *browser,
 			map_symbol__annotation_dump(ms, evsel, browser->opts);
 			continue;
 		case 't':
-			if (notes->options->show_total_period) {
-				notes->options->show_total_period = false;
+			if (symbol_conf.show_total_period) {
+				symbol_conf.show_total_period = false;
 				notes->options->show_nr_samples = true;
 			} else if (notes->options->show_nr_samples)
 				notes->options->show_nr_samples = false;
 			else
-				notes->options->show_total_period = true;
+				symbol_conf.show_total_period = true;
 			annotation__update_column_widths(notes);
 			continue;
 		case 'c':
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index b2a26adeb4cd..c0c3832e3789 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -2892,7 +2892,7 @@ static void __annotation_line__write(struct annotation_line *al, struct annotati
 			percent = annotation_data__percent(&al->data[i], percent_type);
 
 			obj__set_percent_color(obj, percent, current_entry);
-			if (notes->options->show_total_period) {
+			if (symbol_conf.show_total_period) {
 				obj__printf(obj, "%11" PRIu64 " ", al->data[i].he.period);
 			} else if (notes->options->show_nr_samples) {
 				obj__printf(obj, "%6" PRIu64 " ",
@@ -2908,7 +2908,7 @@ static void __annotation_line__write(struct annotation_line *al, struct annotati
 			obj__printf(obj, "%-*s", pcnt_width, " ");
 		else {
 			obj__printf(obj, "%-*s", pcnt_width,
-					   notes->options->show_total_period ? "Period" :
+					   symbol_conf.show_total_period ? "Period" :
 					   notes->options->show_nr_samples ? "Samples" : "Percent");
 		}
 	}
@@ -3132,7 +3132,6 @@ void annotation_config__init(void)
 {
 	perf_config(annotation__config, NULL);
 
-	annotation__default_options.show_total_period = symbol_conf.show_total_period;
 	annotation__default_options.show_nr_samples   = symbol_conf.show_nr_samples;
 }
 
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index 2f333dfb586d..632e28b67990 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -307,7 +307,7 @@ static inline int annotation__cycles_width(struct annotation *notes)
 
 static inline int annotation__pcnt_width(struct annotation *notes)
 {
-	return (notes->options->show_total_period ? 12 : 7) * notes->nr_events;
+	return (symbol_conf.show_total_period ? 12 : 7) * notes->nr_events;
 }
 
 static inline bool annotation_line__filter(struct annotation_line *al, struct annotation *notes)
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 3/8] perf annotate: Fix --show-nr-samples for tui/stdio2
  2020-02-13  6:42 [PATCH 0/8] perf annotate/config: More fixes Ravi Bangoria
  2020-02-13  6:42 ` [PATCH 1/8] perf annotate/tui: Re-render title bar after switching back from script browser Ravi Bangoria
  2020-02-13  6:43 ` [PATCH 2/8] perf annotate: Fix --show-total-period for tui/stdio2 Ravi Bangoria
@ 2020-02-13  6:43 ` Ravi Bangoria
  2020-02-29  9:16   ` [tip: perf/urgent] " tip-bot2 for Ravi Bangoria
  2020-02-13  6:43 ` [PATCH 4/8] perf config: Introduce perf_config_u8() Ravi Bangoria
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 26+ messages in thread
From: Ravi Bangoria @ 2020-02-13  6:43 UTC (permalink / raw)
  To: acme, jolsa
  Cc: xieyisheng1, alexey.budankov, treeze.taeung, adrian.hunter,
	tmricht, namhyung, irogers, songliubraving, yao.jin, changbin.du,
	leo.yan, linux-kernel, Ravi Bangoria

perf annotate --show-nr-samples does not really show number of samples.
The reason is we have two separate variables for the same purpose. One
is in symbol_conf.show_nr_samples and another is
annotation_options.show_nr_samples. We save command line option
in symbol_conf.show_nr_samples but uses
annotation_option.show_nr_samples while rendering tui/stdio2 browser.

Though, we copy symbol_conf.show_nr_samples to
annotation__default_options.show_nr_samples but that is not really
effective as we don't use annotation__default_options once we copy
default options to dynamic variable annotate.opts in cmd_annotate().

Instead of all these complication, keep only one variable and use it
all over. symbol_conf.show_nr_samples is used by perf report/top as
well. So let's kill annotation_options.show_nr_samples.

On a side note, I've kept annotation_options.show_nr_samples definition
because it's still used by perf-config code. Follow up patch to fix
perf-config for annotate will remove annotation_options.show_nr_samples.

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
---
 tools/perf/ui/browsers/annotate.c | 6 +++---
 tools/perf/util/annotate.c        | 6 ++----
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 7e5b44becb5c..9023267e5643 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -835,9 +835,9 @@ static int annotate_browser__run(struct annotate_browser *browser,
 		case 't':
 			if (symbol_conf.show_total_period) {
 				symbol_conf.show_total_period = false;
-				notes->options->show_nr_samples = true;
-			} else if (notes->options->show_nr_samples)
-				notes->options->show_nr_samples = false;
+				symbol_conf.show_nr_samples = true;
+			} else if (symbol_conf.show_nr_samples)
+				symbol_conf.show_nr_samples = false;
 			else
 				symbol_conf.show_total_period = true;
 			annotation__update_column_widths(notes);
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index c0c3832e3789..e05aeee40ed1 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -2894,7 +2894,7 @@ static void __annotation_line__write(struct annotation_line *al, struct annotati
 			obj__set_percent_color(obj, percent, current_entry);
 			if (symbol_conf.show_total_period) {
 				obj__printf(obj, "%11" PRIu64 " ", al->data[i].he.period);
-			} else if (notes->options->show_nr_samples) {
+			} else if (symbol_conf.show_nr_samples) {
 				obj__printf(obj, "%6" PRIu64 " ",
 						   al->data[i].he.nr_samples);
 			} else {
@@ -2909,7 +2909,7 @@ static void __annotation_line__write(struct annotation_line *al, struct annotati
 		else {
 			obj__printf(obj, "%-*s", pcnt_width,
 					   symbol_conf.show_total_period ? "Period" :
-					   notes->options->show_nr_samples ? "Samples" : "Percent");
+					   symbol_conf.show_nr_samples ? "Samples" : "Percent");
 		}
 	}
 
@@ -3131,8 +3131,6 @@ static int annotation__config(const char *var, const char *value,
 void annotation_config__init(void)
 {
 	perf_config(annotation__config, NULL);
-
-	annotation__default_options.show_nr_samples   = symbol_conf.show_nr_samples;
 }
 
 static unsigned int parse_percent_type(char *str1, char *str2)
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 4/8] perf config: Introduce perf_config_u8()
  2020-02-13  6:42 [PATCH 0/8] perf annotate/config: More fixes Ravi Bangoria
                   ` (2 preceding siblings ...)
  2020-02-13  6:43 ` [PATCH 3/8] perf annotate: Fix --show-nr-samples " Ravi Bangoria
@ 2020-02-13  6:43 ` Ravi Bangoria
  2020-02-29  9:16   ` [tip: perf/urgent] " tip-bot2 for Ravi Bangoria
  2020-02-13  6:43 ` [PATCH 5/8] perf annotate: Make perf config effective Ravi Bangoria
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 26+ messages in thread
From: Ravi Bangoria @ 2020-02-13  6:43 UTC (permalink / raw)
  To: acme, jolsa
  Cc: xieyisheng1, alexey.budankov, treeze.taeung, adrian.hunter,
	tmricht, namhyung, irogers, songliubraving, yao.jin, changbin.du,
	leo.yan, linux-kernel, Ravi Bangoria

Introduce perf_config_u8() utility function to convert char * input
into u8 destination. We will utilize it in followup patch.

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
---
 tools/perf/util/config.c | 12 ++++++++++++
 tools/perf/util/config.h |  1 +
 2 files changed, 13 insertions(+)

diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index 0bc9c4d7fdc5..ef38eba56ed0 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -374,6 +374,18 @@ int perf_config_int(int *dest, const char *name, const char *value)
 	return 0;
 }
 
+int perf_config_u8(u8 *dest, const char *name, const char *value)
+{
+	long ret = 0;
+
+	if (!perf_parse_long(value, &ret)) {
+		bad_config(name);
+		return -1;
+	}
+	*dest = ret;
+	return 0;
+}
+
 static int perf_config_bool_or_int(const char *name, const char *value, int *is_bool)
 {
 	int ret;
diff --git a/tools/perf/util/config.h b/tools/perf/util/config.h
index bd0a5897c76a..c10b66dde2f3 100644
--- a/tools/perf/util/config.h
+++ b/tools/perf/util/config.h
@@ -29,6 +29,7 @@ typedef int (*config_fn_t)(const char *, const char *, void *);
 int perf_default_config(const char *, const char *, void *);
 int perf_config(config_fn_t fn, void *);
 int perf_config_int(int *dest, const char *, const char *);
+int perf_config_u8(u8 *dest, const char *name, const char *value);
 int perf_config_u64(u64 *dest, const char *, const char *);
 int perf_config_bool(const char *, const char *);
 int config_error_nonbool(const char *);
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 5/8] perf annotate: Make perf config effective
  2020-02-13  6:42 [PATCH 0/8] perf annotate/config: More fixes Ravi Bangoria
                   ` (3 preceding siblings ...)
  2020-02-13  6:43 ` [PATCH 4/8] perf config: Introduce perf_config_u8() Ravi Bangoria
@ 2020-02-13  6:43 ` Ravi Bangoria
  2020-02-27 13:32   ` Arnaldo Carvalho de Melo
  2020-02-29  9:16   ` [tip: perf/urgent] " tip-bot2 for Ravi Bangoria
  2020-02-13  6:43 ` [PATCH 6/8] perf annotate: Prefer cmdline option over default config Ravi Bangoria
                   ` (4 subsequent siblings)
  9 siblings, 2 replies; 26+ messages in thread
From: Ravi Bangoria @ 2020-02-13  6:43 UTC (permalink / raw)
  To: acme, jolsa
  Cc: xieyisheng1, alexey.budankov, treeze.taeung, adrian.hunter,
	tmricht, namhyung, irogers, songliubraving, yao.jin, changbin.du,
	leo.yan, linux-kernel, Ravi Bangoria

perf default config set by user in [annotate] section is totally
ignored by annotate code. Fix it.

Before:

  $ ./perf config
  annotate.hide_src_code=true
  annotate.show_nr_jumps=true
  annotate.show_nr_samples=true

  $ ./perf annotate shash
         │    unsigned h = 0;
         │      movl   $0x0,-0xc(%rbp)
         │    while (*s)
         │    ↓ jmp    44
         │    h = 65599 * h + *s++;
   11.33 │24:   mov    -0xc(%rbp),%eax
   43.50 │      imul   $0x1003f,%eax,%ecx
         │      mov    -0x18(%rbp),%rax

After:

         │        movl   $0x0,-0xc(%rbp)
         │      ↓ jmp    44
       1 │1 24:   mov    -0xc(%rbp),%eax
       4 │        imul   $0x1003f,%eax,%ecx
         │        mov    -0x18(%rbp),%rax

Note that we have removed show_nr_samples and show_total_period from
annotation_options because they are not used. Instead of them we use
symbol_conf.show_nr_samples and symbol_conf.show_total_period.

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
---
 tools/perf/builtin-annotate.c |  2 +-
 tools/perf/builtin-report.c   |  2 +-
 tools/perf/builtin-top.c      |  2 +-
 tools/perf/util/annotate.c    | 78 +++++++++++++----------------------
 tools/perf/util/annotate.h    |  4 +-
 5 files changed, 33 insertions(+), 55 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index ff61795a4d13..ea89077bb8e0 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -605,7 +605,7 @@ int cmd_annotate(int argc, const char **argv)
 	if (ret < 0)
 		goto out_delete;
 
-	annotation_config__init();
+	annotation_config__init(&annotate.opts);
 
 	symbol_conf.try_vmlinux_path = true;
 
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 9483b3f0cae3..72a12b69f120 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -1507,7 +1507,7 @@ int cmd_report(int argc, const char **argv)
 			symbol_conf.priv_size += sizeof(u32);
 			symbol_conf.sort_by_name = true;
 		}
-		annotation_config__init();
+		annotation_config__init(&report.annotation_opts);
 	}
 
 	if (symbol__init(&session->header.env) < 0)
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 3e37747364e0..f6dd1a63f159 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1683,7 +1683,7 @@ int cmd_top(int argc, const char **argv)
 	if (status < 0)
 		goto out_delete_evlist;
 
-	annotation_config__init();
+	annotation_config__init(&top.annotation_opts);
 
 	symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL);
 	status = symbol__init(NULL);
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index e05aeee40ed1..4e2706274d85 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -3071,66 +3071,46 @@ int symbol__annotate2(struct map_symbol *ms, struct evsel *evsel,
 	return err;
 }
 
-#define ANNOTATION__CFG(n) \
-	{ .name = #n, .value = &annotation__default_options.n, }
-
-/*
- * Keep the entries sorted, they are bsearch'ed
- */
-static struct annotation_config {
-	const char *name;
-	void *value;
-} annotation__configs[] = {
-	ANNOTATION__CFG(hide_src_code),
-	ANNOTATION__CFG(jump_arrows),
-	ANNOTATION__CFG(offset_level),
-	ANNOTATION__CFG(show_linenr),
-	ANNOTATION__CFG(show_nr_jumps),
-	ANNOTATION__CFG(show_nr_samples),
-	ANNOTATION__CFG(show_total_period),
-	ANNOTATION__CFG(use_offset),
-};
-
-#undef ANNOTATION__CFG
-
-static int annotation_config__cmp(const void *name, const void *cfgp)
+static int annotation__config(const char *var, const char *value, void *data)
 {
-	const struct annotation_config *cfg = cfgp;
-
-	return strcmp(name, cfg->name);
-}
-
-static int annotation__config(const char *var, const char *value,
-			    void *data __maybe_unused)
-{
-	struct annotation_config *cfg;
-	const char *name;
+	struct annotation_options *opt = data;
 
 	if (!strstarts(var, "annotate."))
 		return 0;
 
-	name = var + 9;
-	cfg = bsearch(name, annotation__configs, ARRAY_SIZE(annotation__configs),
-		      sizeof(struct annotation_config), annotation_config__cmp);
-
-	if (cfg == NULL)
-		pr_debug("%s variable unknown, ignoring...", var);
-	else if (strcmp(var, "annotate.offset_level") == 0) {
-		perf_config_int(cfg->value, name, value);
-
-		if (*(int *)cfg->value > ANNOTATION__MAX_OFFSET_LEVEL)
-			*(int *)cfg->value = ANNOTATION__MAX_OFFSET_LEVEL;
-		else if (*(int *)cfg->value < ANNOTATION__MIN_OFFSET_LEVEL)
-			*(int *)cfg->value = ANNOTATION__MIN_OFFSET_LEVEL;
+	if (!strcmp(var, "annotate.offset_level")) {
+		perf_config_u8(&opt->offset_level, "offset_level", value);
+
+		if (opt->offset_level > ANNOTATION__MAX_OFFSET_LEVEL)
+			opt->offset_level = ANNOTATION__MAX_OFFSET_LEVEL;
+		else if (opt->offset_level < ANNOTATION__MIN_OFFSET_LEVEL)
+			opt->offset_level = ANNOTATION__MIN_OFFSET_LEVEL;
+	} else if (!strcmp(var, "annotate.hide_src_code")) {
+		opt->hide_src_code = perf_config_bool("hide_src_code", value);
+	} else if (!strcmp(var, "annotate.jump_arrows")) {
+		opt->jump_arrows = perf_config_bool("jump_arrows", value);
+	} else if (!strcmp(var, "annotate.show_linenr")) {
+		opt->show_linenr = perf_config_bool("show_linenr", value);
+	} else if (!strcmp(var, "annotate.show_nr_jumps")) {
+		opt->show_nr_jumps = perf_config_bool("show_nr_jumps", value);
+	} else if (!strcmp(var, "annotate.show_nr_samples")) {
+		symbol_conf.show_nr_samples = perf_config_bool("show_nr_samples",
+								value);
+	} else if (!strcmp(var, "annotate.show_total_period")) {
+		symbol_conf.show_total_period = perf_config_bool("show_total_period",
+								value);
+	} else if (!strcmp(var, "annotate.use_offset")) {
+		opt->use_offset = perf_config_bool("use_offset", value);
 	} else {
-		*(bool *)cfg->value = perf_config_bool(name, value);
+		pr_debug("%s variable unknown, ignoring...", var);
 	}
+
 	return 0;
 }
 
-void annotation_config__init(void)
+void annotation_config__init(struct annotation_options *opt)
 {
-	perf_config(annotation__config, NULL);
+	perf_config(annotation__config, opt);
 }
 
 static unsigned int parse_percent_type(char *str1, char *str2)
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index 632e28b67990..d9b5bb105056 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -83,8 +83,6 @@ struct annotation_options {
 	     full_path,
 	     show_linenr,
 	     show_nr_jumps,
-	     show_nr_samples,
-	     show_total_period,
 	     show_minmax_cycle,
 	     show_asm_raw,
 	     annotate_src;
@@ -407,7 +405,7 @@ static inline int symbol__tui_annotate(struct map_symbol *ms __maybe_unused,
 }
 #endif
 
-void annotation_config__init(void);
+void annotation_config__init(struct annotation_options *opt);
 
 int annotate_parse_percent_type(const struct option *opt, const char *_str,
 				int unset);
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 6/8] perf annotate: Prefer cmdline option over default config
  2020-02-13  6:42 [PATCH 0/8] perf annotate/config: More fixes Ravi Bangoria
                   ` (4 preceding siblings ...)
  2020-02-13  6:43 ` [PATCH 5/8] perf annotate: Make perf config effective Ravi Bangoria
@ 2020-02-13  6:43 ` Ravi Bangoria
  2020-02-29  9:16   ` [tip: perf/urgent] " tip-bot2 for Ravi Bangoria
  2020-02-13  6:43 ` [PATCH 7/8] perf annotate: Fix perf config option description Ravi Bangoria
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 26+ messages in thread
From: Ravi Bangoria @ 2020-02-13  6:43 UTC (permalink / raw)
  To: acme, jolsa
  Cc: xieyisheng1, alexey.budankov, treeze.taeung, adrian.hunter,
	tmricht, namhyung, irogers, songliubraving, yao.jin, changbin.du,
	leo.yan, linux-kernel, Ravi Bangoria

For all the perf-config options that can also be set from command line
option, the preference is given to command line version in case of any
conflict. But that's opposite in case of perf annotate. i.e. the more
preference is given to default option rather than command line option.
Fix it.

Before:

  $ ./perf config
  annotate.show_nr_samples=false

  $ ./perf annotate shash --show-nr-samples
  Percent│
         │24:   mov    -0xc(%rbp),%eax
   49.19 │      imul   $0x1003f,%eax,%ecx
         │      mov    -0x18(%rbp),%rax

After:

  Samples│
         │24:   mov    -0xc(%rbp),%eax
       1 │      imul   $0x1003f,%eax,%ecx
         │      mov    -0x18(%rbp),%rax

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
---
 tools/perf/builtin-annotate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index ea89077bb8e0..6c0a0412502e 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -566,6 +566,8 @@ int cmd_annotate(int argc, const char **argv)
 	if (ret < 0)
 		return ret;
 
+	annotation_config__init(&annotate.opts);
+
 	argc = parse_options(argc, argv, options, annotate_usage, 0);
 	if (argc) {
 		/*
@@ -605,8 +607,6 @@ int cmd_annotate(int argc, const char **argv)
 	if (ret < 0)
 		goto out_delete;
 
-	annotation_config__init(&annotate.opts);
-
 	symbol_conf.try_vmlinux_path = true;
 
 	ret = symbol__init(&annotate.session->header.env);
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 7/8] perf annotate: Fix perf config option description
  2020-02-13  6:42 [PATCH 0/8] perf annotate/config: More fixes Ravi Bangoria
                   ` (5 preceding siblings ...)
  2020-02-13  6:43 ` [PATCH 6/8] perf annotate: Prefer cmdline option over default config Ravi Bangoria
@ 2020-02-13  6:43 ` Ravi Bangoria
  2020-02-29  9:16   ` [tip: perf/urgent] " tip-bot2 for Ravi Bangoria
  2020-02-13  6:43 ` [PATCH 8/8] perf config: Document missing config options Ravi Bangoria
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 26+ messages in thread
From: Ravi Bangoria @ 2020-02-13  6:43 UTC (permalink / raw)
  To: acme, jolsa
  Cc: xieyisheng1, alexey.budankov, treeze.taeung, adrian.hunter,
	tmricht, namhyung, irogers, songliubraving, yao.jin, changbin.du,
	leo.yan, linux-kernel, Ravi Bangoria

perf config annotate options says it works only with TUI, which is wrong.
Most of the TUI options are applicable to stdio2 as well. So remove that
generic line and add individual line with each option stating which
browsers supports that option. Also, annotate.show_nr_samples config is
missing in Documentation. Describe it.

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
---
 tools/perf/Documentation/perf-config.txt | 30 +++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-config.txt b/tools/perf/Documentation/perf-config.txt
index c4dd23c4b478..9dae0df3ab7e 100644
--- a/tools/perf/Documentation/perf-config.txt
+++ b/tools/perf/Documentation/perf-config.txt
@@ -239,7 +239,6 @@ buildid.*::
 		set buildid.dir to /dev/null. The default is $HOME/.debug
 
 annotate.*::
-	These options work only for TUI.
 	These are in control of addresses, jump function, source code
 	in lines of assembly code from a specific program.
 
@@ -269,6 +268,8 @@ annotate.*::
 		│        mov    (%rdi),%rdx
 		│              return n;
 
+		This option works with tui, stdio2 browsers.
+
         annotate.use_offset::
 		Basing on a first address of a loaded function, offset can be used.
 		Instead of using original addresses of assembly code,
@@ -287,6 +288,8 @@ annotate.*::
 
 		             368:│  mov    0x8(%r14),%rdi
 
+		This option works with tui, stdio2 browsers.
+
 	annotate.jump_arrows::
 		There can be jump instruction among assembly code.
 		Depending on a boolean value of jump_arrows,
@@ -306,6 +309,8 @@ annotate.*::
 		│1330:   mov    %r15,%r10
 		│1333:   cmp    %r15,%r14
 
+		This option works with tui browser.
+
         annotate.show_linenr::
 		When showing source code if this option is 'true',
 		line numbers are printed as below.
@@ -325,6 +330,8 @@ annotate.*::
 		│                     array++;
 		│             }
 
+		This option works with tui, stdio2 browsers.
+
         annotate.show_nr_jumps::
 		Let's see a part of assembly code.
 
@@ -335,6 +342,8 @@ annotate.*::
 
 		│1 1382:   movb   $0x1,-0x270(%rbp)
 
+		This option works with tui, stdio2 browsers.
+
         annotate.show_total_period::
 		To compare two records on an instruction base, with this option
 		provided, display total number of samples that belong to a line
@@ -348,11 +357,30 @@ annotate.*::
 
 		99.93 │      mov    %eax,%eax
 
+		This option works with tui, stdio2, stdio browsers.
+
+	annotate.show_nr_samples::
+		By default perf annotate shows percentage of samples. This option
+		can be used to print absolute number of samples. Ex, when set as
+		false:
+
+		Percent│
+		 74.03 │      mov    %fs:0x28,%rax
+
+		When set as true:
+
+		Samples│
+		     6 │      mov    %fs:0x28,%rax
+
+		This option works with tui, stdio2, stdio browsers.
+
 	annotate.offset_level::
 		Default is '1', meaning just jump targets will have offsets show right beside
 		the instruction. When set to '2' 'call' instructions will also have its offsets
 		shown, 3 or higher will show offsets for all instructions.
 
+		This option works with tui, stdio2 browsers.
+
 hist.*::
 	hist.percentage::
 		This option control the way to calculate overhead of filtered entries -
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 8/8] perf config: Document missing config options
  2020-02-13  6:42 [PATCH 0/8] perf annotate/config: More fixes Ravi Bangoria
                   ` (6 preceding siblings ...)
  2020-02-13  6:43 ` [PATCH 7/8] perf annotate: Fix perf config option description Ravi Bangoria
@ 2020-02-13  6:43 ` Ravi Bangoria
  2020-02-29  9:16   ` [tip: perf/urgent] " tip-bot2 for Ravi Bangoria
  2020-02-16 21:15 ` [PATCH 0/8] perf annotate/config: More fixes Jiri Olsa
  2020-02-27 13:39 ` Arnaldo Carvalho de Melo
  9 siblings, 1 reply; 26+ messages in thread
From: Ravi Bangoria @ 2020-02-13  6:43 UTC (permalink / raw)
  To: acme, jolsa
  Cc: xieyisheng1, alexey.budankov, treeze.taeung, adrian.hunter,
	tmricht, namhyung, irogers, songliubraving, yao.jin, changbin.du,
	leo.yan, linux-kernel, Ravi Bangoria

While documenting annotate.show_nr_samples config option, I found many
other config options missing in perf-config documentation. Add them.

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
---
 tools/perf/Documentation/perf-config.txt | 44 ++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/tools/perf/Documentation/perf-config.txt b/tools/perf/Documentation/perf-config.txt
index 9dae0df3ab7e..8ead55593984 100644
--- a/tools/perf/Documentation/perf-config.txt
+++ b/tools/perf/Documentation/perf-config.txt
@@ -518,6 +518,12 @@ top.*::
 		column by default.
 		The default is 'true'.
 
+	top.call-graph::
+		This is identical to 'call-graph.record-mode', except it is
+		applicable only for 'top' subcommand. This option ONLY setup
+		the unwind method. To enable 'perf top' to actually use it,
+		the command line option -g must be specified.
+
 man.*::
 	man.viewer::
 		This option can assign a tool to view manual pages when 'help'
@@ -545,6 +551,16 @@ record.*::
 		But if this option is 'no-cache', it will not update the build-id cache.
 		'skip' skips post-processing and does not update the cache.
 
+	record.call-graph::
+		This is identical to 'call-graph.record-mode', except it is
+		applicable only for 'record' subcommand. This option ONLY setup
+		the unwind method. To enable 'perf record' to actually use it,
+		the command line option -g must be specified.
+
+	record.aio::
+		Use 'n' control blocks in asynchronous (Posix AIO) trace writing
+		mode ('n' default: 1, max: 4).
+
 diff.*::
 	diff.order::
 		This option sets the number of columns to sort the result.
@@ -594,6 +610,11 @@ trace.*::
 		"libbeauty", the default, to use the same argument beautifiers used in the
 		strace-like sys_enter+sys_exit lines.
 
+ftrace.*::
+	ftrace.tracer::
+		Can be used to select the default tracer. Possible values are
+		'function' and 'function_graph'.
+
 llvm.*::
 	llvm.clang-path::
 		Path to clang. If omit, search it from $PATH.
@@ -638,6 +659,29 @@ scripts.*::
 	The script gets the same options passed as a full perf script,
 	in particular -i perfdata file, --cpu, --tid
 
+convert.*::
+
+	convert.queue-size::
+		Limit the size of ordered_events queue, so we could control
+		allocation size of perf data files without proper finished
+		round events.
+
+intel-pt.*::
+
+	intel-pt.cache-divisor::
+
+	intel-pt.mispred-all::
+		If set, Intel PT decoder will set the mispred flag on all
+		branches.
+
+auxtrace.*::
+
+	auxtrace.dumpdir::
+		s390 only. The directory to save the auxiliary trace buffer
+		can be changed using this option. Ex, auxtrace.dumpdir=/tmp.
+		If the directory does not exist or has the wrong file type,
+		the current directory is used.
+
 SEE ALSO
 --------
 linkperf:perf[1]
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [PATCH 0/8] perf annotate/config: More fixes
  2020-02-13  6:42 [PATCH 0/8] perf annotate/config: More fixes Ravi Bangoria
                   ` (7 preceding siblings ...)
  2020-02-13  6:43 ` [PATCH 8/8] perf config: Document missing config options Ravi Bangoria
@ 2020-02-16 21:15 ` Jiri Olsa
  2020-02-17 13:02   ` Ravi Bangoria
  2020-02-27 13:08   ` Arnaldo Carvalho de Melo
  2020-02-27 13:39 ` Arnaldo Carvalho de Melo
  9 siblings, 2 replies; 26+ messages in thread
From: Jiri Olsa @ 2020-02-16 21:15 UTC (permalink / raw)
  To: Ravi Bangoria
  Cc: acme, xieyisheng1, alexey.budankov, treeze.taeung, adrian.hunter,
	tmricht, namhyung, irogers, songliubraving, yao.jin, changbin.du,
	leo.yan, linux-kernel

On Thu, Feb 13, 2020 at 12:12:58PM +0530, Ravi Bangoria wrote:
> These are the additional set of fixes on top of previous series:
> http://lore.kernel.org/r/20200204045233.474937-1-ravi.bangoria@linux.ibm.com
> 
> Note for the last patch:
> I couldn't understand what intel-pt.cache-divisor is really used for.
> Adrian, can you please help.
> 
> Ravi Bangoria (8):
>   perf annotate/tui: Re-render title bar after switching back from
>     script browser
>   perf annotate: Fix --show-total-period for tui/stdio2
>   perf annotate: Fix --show-nr-samples for tui/stdio2
>   perf config: Introduce perf_config_u8()
>   perf annotate: Make perf config effective
>   perf annotate: Prefer cmdline option over default config
>   perf annotate: Fix perf config option description
>   perf config: Document missing config options

nice, I guess this all worked in the past but got broken because
we don't have any tests for annotation code.. any chance you could
think of some way to test annotations?

perhaps some shell script, or prepare all the needed data for annotation
manualy.. sort of like we did in tests/hists_*.c

thanks,
jirka

> 
>  tools/perf/Documentation/perf-config.txt | 74 +++++++++++++++++++-
>  tools/perf/builtin-annotate.c            |  4 +-
>  tools/perf/builtin-report.c              |  2 +-
>  tools/perf/builtin-top.c                 |  2 +-
>  tools/perf/ui/browsers/annotate.c        | 19 +++--
>  tools/perf/util/annotate.c               | 89 +++++++++---------------
>  tools/perf/util/annotate.h               |  6 +-
>  tools/perf/util/config.c                 | 12 ++++
>  tools/perf/util/config.h                 |  1 +
>  9 files changed, 134 insertions(+), 75 deletions(-)
> 
> -- 
> 2.24.1
> 


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 0/8] perf annotate/config: More fixes
  2020-02-16 21:15 ` [PATCH 0/8] perf annotate/config: More fixes Jiri Olsa
@ 2020-02-17 13:02   ` Ravi Bangoria
  2020-02-27 13:08   ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 26+ messages in thread
From: Ravi Bangoria @ 2020-02-17 13:02 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: acme, xieyisheng1, alexey.budankov, treeze.taeung, adrian.hunter,
	tmricht, namhyung, irogers, songliubraving, yao.jin, changbin.du,
	leo.yan, linux-kernel, Ravi Bangoria



On 2/17/20 2:45 AM, Jiri Olsa wrote:
> On Thu, Feb 13, 2020 at 12:12:58PM +0530, Ravi Bangoria wrote:
>> These are the additional set of fixes on top of previous series:
>> http://lore.kernel.org/r/20200204045233.474937-1-ravi.bangoria@linux.ibm.com
>>
>> Note for the last patch:
>> I couldn't understand what intel-pt.cache-divisor is really used for.
>> Adrian, can you please help.
>>
>> Ravi Bangoria (8):
>>    perf annotate/tui: Re-render title bar after switching back from
>>      script browser
>>    perf annotate: Fix --show-total-period for tui/stdio2
>>    perf annotate: Fix --show-nr-samples for tui/stdio2
>>    perf config: Introduce perf_config_u8()
>>    perf annotate: Make perf config effective
>>    perf annotate: Prefer cmdline option over default config
>>    perf annotate: Fix perf config option description
>>    perf config: Document missing config options
> 
> nice, I guess this all worked in the past but got broken because
> we don't have any tests for annotation code.. any chance you could
> think of some way to test annotations?
> 
> perhaps some shell script, or prepare all the needed data for annotation
> manualy.. sort of like we did in tests/hists_*.c

Sure Jiri. I'll take a look at this.

Ravi


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 0/8] perf annotate/config: More fixes
  2020-02-16 21:15 ` [PATCH 0/8] perf annotate/config: More fixes Jiri Olsa
  2020-02-17 13:02   ` Ravi Bangoria
@ 2020-02-27 13:08   ` Arnaldo Carvalho de Melo
  2020-02-27 13:16     ` Jiri Olsa
  1 sibling, 1 reply; 26+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-02-27 13:08 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Ravi Bangoria, xieyisheng1, alexey.budankov, treeze.taeung,
	adrian.hunter, tmricht, namhyung, irogers, songliubraving,
	yao.jin, changbin.du, leo.yan, linux-kernel

Em Sun, Feb 16, 2020 at 10:15:49PM +0100, Jiri Olsa escreveu:
> On Thu, Feb 13, 2020 at 12:12:58PM +0530, Ravi Bangoria wrote:
> > These are the additional set of fixes on top of previous series:
> > http://lore.kernel.org/r/20200204045233.474937-1-ravi.bangoria@linux.ibm.com
> > 
> > Note for the last patch:
> > I couldn't understand what intel-pt.cache-divisor is really used for.
> > Adrian, can you please help.
> > 
> > Ravi Bangoria (8):
> >   perf annotate/tui: Re-render title bar after switching back from
> >     script browser
> >   perf annotate: Fix --show-total-period for tui/stdio2
> >   perf annotate: Fix --show-nr-samples for tui/stdio2
> >   perf config: Introduce perf_config_u8()
> >   perf annotate: Make perf config effective
> >   perf annotate: Prefer cmdline option over default config
> >   perf annotate: Fix perf config option description
> >   perf config: Document missing config options
> 
> nice, I guess this all worked in the past but got broken because
> we don't have any tests for annotation code.. any chance you could

I'm going thru them, can I take that "nice" as an Acked-by? Have you
gone thru those patches?

- Arnaldo

> think of some way to test annotations?
 
> perhaps some shell script, or prepare all the needed data for annotation
> manualy.. sort of like we did in tests/hists_*.c
> 
> thanks,
> jirka
> 
> > 
> >  tools/perf/Documentation/perf-config.txt | 74 +++++++++++++++++++-
> >  tools/perf/builtin-annotate.c            |  4 +-
> >  tools/perf/builtin-report.c              |  2 +-
> >  tools/perf/builtin-top.c                 |  2 +-
> >  tools/perf/ui/browsers/annotate.c        | 19 +++--
> >  tools/perf/util/annotate.c               | 89 +++++++++---------------
> >  tools/perf/util/annotate.h               |  6 +-
> >  tools/perf/util/config.c                 | 12 ++++
> >  tools/perf/util/config.h                 |  1 +
> >  9 files changed, 134 insertions(+), 75 deletions(-)
> > 
> > -- 
> > 2.24.1
> > 
> 

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 1/8] perf annotate/tui: Re-render title bar after switching back from script browser
  2020-02-13  6:42 ` [PATCH 1/8] perf annotate/tui: Re-render title bar after switching back from script browser Ravi Bangoria
@ 2020-02-27 13:11   ` Arnaldo Carvalho de Melo
  2020-02-29  9:16   ` [tip: perf/urgent] " tip-bot2 for Ravi Bangoria
  1 sibling, 0 replies; 26+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-02-27 13:11 UTC (permalink / raw)
  To: Ravi Bangoria
  Cc: jolsa, xieyisheng1, alexey.budankov, treeze.taeung,
	adrian.hunter, tmricht, namhyung, irogers, songliubraving,
	yao.jin, changbin.du, leo.yan, linux-kernel

Em Thu, Feb 13, 2020 at 12:12:59PM +0530, Ravi Bangoria escreveu:
> Perf annotate tui browser provides a hot key 'r' to switch to script
> browser. But the annotate browser title bar becomes hidden while
> switching back from script browser. Fix it.

Reproduced, tested fix, applied, thanks.

- Arnaldo
 
> Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
> ---
>  tools/perf/ui/browsers/annotate.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
> index badbddbb30f8..0dbbf35e6ed1 100644
> --- a/tools/perf/ui/browsers/annotate.c
> +++ b/tools/perf/ui/browsers/annotate.c
> @@ -754,10 +754,9 @@ static int annotate_browser__run(struct annotate_browser *browser,
>  		"?             Search string backwards\n");
>  			continue;
>  		case 'r':
> -			{
> -				script_browse(NULL, NULL);
> -				continue;
> -			}
> +			script_browse(NULL, NULL);
> +			annotate_browser__show(&browser->b, title, help);
> +			continue;
>  		case 'k':
>  			notes->options->show_linenr = !notes->options->show_linenr;
>  			break;
> -- 
> 2.24.1
> 

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/8] perf annotate: Fix --show-total-period for tui/stdio2
  2020-02-13  6:43 ` [PATCH 2/8] perf annotate: Fix --show-total-period for tui/stdio2 Ravi Bangoria
@ 2020-02-27 13:14   ` Arnaldo Carvalho de Melo
  2020-02-29  9:16   ` [tip: perf/urgent] " tip-bot2 for Ravi Bangoria
  1 sibling, 0 replies; 26+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-02-27 13:14 UTC (permalink / raw)
  To: Ravi Bangoria
  Cc: jolsa, xieyisheng1, alexey.budankov, treeze.taeung,
	adrian.hunter, tmricht, namhyung, irogers, songliubraving,
	yao.jin, changbin.du, leo.yan, linux-kernel

Em Thu, Feb 13, 2020 at 12:13:00PM +0530, Ravi Bangoria escreveu:
> perf annotate --show-total-period does not really show total period.
> The reason is we have two separate variables for the same purpose.
> One is in symbol_conf.show_total_period and another is
> annotation_options.show_total_period. We save command line option
> in symbol_conf.show_total_period but uses
> annotation_option.show_total_period while rendering tui/stdio2 browser.
> 
> Though, we copy symbol_conf.show_total_period to
> annotation__default_options.show_total_period but that is not really
> effective as we don't use annotation__default_options once we copy
> default options to dynamic variable annotate.opts in cmd_annotate().
> 
> Instead of all these complication, keep only one variable and use it
> all over. symbol_conf.show_total_period is used by perf report/top as
> well. So let's kill annotation_options.show_total_period.
> 
> On a side note, I've kept annotation_options.show_total_period definition
> because it's still used by perf-config code. Follow up patch to fix
> perf-config for annotate will remove annotation_options.show_total_period.

IIRC this was an attempt to reduce the number of entries in symbol_conf,
that became a hodpodge of options, all global, argh.

But then, making changes like that sticky in a session, i.e. you go
annotate some symbol, toggle some option, then go back to the main
window and go back to annotation and things are the way you left off in
the previous symbol has been over the years considered a nice feature...

So I'll apply your changes, at some point we can sanitize symbol_conf.

Thanks,

- Arnaldo
 
> Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
> ---
>  tools/perf/ui/browsers/annotate.c | 6 +++---
>  tools/perf/util/annotate.c        | 5 ++---
>  tools/perf/util/annotate.h        | 2 +-
>  3 files changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
> index 0dbbf35e6ed1..7e5b44becb5c 100644
> --- a/tools/perf/ui/browsers/annotate.c
> +++ b/tools/perf/ui/browsers/annotate.c
> @@ -833,13 +833,13 @@ static int annotate_browser__run(struct annotate_browser *browser,
>  			map_symbol__annotation_dump(ms, evsel, browser->opts);
>  			continue;
>  		case 't':
> -			if (notes->options->show_total_period) {
> -				notes->options->show_total_period = false;
> +			if (symbol_conf.show_total_period) {
> +				symbol_conf.show_total_period = false;
>  				notes->options->show_nr_samples = true;
>  			} else if (notes->options->show_nr_samples)
>  				notes->options->show_nr_samples = false;
>  			else
> -				notes->options->show_total_period = true;
> +				symbol_conf.show_total_period = true;
>  			annotation__update_column_widths(notes);
>  			continue;
>  		case 'c':
> diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
> index b2a26adeb4cd..c0c3832e3789 100644
> --- a/tools/perf/util/annotate.c
> +++ b/tools/perf/util/annotate.c
> @@ -2892,7 +2892,7 @@ static void __annotation_line__write(struct annotation_line *al, struct annotati
>  			percent = annotation_data__percent(&al->data[i], percent_type);
>  
>  			obj__set_percent_color(obj, percent, current_entry);
> -			if (notes->options->show_total_period) {
> +			if (symbol_conf.show_total_period) {
>  				obj__printf(obj, "%11" PRIu64 " ", al->data[i].he.period);
>  			} else if (notes->options->show_nr_samples) {
>  				obj__printf(obj, "%6" PRIu64 " ",
> @@ -2908,7 +2908,7 @@ static void __annotation_line__write(struct annotation_line *al, struct annotati
>  			obj__printf(obj, "%-*s", pcnt_width, " ");
>  		else {
>  			obj__printf(obj, "%-*s", pcnt_width,
> -					   notes->options->show_total_period ? "Period" :
> +					   symbol_conf.show_total_period ? "Period" :
>  					   notes->options->show_nr_samples ? "Samples" : "Percent");
>  		}
>  	}
> @@ -3132,7 +3132,6 @@ void annotation_config__init(void)
>  {
>  	perf_config(annotation__config, NULL);
>  
> -	annotation__default_options.show_total_period = symbol_conf.show_total_period;
>  	annotation__default_options.show_nr_samples   = symbol_conf.show_nr_samples;
>  }
>  
> diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
> index 2f333dfb586d..632e28b67990 100644
> --- a/tools/perf/util/annotate.h
> +++ b/tools/perf/util/annotate.h
> @@ -307,7 +307,7 @@ static inline int annotation__cycles_width(struct annotation *notes)
>  
>  static inline int annotation__pcnt_width(struct annotation *notes)
>  {
> -	return (notes->options->show_total_period ? 12 : 7) * notes->nr_events;
> +	return (symbol_conf.show_total_period ? 12 : 7) * notes->nr_events;
>  }
>  
>  static inline bool annotation_line__filter(struct annotation_line *al, struct annotation *notes)
> -- 
> 2.24.1
> 

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 0/8] perf annotate/config: More fixes
  2020-02-27 13:08   ` Arnaldo Carvalho de Melo
@ 2020-02-27 13:16     ` Jiri Olsa
  2020-02-27 13:43       ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 26+ messages in thread
From: Jiri Olsa @ 2020-02-27 13:16 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ravi Bangoria, xieyisheng1, alexey.budankov, treeze.taeung,
	adrian.hunter, tmricht, namhyung, irogers, songliubraving,
	yao.jin, changbin.du, leo.yan, linux-kernel

On Thu, Feb 27, 2020 at 10:08:46AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Sun, Feb 16, 2020 at 10:15:49PM +0100, Jiri Olsa escreveu:
> > On Thu, Feb 13, 2020 at 12:12:58PM +0530, Ravi Bangoria wrote:
> > > These are the additional set of fixes on top of previous series:
> > > http://lore.kernel.org/r/20200204045233.474937-1-ravi.bangoria@linux.ibm.com
> > > 
> > > Note for the last patch:
> > > I couldn't understand what intel-pt.cache-divisor is really used for.
> > > Adrian, can you please help.
> > > 
> > > Ravi Bangoria (8):
> > >   perf annotate/tui: Re-render title bar after switching back from
> > >     script browser
> > >   perf annotate: Fix --show-total-period for tui/stdio2
> > >   perf annotate: Fix --show-nr-samples for tui/stdio2
> > >   perf config: Introduce perf_config_u8()
> > >   perf annotate: Make perf config effective
> > >   perf annotate: Prefer cmdline option over default config
> > >   perf annotate: Fix perf config option description
> > >   perf config: Document missing config options
> > 
> > nice, I guess this all worked in the past but got broken because
> > we don't have any tests for annotation code.. any chance you could
> 
> I'm going thru them, can I take that "nice" as an Acked-by? Have you
> gone thru those patches?

nope, I just real fast checked on them.. I expected more discussion on tests ;-)

but as Ravi wrote, it could take some time

jirka

> 
> - Arnaldo
> 
> > think of some way to test annotations?
>  
> > perhaps some shell script, or prepare all the needed data for annotation
> > manualy.. sort of like we did in tests/hists_*.c
> > 
> > thanks,
> > jirka
> > 
> > > 
> > >  tools/perf/Documentation/perf-config.txt | 74 +++++++++++++++++++-
> > >  tools/perf/builtin-annotate.c            |  4 +-
> > >  tools/perf/builtin-report.c              |  2 +-
> > >  tools/perf/builtin-top.c                 |  2 +-
> > >  tools/perf/ui/browsers/annotate.c        | 19 +++--
> > >  tools/perf/util/annotate.c               | 89 +++++++++---------------
> > >  tools/perf/util/annotate.h               |  6 +-
> > >  tools/perf/util/config.c                 | 12 ++++
> > >  tools/perf/util/config.h                 |  1 +
> > >  9 files changed, 134 insertions(+), 75 deletions(-)
> > > 
> > > -- 
> > > 2.24.1
> > > 
> > 
> 
> -- 
> 
> - Arnaldo
> 


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 5/8] perf annotate: Make perf config effective
  2020-02-13  6:43 ` [PATCH 5/8] perf annotate: Make perf config effective Ravi Bangoria
@ 2020-02-27 13:32   ` Arnaldo Carvalho de Melo
  2020-02-29  9:16   ` [tip: perf/urgent] " tip-bot2 for Ravi Bangoria
  1 sibling, 0 replies; 26+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-02-27 13:32 UTC (permalink / raw)
  To: Ravi Bangoria
  Cc: jolsa, xieyisheng1, alexey.budankov, treeze.taeung,
	adrian.hunter, tmricht, namhyung, irogers, songliubraving,
	yao.jin, changbin.du, leo.yan, linux-kernel

Em Thu, Feb 13, 2020 at 12:13:03PM +0530, Ravi Bangoria escreveu:
> perf default config set by user in [annotate] section is totally
> ignored by annotate code. Fix it.
> 
> Before:
> 
>   $ ./perf config
>   annotate.hide_src_code=true
>   annotate.show_nr_jumps=true
>   annotate.show_nr_samples=true
> 
>   $ ./perf annotate shash
>          │    unsigned h = 0;
>          │      movl   $0x0,-0xc(%rbp)
>          │    while (*s)
>          │    ↓ jmp    44
>          │    h = 65599 * h + *s++;
>    11.33 │24:   mov    -0xc(%rbp),%eax
>    43.50 │      imul   $0x1003f,%eax,%ecx
>          │      mov    -0x18(%rbp),%rax
> 
> After:
> 
>          │        movl   $0x0,-0xc(%rbp)
>          │      ↓ jmp    44
>        1 │1 24:   mov    -0xc(%rbp),%eax
>        4 │        imul   $0x1003f,%eax,%ecx
>          │        mov    -0x18(%rbp),%rax
> 
> Note that we have removed show_nr_samples and show_total_period from
> annotation_options because they are not used. Instead of them we use
> symbol_conf.show_nr_samples and symbol_conf.show_total_period.

Cool, applied, and consider using --stdio2 to test such changes in the
future, as I did in a commiter notes section when applying this patch:


commit 8e63100473a16173a5cdd1f3ebc2bb986a8d1047
Author: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Date:   Thu Feb 13 12:13:03 2020 +0530

    perf annotate: Make perf config effective
    
    perf default config set by user in [annotate] section is totally ignored
    by annotate code. Fix it.
    
    Before:
    
      $ ./perf config
      annotate.hide_src_code=true
      annotate.show_nr_jumps=true
      annotate.show_nr_samples=true
    
      $ ./perf annotate shash
             │    unsigned h = 0;
             │      movl   $0x0,-0xc(%rbp)
             │    while (*s)
             │    ↓ jmp    44
             │    h = 65599 * h + *s++;
       11.33 │24:   mov    -0xc(%rbp),%eax
       43.50 │      imul   $0x1003f,%eax,%ecx
             │      mov    -0x18(%rbp),%rax
    
    After:
    
             │        movl   $0x0,-0xc(%rbp)
             │      ↓ jmp    44
           1 │1 24:   mov    -0xc(%rbp),%eax
           4 │        imul   $0x1003f,%eax,%ecx
             │        mov    -0x18(%rbp),%rax
    
    Note that we have removed show_nr_samples and show_total_period from
    annotation_options because they are not used. Instead of them we use
    symbol_conf.show_nr_samples and symbol_conf.show_total_period.
    
    Committer testing:
    
    Using 'perf annotate --stdio2' to use the TUI rendering but emitting the output to stdio:
    
      # perf config
      #
      # perf config annotate.hide_src_code=true
      # perf config
      annotate.hide_src_code=true
      #
      # perf config annotate.show_nr_jumps=true
      # perf config annotate.show_nr_samples=true
      # perf config
      annotate.hide_src_code=true
      annotate.show_nr_jumps=true
      annotate.show_nr_samples=true
      #
      #
    
    Before:
    
      # perf annotate --stdio2 ObjectInstance::weak_pointer_was_finalized
      Samples: 1  of event 'cycles', 4000 Hz, Event count (approx.): 830873, [percent: local period]
      ObjectInstance::weak_pointer_was_finalized() /usr/lib64/libgjs.so.0.0.0
      Percent
                  00000000000609f0 <ObjectInstance::weak_pointer_was_finalized()@@Base>:
                    endbr64
                    cmpq    $0x0,0x20(%rdi)
                  ↓ je      10
                    xor     %eax,%eax
                  ← retq
                    xchg    %ax,%ax
      100.00  10:   push    %rbp
                    cmpq    $0x0,0x18(%rdi)
                    mov     %rdi,%rbp
                  ↓ jne     20
              1b:   xor     %eax,%eax
                    pop     %rbp
                  ← retq
                    nop
              20:   lea     0x18(%rdi),%rdi
                  → callq   JS_UpdateWeakPointerAfterGC(JS::Heap<JSObject*
                    cmpq    $0x0,0x18(%rbp)
                  ↑ jne     1b
                    mov     %rbp,%rdi
                  → callq   ObjectBase::jsobj_addr() const@plt
                    mov     $0x1,%eax
                    pop     %rbp
                  ← retq
      #
    
    After:
    
      # perf annotate --stdio2 ObjectInstance::weak_pointer_was_finalized 2> /dev/null
      Samples: 1  of event 'cycles', 4000 Hz, Event count (approx.): 830873, [percent: local period]
      ObjectInstance::weak_pointer_was_finalized() /usr/lib64/libgjs.so.0.0.0
      Samples       endbr64
                    cmpq    $0x0,0x20(%rdi)
                  ↓ je      10
                    xor     %eax,%eax
                  ← retq
                    xchg    %ax,%ax
         1  1 10:   push    %rbp
                    cmpq    $0x0,0x18(%rdi)
                    mov     %rdi,%rbp
                  ↓ jne     20
            1 1b:   xor     %eax,%eax
                    pop     %rbp
                  ← retq
                    nop
            1 20:   lea     0x18(%rdi),%rdi
                  → callq   JS_UpdateWeakPointerAfterGC(JS::Heap<JSObject*
                    cmpq    $0x0,0x18(%rbp)
                  ↑ jne     1b
                    mov     %rbp,%rdi
                  → callq   ObjectBase::jsobj_addr() const@plt
                    mov     $0x1,%eax
                    pop     %rbp
                  ← retq
      #
      # perf config annotate.show_nr_jumps
      annotate.show_nr_jumps=true
      # perf config annotate.show_nr_jumps=false
      # perf config annotate.show_nr_jumps
      annotate.show_nr_jumps=false
      #
      # perf annotate --stdio2 ObjectInstance::weak_pointer_was_finalized 2> /dev/null
      Samples: 1  of event 'cycles', 4000 Hz, Event count (approx.): 830873, [percent: local period]
      ObjectInstance::weak_pointer_was_finalized() /usr/lib64/libgjs.so.0.0.0
      Samples       endbr64
                    cmpq    $0x0,0x20(%rdi)
                  ↓ je      10
                    xor     %eax,%eax
                  ← retq
                    xchg    %ax,%ax
           1  10:   push    %rbp
                    cmpq    $0x0,0x18(%rdi)
                    mov     %rdi,%rbp
                  ↓ jne     20
              1b:   xor     %eax,%eax
                    pop     %rbp
                  ← retq
                    nop
              20:   lea     0x18(%rdi),%rdi
                  → callq   JS_UpdateWeakPointerAfterGC(JS::Heap<JSObject*
                    cmpq    $0x0,0x18(%rbp)
                  ↑ jne     1b
                    mov     %rbp,%rdi
                  → callq   ObjectBase::jsobj_addr() const@plt
                    mov     $0x1,%eax
                    pop     %rbp
                  ← retq
      #
    
    Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
    Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Acked-by: Jiri Olsa <jolsa@kernel.org>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
    Cc: Changbin Du <changbin.du@intel.com>
    Cc: Ian Rogers <irogers@google.com>
    Cc: Jin Yao <yao.jin@linux.intel.com>
    Cc: Leo Yan <leo.yan@linaro.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Song Liu <songliubraving@fb.com>
    Cc: Taeung Song <treeze.taeung@gmail.com>
    Cc: Thomas Richter <tmricht@linux.ibm.com>
    Cc: Yisheng Xie <xieyisheng1@huawei.com>
    Link: http://lore.kernel.org/lkml/20200213064306.160480-6-ravi.bangoria@linux.ibm.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index ff61795a4d13..ea89077bb8e0 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -605,7 +605,7 @@ int cmd_annotate(int argc, const char **argv)
 	if (ret < 0)
 		goto out_delete;
 
-	annotation_config__init();
+	annotation_config__init(&annotate.opts);
 
 	symbol_conf.try_vmlinux_path = true;
 
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 9483b3f0cae3..72a12b69f120 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -1507,7 +1507,7 @@ int cmd_report(int argc, const char **argv)
 			symbol_conf.priv_size += sizeof(u32);
 			symbol_conf.sort_by_name = true;
 		}
-		annotation_config__init();
+		annotation_config__init(&report.annotation_opts);
 	}
 
 	if (symbol__init(&session->header.env) < 0)
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 8affcab75604..cc26aeab6a66 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1683,7 +1683,7 @@ int cmd_top(int argc, const char **argv)
 	if (status < 0)
 		goto out_delete_evlist;
 
-	annotation_config__init();
+	annotation_config__init(&top.annotation_opts);
 
 	symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL);
 	status = symbol__init(NULL);
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index f0741daf94ef..3b79da595db6 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -3094,66 +3094,46 @@ int symbol__annotate2(struct map_symbol *ms, struct evsel *evsel,
 	return err;
 }
 
-#define ANNOTATION__CFG(n) \
-	{ .name = #n, .value = &annotation__default_options.n, }
-
-/*
- * Keep the entries sorted, they are bsearch'ed
- */
-static struct annotation_config {
-	const char *name;
-	void *value;
-} annotation__configs[] = {
-	ANNOTATION__CFG(hide_src_code),
-	ANNOTATION__CFG(jump_arrows),
-	ANNOTATION__CFG(offset_level),
-	ANNOTATION__CFG(show_linenr),
-	ANNOTATION__CFG(show_nr_jumps),
-	ANNOTATION__CFG(show_nr_samples),
-	ANNOTATION__CFG(show_total_period),
-	ANNOTATION__CFG(use_offset),
-};
-
-#undef ANNOTATION__CFG
-
-static int annotation_config__cmp(const void *name, const void *cfgp)
+static int annotation__config(const char *var, const char *value, void *data)
 {
-	const struct annotation_config *cfg = cfgp;
-
-	return strcmp(name, cfg->name);
-}
-
-static int annotation__config(const char *var, const char *value,
-			    void *data __maybe_unused)
-{
-	struct annotation_config *cfg;
-	const char *name;
+	struct annotation_options *opt = data;
 
 	if (!strstarts(var, "annotate."))
 		return 0;
 
-	name = var + 9;
-	cfg = bsearch(name, annotation__configs, ARRAY_SIZE(annotation__configs),
-		      sizeof(struct annotation_config), annotation_config__cmp);
-
-	if (cfg == NULL)
-		pr_debug("%s variable unknown, ignoring...", var);
-	else if (strcmp(var, "annotate.offset_level") == 0) {
-		perf_config_int(cfg->value, name, value);
-
-		if (*(int *)cfg->value > ANNOTATION__MAX_OFFSET_LEVEL)
-			*(int *)cfg->value = ANNOTATION__MAX_OFFSET_LEVEL;
-		else if (*(int *)cfg->value < ANNOTATION__MIN_OFFSET_LEVEL)
-			*(int *)cfg->value = ANNOTATION__MIN_OFFSET_LEVEL;
+	if (!strcmp(var, "annotate.offset_level")) {
+		perf_config_u8(&opt->offset_level, "offset_level", value);
+
+		if (opt->offset_level > ANNOTATION__MAX_OFFSET_LEVEL)
+			opt->offset_level = ANNOTATION__MAX_OFFSET_LEVEL;
+		else if (opt->offset_level < ANNOTATION__MIN_OFFSET_LEVEL)
+			opt->offset_level = ANNOTATION__MIN_OFFSET_LEVEL;
+	} else if (!strcmp(var, "annotate.hide_src_code")) {
+		opt->hide_src_code = perf_config_bool("hide_src_code", value);
+	} else if (!strcmp(var, "annotate.jump_arrows")) {
+		opt->jump_arrows = perf_config_bool("jump_arrows", value);
+	} else if (!strcmp(var, "annotate.show_linenr")) {
+		opt->show_linenr = perf_config_bool("show_linenr", value);
+	} else if (!strcmp(var, "annotate.show_nr_jumps")) {
+		opt->show_nr_jumps = perf_config_bool("show_nr_jumps", value);
+	} else if (!strcmp(var, "annotate.show_nr_samples")) {
+		symbol_conf.show_nr_samples = perf_config_bool("show_nr_samples",
+								value);
+	} else if (!strcmp(var, "annotate.show_total_period")) {
+		symbol_conf.show_total_period = perf_config_bool("show_total_period",
+								value);
+	} else if (!strcmp(var, "annotate.use_offset")) {
+		opt->use_offset = perf_config_bool("use_offset", value);
 	} else {
-		*(bool *)cfg->value = perf_config_bool(name, value);
+		pr_debug("%s variable unknown, ignoring...", var);
 	}
+
 	return 0;
 }
 
-void annotation_config__init(void)
+void annotation_config__init(struct annotation_options *opt)
 {
-	perf_config(annotation__config, NULL);
+	perf_config(annotation__config, opt);
 }
 
 static unsigned int parse_percent_type(char *str1, char *str2)
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index 6237c2cc582d..8e54184b43dc 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -83,8 +83,6 @@ struct annotation_options {
 	     full_path,
 	     show_linenr,
 	     show_nr_jumps,
-	     show_nr_samples,
-	     show_total_period,
 	     show_minmax_cycle,
 	     show_asm_raw,
 	     annotate_src;
@@ -413,7 +411,7 @@ static inline int symbol__tui_annotate(struct map_symbol *ms __maybe_unused,
 }
 #endif
 
-void annotation_config__init(void);
+void annotation_config__init(struct annotation_options *opt);
 
 int annotate_parse_percent_type(const struct option *opt, const char *_str,
 				int unset);

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [PATCH 0/8] perf annotate/config: More fixes
  2020-02-13  6:42 [PATCH 0/8] perf annotate/config: More fixes Ravi Bangoria
                   ` (8 preceding siblings ...)
  2020-02-16 21:15 ` [PATCH 0/8] perf annotate/config: More fixes Jiri Olsa
@ 2020-02-27 13:39 ` Arnaldo Carvalho de Melo
  9 siblings, 0 replies; 26+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-02-27 13:39 UTC (permalink / raw)
  To: Ravi Bangoria
  Cc: jolsa, xieyisheng1, alexey.budankov, treeze.taeung,
	adrian.hunter, tmricht, namhyung, irogers, songliubraving,
	yao.jin, changbin.du, leo.yan, linux-kernel

Em Thu, Feb 13, 2020 at 12:12:58PM +0530, Ravi Bangoria escreveu:
> These are the additional set of fixes on top of previous series:
> http://lore.kernel.org/r/20200204045233.474937-1-ravi.bangoria@linux.ibm.com

All applied to perf/urgent, thanks a lot!

- Arnaldo
 
> Note for the last patch:
> I couldn't understand what intel-pt.cache-divisor is really used for.
> Adrian, can you please help.
> 
> Ravi Bangoria (8):
>   perf annotate/tui: Re-render title bar after switching back from
>     script browser
>   perf annotate: Fix --show-total-period for tui/stdio2
>   perf annotate: Fix --show-nr-samples for tui/stdio2
>   perf config: Introduce perf_config_u8()
>   perf annotate: Make perf config effective
>   perf annotate: Prefer cmdline option over default config
>   perf annotate: Fix perf config option description
>   perf config: Document missing config options
> 
>  tools/perf/Documentation/perf-config.txt | 74 +++++++++++++++++++-
>  tools/perf/builtin-annotate.c            |  4 +-
>  tools/perf/builtin-report.c              |  2 +-
>  tools/perf/builtin-top.c                 |  2 +-
>  tools/perf/ui/browsers/annotate.c        | 19 +++--
>  tools/perf/util/annotate.c               | 89 +++++++++---------------
>  tools/perf/util/annotate.h               |  6 +-
>  tools/perf/util/config.c                 | 12 ++++
>  tools/perf/util/config.h                 |  1 +
>  9 files changed, 134 insertions(+), 75 deletions(-)
> 
> -- 
> 2.24.1
> 

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 0/8] perf annotate/config: More fixes
  2020-02-27 13:16     ` Jiri Olsa
@ 2020-02-27 13:43       ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 26+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-02-27 13:43 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, Ravi Bangoria, xieyisheng1,
	alexey.budankov, treeze.taeung, adrian.hunter, tmricht, namhyung,
	irogers, songliubraving, yao.jin, changbin.du, leo.yan,
	linux-kernel

Em Thu, Feb 27, 2020 at 02:16:48PM +0100, Jiri Olsa escreveu:
> On Thu, Feb 27, 2020 at 10:08:46AM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Sun, Feb 16, 2020 at 10:15:49PM +0100, Jiri Olsa escreveu:
> > > On Thu, Feb 13, 2020 at 12:12:58PM +0530, Ravi Bangoria wrote:
> > > > These are the additional set of fixes on top of previous series:
> > > > http://lore.kernel.org/r/20200204045233.474937-1-ravi.bangoria@linux.ibm.com
> > > > 
> > > > Note for the last patch:
> > > > I couldn't understand what intel-pt.cache-divisor is really used for.
> > > > Adrian, can you please help.
> > > > 
> > > > Ravi Bangoria (8):
> > > >   perf annotate/tui: Re-render title bar after switching back from
> > > >     script browser
> > > >   perf annotate: Fix --show-total-period for tui/stdio2
> > > >   perf annotate: Fix --show-nr-samples for tui/stdio2
> > > >   perf config: Introduce perf_config_u8()
> > > >   perf annotate: Make perf config effective
> > > >   perf annotate: Prefer cmdline option over default config
> > > >   perf annotate: Fix perf config option description
> > > >   perf config: Document missing config options
> > > 
> > > nice, I guess this all worked in the past but got broken because
> > > we don't have any tests for annotation code.. any chance you could
> > 
> > I'm going thru them, can I take that "nice" as an Acked-by? Have you
> > gone thru those patches?
> 
> nope, I just real fast checked on them.. I expected more discussion on tests ;-)

Ok, I tested all of the patches, and merged them, thanks,

- Arnaldo
 
> but as Ravi wrote, it could take some time
> 
> jirka
> 
> > 
> > - Arnaldo
> > 
> > > think of some way to test annotations?
> >  
> > > perhaps some shell script, or prepare all the needed data for annotation
> > > manualy.. sort of like we did in tests/hists_*.c
> > > 
> > > thanks,
> > > jirka
> > > 
> > > > 
> > > >  tools/perf/Documentation/perf-config.txt | 74 +++++++++++++++++++-
> > > >  tools/perf/builtin-annotate.c            |  4 +-
> > > >  tools/perf/builtin-report.c              |  2 +-
> > > >  tools/perf/builtin-top.c                 |  2 +-
> > > >  tools/perf/ui/browsers/annotate.c        | 19 +++--
> > > >  tools/perf/util/annotate.c               | 89 +++++++++---------------
> > > >  tools/perf/util/annotate.h               |  6 +-
> > > >  tools/perf/util/config.c                 | 12 ++++
> > > >  tools/perf/util/config.h                 |  1 +
> > > >  9 files changed, 134 insertions(+), 75 deletions(-)
> > > > 
> > > > -- 
> > > > 2.24.1
> > > > 
> > > 
> > 
> > -- 
> > 
> > - Arnaldo
> > 
> 

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [tip: perf/urgent] perf config: Document missing config options
  2020-02-13  6:43 ` [PATCH 8/8] perf config: Document missing config options Ravi Bangoria
@ 2020-02-29  9:16   ` tip-bot2 for Ravi Bangoria
  0 siblings, 0 replies; 26+ messages in thread
From: tip-bot2 for Ravi Bangoria @ 2020-02-29  9:16 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Ravi Bangoria, Adrian Hunter, Alexey Budankov, Changbin Du,
	Ian Rogers, Jin Yao, Jiri Olsa, Leo Yan, Namhyung Kim, Song Liu,
	Taeung Song, Thomas Richter, Yisheng Xie,
	Arnaldo Carvalho de Melo, x86, LKML

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     b0aaf4c8f31feb21de59df723231c286df2d6be3
Gitweb:        https://git.kernel.org/tip/b0aaf4c8f31feb21de59df723231c286df2d6be3
Author:        Ravi Bangoria <ravi.bangoria@linux.ibm.com>
AuthorDate:    Thu, 13 Feb 2020 12:13:06 +05:30
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Thu, 27 Feb 2020 10:45:19 -03:00

perf config: Document missing config options

While documenting annotate.show_nr_samples config option, I found many
other config options missing in perf-config documentation. Add them.

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Changbin Du <changbin.du@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Song Liu <songliubraving@fb.com>
Cc: Taeung Song <treeze.taeung@gmail.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Yisheng Xie <xieyisheng1@huawei.com>
Link: http://lore.kernel.org/lkml/20200213064306.160480-9-ravi.bangoria@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-config.txt | 44 +++++++++++++++++++++++-
 1 file changed, 44 insertions(+)

diff --git a/tools/perf/Documentation/perf-config.txt b/tools/perf/Documentation/perf-config.txt
index 9dae0df..8ead555 100644
--- a/tools/perf/Documentation/perf-config.txt
+++ b/tools/perf/Documentation/perf-config.txt
@@ -518,6 +518,12 @@ top.*::
 		column by default.
 		The default is 'true'.
 
+	top.call-graph::
+		This is identical to 'call-graph.record-mode', except it is
+		applicable only for 'top' subcommand. This option ONLY setup
+		the unwind method. To enable 'perf top' to actually use it,
+		the command line option -g must be specified.
+
 man.*::
 	man.viewer::
 		This option can assign a tool to view manual pages when 'help'
@@ -545,6 +551,16 @@ record.*::
 		But if this option is 'no-cache', it will not update the build-id cache.
 		'skip' skips post-processing and does not update the cache.
 
+	record.call-graph::
+		This is identical to 'call-graph.record-mode', except it is
+		applicable only for 'record' subcommand. This option ONLY setup
+		the unwind method. To enable 'perf record' to actually use it,
+		the command line option -g must be specified.
+
+	record.aio::
+		Use 'n' control blocks in asynchronous (Posix AIO) trace writing
+		mode ('n' default: 1, max: 4).
+
 diff.*::
 	diff.order::
 		This option sets the number of columns to sort the result.
@@ -594,6 +610,11 @@ trace.*::
 		"libbeauty", the default, to use the same argument beautifiers used in the
 		strace-like sys_enter+sys_exit lines.
 
+ftrace.*::
+	ftrace.tracer::
+		Can be used to select the default tracer. Possible values are
+		'function' and 'function_graph'.
+
 llvm.*::
 	llvm.clang-path::
 		Path to clang. If omit, search it from $PATH.
@@ -638,6 +659,29 @@ scripts.*::
 	The script gets the same options passed as a full perf script,
 	in particular -i perfdata file, --cpu, --tid
 
+convert.*::
+
+	convert.queue-size::
+		Limit the size of ordered_events queue, so we could control
+		allocation size of perf data files without proper finished
+		round events.
+
+intel-pt.*::
+
+	intel-pt.cache-divisor::
+
+	intel-pt.mispred-all::
+		If set, Intel PT decoder will set the mispred flag on all
+		branches.
+
+auxtrace.*::
+
+	auxtrace.dumpdir::
+		s390 only. The directory to save the auxiliary trace buffer
+		can be changed using this option. Ex, auxtrace.dumpdir=/tmp.
+		If the directory does not exist or has the wrong file type,
+		the current directory is used.
+
 SEE ALSO
 --------
 linkperf:perf[1]

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [tip: perf/urgent] perf annotate: Prefer cmdline option over default config
  2020-02-13  6:43 ` [PATCH 6/8] perf annotate: Prefer cmdline option over default config Ravi Bangoria
@ 2020-02-29  9:16   ` tip-bot2 for Ravi Bangoria
  0 siblings, 0 replies; 26+ messages in thread
From: tip-bot2 for Ravi Bangoria @ 2020-02-29  9:16 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Ravi Bangoria, Arnaldo Carvalho de Melo, Adrian Hunter,
	Alexey Budankov, Changbin Du, Ian Rogers, Jin Yao, Jiri Olsa,
	Leo Yan, Namhyung Kim, Song Liu, Taeung Song, Thomas Richter,
	Yisheng Xie, x86, LKML

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     812b0f528240ab0e6c58911fcfcb61f4ed811ca2
Gitweb:        https://git.kernel.org/tip/812b0f528240ab0e6c58911fcfcb61f4ed811ca2
Author:        Ravi Bangoria <ravi.bangoria@linux.ibm.com>
AuthorDate:    Thu, 13 Feb 2020 12:13:04 +05:30
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Thu, 27 Feb 2020 10:45:08 -03:00

perf annotate: Prefer cmdline option over default config

For all the perf-config options that can also be set from command line
option, the preference is given to command line version in case of any
conflict. But that's opposite in case of perf annotate. i.e. the more
preference is given to default option rather than command line option.
Fix it.

Before:

  $ ./perf config
  annotate.show_nr_samples=false

  $ ./perf annotate shash --show-nr-samples
  Percent│
         │24:   mov    -0xc(%rbp),%eax
   49.19 │      imul   $0x1003f,%eax,%ecx
         │      mov    -0x18(%rbp),%rax

After:

  Samples│
         │24:   mov    -0xc(%rbp),%eax
       1 │      imul   $0x1003f,%eax,%ecx
         │      mov    -0x18(%rbp),%rax

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Changbin Du <changbin.du@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Song Liu <songliubraving@fb.com>
Cc: Taeung Song <treeze.taeung@gmail.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Yisheng Xie <xieyisheng1@huawei.com>
Link: http://lore.kernel.org/lkml/20200213064306.160480-7-ravi.bangoria@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-annotate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index ea89077..6c0a041 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -566,6 +566,8 @@ int cmd_annotate(int argc, const char **argv)
 	if (ret < 0)
 		return ret;
 
+	annotation_config__init(&annotate.opts);
+
 	argc = parse_options(argc, argv, options, annotate_usage, 0);
 	if (argc) {
 		/*
@@ -605,8 +607,6 @@ int cmd_annotate(int argc, const char **argv)
 	if (ret < 0)
 		goto out_delete;
 
-	annotation_config__init(&annotate.opts);
-
 	symbol_conf.try_vmlinux_path = true;
 
 	ret = symbol__init(&annotate.session->header.env);

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [tip: perf/urgent] perf annotate: Make perf config effective
  2020-02-13  6:43 ` [PATCH 5/8] perf annotate: Make perf config effective Ravi Bangoria
  2020-02-27 13:32   ` Arnaldo Carvalho de Melo
@ 2020-02-29  9:16   ` tip-bot2 for Ravi Bangoria
  1 sibling, 0 replies; 26+ messages in thread
From: tip-bot2 for Ravi Bangoria @ 2020-02-29  9:16 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Ravi Bangoria, Arnaldo Carvalho de Melo, Adrian Hunter,
	Alexey Budankov, Changbin Du, Ian Rogers, Jin Yao, Jiri Olsa,
	Leo Yan, Namhyung Kim, Song Liu, Taeung Song, Thomas Richter,
	Yisheng Xie, x86, LKML

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     7384083ba616092e62df7bfb4f2034730e631e40
Gitweb:        https://git.kernel.org/tip/7384083ba616092e62df7bfb4f2034730e631e40
Author:        Ravi Bangoria <ravi.bangoria@linux.ibm.com>
AuthorDate:    Thu, 13 Feb 2020 12:13:03 +05:30
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Thu, 27 Feb 2020 10:44:59 -03:00

perf annotate: Make perf config effective

perf default config set by user in [annotate] section is totally ignored
by annotate code. Fix it.

Before:

  $ ./perf config
  annotate.hide_src_code=true
  annotate.show_nr_jumps=true
  annotate.show_nr_samples=true

  $ ./perf annotate shash
         │    unsigned h = 0;
         │      movl   $0x0,-0xc(%rbp)
         │    while (*s)
         │    ↓ jmp    44
         │    h = 65599 * h + *s++;
   11.33 │24:   mov    -0xc(%rbp),%eax
   43.50 │      imul   $0x1003f,%eax,%ecx
         │      mov    -0x18(%rbp),%rax

After:

         │        movl   $0x0,-0xc(%rbp)
         │      ↓ jmp    44
       1 │1 24:   mov    -0xc(%rbp),%eax
       4 │        imul   $0x1003f,%eax,%ecx
         │        mov    -0x18(%rbp),%rax

Note that we have removed show_nr_samples and show_total_period from
annotation_options because they are not used. Instead of them we use
symbol_conf.show_nr_samples and symbol_conf.show_total_period.

Committer testing:

Using 'perf annotate --stdio2' to use the TUI rendering but emitting the output to stdio:

  # perf config
  #
  # perf config annotate.hide_src_code=true
  # perf config
  annotate.hide_src_code=true
  #
  # perf config annotate.show_nr_jumps=true
  # perf config annotate.show_nr_samples=true
  # perf config
  annotate.hide_src_code=true
  annotate.show_nr_jumps=true
  annotate.show_nr_samples=true
  #
  #

Before:

  # perf annotate --stdio2 ObjectInstance::weak_pointer_was_finalized
  Samples: 1  of event 'cycles', 4000 Hz, Event count (approx.): 830873, [percent: local period]
  ObjectInstance::weak_pointer_was_finalized() /usr/lib64/libgjs.so.0.0.0
  Percent
              00000000000609f0 <ObjectInstance::weak_pointer_was_finalized()@@Base>:
                endbr64
                cmpq    $0x0,0x20(%rdi)
              ↓ je      10
                xor     %eax,%eax
              ← retq
                xchg    %ax,%ax
  100.00  10:   push    %rbp
                cmpq    $0x0,0x18(%rdi)
                mov     %rdi,%rbp
              ↓ jne     20
          1b:   xor     %eax,%eax
                pop     %rbp
              ← retq
                nop
          20:   lea     0x18(%rdi),%rdi
              → callq   JS_UpdateWeakPointerAfterGC(JS::Heap<JSObject*
                cmpq    $0x0,0x18(%rbp)
              ↑ jne     1b
                mov     %rbp,%rdi
              → callq   ObjectBase::jsobj_addr() const@plt
                mov     $0x1,%eax
                pop     %rbp
              ← retq
  #

After:

  # perf annotate --stdio2 ObjectInstance::weak_pointer_was_finalized 2> /dev/null
  Samples: 1  of event 'cycles', 4000 Hz, Event count (approx.): 830873, [percent: local period]
  ObjectInstance::weak_pointer_was_finalized() /usr/lib64/libgjs.so.0.0.0
  Samples       endbr64
                cmpq    $0x0,0x20(%rdi)
              ↓ je      10
                xor     %eax,%eax
              ← retq
                xchg    %ax,%ax
     1  1 10:   push    %rbp
                cmpq    $0x0,0x18(%rdi)
                mov     %rdi,%rbp
              ↓ jne     20
        1 1b:   xor     %eax,%eax
                pop     %rbp
              ← retq
                nop
        1 20:   lea     0x18(%rdi),%rdi
              → callq   JS_UpdateWeakPointerAfterGC(JS::Heap<JSObject*
                cmpq    $0x0,0x18(%rbp)
              ↑ jne     1b
                mov     %rbp,%rdi
              → callq   ObjectBase::jsobj_addr() const@plt
                mov     $0x1,%eax
                pop     %rbp
              ← retq
  #
  # perf config annotate.show_nr_jumps
  annotate.show_nr_jumps=true
  # perf config annotate.show_nr_jumps=false
  # perf config annotate.show_nr_jumps
  annotate.show_nr_jumps=false
  #
  # perf annotate --stdio2 ObjectInstance::weak_pointer_was_finalized 2> /dev/null
  Samples: 1  of event 'cycles', 4000 Hz, Event count (approx.): 830873, [percent: local period]
  ObjectInstance::weak_pointer_was_finalized() /usr/lib64/libgjs.so.0.0.0
  Samples       endbr64
                cmpq    $0x0,0x20(%rdi)
              ↓ je      10
                xor     %eax,%eax
              ← retq
                xchg    %ax,%ax
       1  10:   push    %rbp
                cmpq    $0x0,0x18(%rdi)
                mov     %rdi,%rbp
              ↓ jne     20
          1b:   xor     %eax,%eax
                pop     %rbp
              ← retq
                nop
          20:   lea     0x18(%rdi),%rdi
              → callq   JS_UpdateWeakPointerAfterGC(JS::Heap<JSObject*
                cmpq    $0x0,0x18(%rbp)
              ↑ jne     1b
                mov     %rbp,%rdi
              → callq   ObjectBase::jsobj_addr() const@plt
                mov     $0x1,%eax
                pop     %rbp
              ← retq
  #

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Changbin Du <changbin.du@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Song Liu <songliubraving@fb.com>
Cc: Taeung Song <treeze.taeung@gmail.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Yisheng Xie <xieyisheng1@huawei.com>
Link: http://lore.kernel.org/lkml/20200213064306.160480-6-ravi.bangoria@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-annotate.c |  2 +-
 tools/perf/builtin-report.c   |  2 +-
 tools/perf/builtin-top.c      |  2 +-
 tools/perf/util/annotate.c    | 78 ++++++++++++----------------------
 tools/perf/util/annotate.h    |  4 +--
 5 files changed, 33 insertions(+), 55 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index ff61795..ea89077 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -605,7 +605,7 @@ int cmd_annotate(int argc, const char **argv)
 	if (ret < 0)
 		goto out_delete;
 
-	annotation_config__init();
+	annotation_config__init(&annotate.opts);
 
 	symbol_conf.try_vmlinux_path = true;
 
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 9483b3f..72a12b6 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -1507,7 +1507,7 @@ repeat:
 			symbol_conf.priv_size += sizeof(u32);
 			symbol_conf.sort_by_name = true;
 		}
-		annotation_config__init();
+		annotation_config__init(&report.annotation_opts);
 	}
 
 	if (symbol__init(&session->header.env) < 0)
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 8affcab..cc26aea 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1683,7 +1683,7 @@ int cmd_top(int argc, const char **argv)
 	if (status < 0)
 		goto out_delete_evlist;
 
-	annotation_config__init();
+	annotation_config__init(&top.annotation_opts);
 
 	symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL);
 	status = symbol__init(NULL);
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index f0741da..3b79da5 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -3094,66 +3094,46 @@ out_free_offsets:
 	return err;
 }
 
-#define ANNOTATION__CFG(n) \
-	{ .name = #n, .value = &annotation__default_options.n, }
-
-/*
- * Keep the entries sorted, they are bsearch'ed
- */
-static struct annotation_config {
-	const char *name;
-	void *value;
-} annotation__configs[] = {
-	ANNOTATION__CFG(hide_src_code),
-	ANNOTATION__CFG(jump_arrows),
-	ANNOTATION__CFG(offset_level),
-	ANNOTATION__CFG(show_linenr),
-	ANNOTATION__CFG(show_nr_jumps),
-	ANNOTATION__CFG(show_nr_samples),
-	ANNOTATION__CFG(show_total_period),
-	ANNOTATION__CFG(use_offset),
-};
-
-#undef ANNOTATION__CFG
-
-static int annotation_config__cmp(const void *name, const void *cfgp)
+static int annotation__config(const char *var, const char *value, void *data)
 {
-	const struct annotation_config *cfg = cfgp;
-
-	return strcmp(name, cfg->name);
-}
-
-static int annotation__config(const char *var, const char *value,
-			    void *data __maybe_unused)
-{
-	struct annotation_config *cfg;
-	const char *name;
+	struct annotation_options *opt = data;
 
 	if (!strstarts(var, "annotate."))
 		return 0;
 
-	name = var + 9;
-	cfg = bsearch(name, annotation__configs, ARRAY_SIZE(annotation__configs),
-		      sizeof(struct annotation_config), annotation_config__cmp);
-
-	if (cfg == NULL)
-		pr_debug("%s variable unknown, ignoring...", var);
-	else if (strcmp(var, "annotate.offset_level") == 0) {
-		perf_config_int(cfg->value, name, value);
-
-		if (*(int *)cfg->value > ANNOTATION__MAX_OFFSET_LEVEL)
-			*(int *)cfg->value = ANNOTATION__MAX_OFFSET_LEVEL;
-		else if (*(int *)cfg->value < ANNOTATION__MIN_OFFSET_LEVEL)
-			*(int *)cfg->value = ANNOTATION__MIN_OFFSET_LEVEL;
+	if (!strcmp(var, "annotate.offset_level")) {
+		perf_config_u8(&opt->offset_level, "offset_level", value);
+
+		if (opt->offset_level > ANNOTATION__MAX_OFFSET_LEVEL)
+			opt->offset_level = ANNOTATION__MAX_OFFSET_LEVEL;
+		else if (opt->offset_level < ANNOTATION__MIN_OFFSET_LEVEL)
+			opt->offset_level = ANNOTATION__MIN_OFFSET_LEVEL;
+	} else if (!strcmp(var, "annotate.hide_src_code")) {
+		opt->hide_src_code = perf_config_bool("hide_src_code", value);
+	} else if (!strcmp(var, "annotate.jump_arrows")) {
+		opt->jump_arrows = perf_config_bool("jump_arrows", value);
+	} else if (!strcmp(var, "annotate.show_linenr")) {
+		opt->show_linenr = perf_config_bool("show_linenr", value);
+	} else if (!strcmp(var, "annotate.show_nr_jumps")) {
+		opt->show_nr_jumps = perf_config_bool("show_nr_jumps", value);
+	} else if (!strcmp(var, "annotate.show_nr_samples")) {
+		symbol_conf.show_nr_samples = perf_config_bool("show_nr_samples",
+								value);
+	} else if (!strcmp(var, "annotate.show_total_period")) {
+		symbol_conf.show_total_period = perf_config_bool("show_total_period",
+								value);
+	} else if (!strcmp(var, "annotate.use_offset")) {
+		opt->use_offset = perf_config_bool("use_offset", value);
 	} else {
-		*(bool *)cfg->value = perf_config_bool(name, value);
+		pr_debug("%s variable unknown, ignoring...", var);
 	}
+
 	return 0;
 }
 
-void annotation_config__init(void)
+void annotation_config__init(struct annotation_options *opt)
 {
-	perf_config(annotation__config, NULL);
+	perf_config(annotation__config, opt);
 }
 
 static unsigned int parse_percent_type(char *str1, char *str2)
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index 6237c2c..8e54184 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -83,8 +83,6 @@ struct annotation_options {
 	     full_path,
 	     show_linenr,
 	     show_nr_jumps,
-	     show_nr_samples,
-	     show_total_period,
 	     show_minmax_cycle,
 	     show_asm_raw,
 	     annotate_src;
@@ -413,7 +411,7 @@ static inline int symbol__tui_annotate(struct map_symbol *ms __maybe_unused,
 }
 #endif
 
-void annotation_config__init(void);
+void annotation_config__init(struct annotation_options *opt);
 
 int annotate_parse_percent_type(const struct option *opt, const char *_str,
 				int unset);

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [tip: perf/urgent] perf annotate: Fix perf config option description
  2020-02-13  6:43 ` [PATCH 7/8] perf annotate: Fix perf config option description Ravi Bangoria
@ 2020-02-29  9:16   ` tip-bot2 for Ravi Bangoria
  0 siblings, 0 replies; 26+ messages in thread
From: tip-bot2 for Ravi Bangoria @ 2020-02-29  9:16 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Ravi Bangoria, Adrian Hunter, Alexey Budankov, Changbin Du,
	Ian Rogers, Jin Yao, Jiri Olsa, Leo Yan, Namhyung Kim, Song Liu,
	Taeung Song, Thomas Richter, Yisheng Xie,
	Arnaldo Carvalho de Melo, x86, LKML

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     cd0a9c518db123e2097e03eae374e822d82493fd
Gitweb:        https://git.kernel.org/tip/cd0a9c518db123e2097e03eae374e822d82493fd
Author:        Ravi Bangoria <ravi.bangoria@linux.ibm.com>
AuthorDate:    Thu, 13 Feb 2020 12:13:05 +05:30
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Thu, 27 Feb 2020 10:45:13 -03:00

perf annotate: Fix perf config option description

perf config annotate options says it works only with TUI, which is wrong.
Most of the TUI options are applicable to stdio2 as well. So remove that
generic line and add individual line with each option stating which
browsers supports that option. Also, annotate.show_nr_samples config is
missing in Documentation. Describe it.

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Changbin Du <changbin.du@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Song Liu <songliubraving@fb.com>
Cc: Taeung Song <treeze.taeung@gmail.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Yisheng Xie <xieyisheng1@huawei.com>
Link: http://lore.kernel.org/lkml/20200213064306.160480-8-ravi.bangoria@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-config.txt | 30 ++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-config.txt b/tools/perf/Documentation/perf-config.txt
index c4dd23c..9dae0df 100644
--- a/tools/perf/Documentation/perf-config.txt
+++ b/tools/perf/Documentation/perf-config.txt
@@ -239,7 +239,6 @@ buildid.*::
 		set buildid.dir to /dev/null. The default is $HOME/.debug
 
 annotate.*::
-	These options work only for TUI.
 	These are in control of addresses, jump function, source code
 	in lines of assembly code from a specific program.
 
@@ -269,6 +268,8 @@ annotate.*::
 		│        mov    (%rdi),%rdx
 		│              return n;
 
+		This option works with tui, stdio2 browsers.
+
         annotate.use_offset::
 		Basing on a first address of a loaded function, offset can be used.
 		Instead of using original addresses of assembly code,
@@ -287,6 +288,8 @@ annotate.*::
 
 		             368:│  mov    0x8(%r14),%rdi
 
+		This option works with tui, stdio2 browsers.
+
 	annotate.jump_arrows::
 		There can be jump instruction among assembly code.
 		Depending on a boolean value of jump_arrows,
@@ -306,6 +309,8 @@ annotate.*::
 		│1330:   mov    %r15,%r10
 		│1333:   cmp    %r15,%r14
 
+		This option works with tui browser.
+
         annotate.show_linenr::
 		When showing source code if this option is 'true',
 		line numbers are printed as below.
@@ -325,6 +330,8 @@ annotate.*::
 		│                     array++;
 		│             }
 
+		This option works with tui, stdio2 browsers.
+
         annotate.show_nr_jumps::
 		Let's see a part of assembly code.
 
@@ -335,6 +342,8 @@ annotate.*::
 
 		│1 1382:   movb   $0x1,-0x270(%rbp)
 
+		This option works with tui, stdio2 browsers.
+
         annotate.show_total_period::
 		To compare two records on an instruction base, with this option
 		provided, display total number of samples that belong to a line
@@ -348,11 +357,30 @@ annotate.*::
 
 		99.93 │      mov    %eax,%eax
 
+		This option works with tui, stdio2, stdio browsers.
+
+	annotate.show_nr_samples::
+		By default perf annotate shows percentage of samples. This option
+		can be used to print absolute number of samples. Ex, when set as
+		false:
+
+		Percent│
+		 74.03 │      mov    %fs:0x28,%rax
+
+		When set as true:
+
+		Samples│
+		     6 │      mov    %fs:0x28,%rax
+
+		This option works with tui, stdio2, stdio browsers.
+
 	annotate.offset_level::
 		Default is '1', meaning just jump targets will have offsets show right beside
 		the instruction. When set to '2' 'call' instructions will also have its offsets
 		shown, 3 or higher will show offsets for all instructions.
 
+		This option works with tui, stdio2 browsers.
+
 hist.*::
 	hist.percentage::
 		This option control the way to calculate overhead of filtered entries -

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [tip: perf/urgent] perf config: Introduce perf_config_u8()
  2020-02-13  6:43 ` [PATCH 4/8] perf config: Introduce perf_config_u8() Ravi Bangoria
@ 2020-02-29  9:16   ` tip-bot2 for Ravi Bangoria
  0 siblings, 0 replies; 26+ messages in thread
From: tip-bot2 for Ravi Bangoria @ 2020-02-29  9:16 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Ravi Bangoria, Adrian Hunter, Alexey Budankov, Changbin Du,
	Ian Rogers, Jin Yao, Jiri Olsa, Leo Yan, Namhyung Kim, Song Liu,
	Taeung Song, Thomas Richter, Yisheng Xie,
	Arnaldo Carvalho de Melo, x86, LKML

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     7b43b6970474757da68e89efb76e892219dea9d8
Gitweb:        https://git.kernel.org/tip/7b43b6970474757da68e89efb76e892219dea9d8
Author:        Ravi Bangoria <ravi.bangoria@linux.ibm.com>
AuthorDate:    Thu, 13 Feb 2020 12:13:02 +05:30
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Thu, 27 Feb 2020 10:44:54 -03:00

perf config: Introduce perf_config_u8()

Introduce perf_config_u8() utility function to convert char * input into
u8 destination. We will utilize it in followup patch.

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Changbin Du <changbin.du@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Song Liu <songliubraving@fb.com>
Cc: Taeung Song <treeze.taeung@gmail.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Yisheng Xie <xieyisheng1@huawei.com>
Link: http://lore.kernel.org/lkml/20200213064306.160480-5-ravi.bangoria@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/config.c | 12 ++++++++++++
 tools/perf/util/config.h |  1 +
 2 files changed, 13 insertions(+)

diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index 0bc9c4d..ef38eba 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -374,6 +374,18 @@ int perf_config_int(int *dest, const char *name, const char *value)
 	return 0;
 }
 
+int perf_config_u8(u8 *dest, const char *name, const char *value)
+{
+	long ret = 0;
+
+	if (!perf_parse_long(value, &ret)) {
+		bad_config(name);
+		return -1;
+	}
+	*dest = ret;
+	return 0;
+}
+
 static int perf_config_bool_or_int(const char *name, const char *value, int *is_bool)
 {
 	int ret;
diff --git a/tools/perf/util/config.h b/tools/perf/util/config.h
index bd0a589..c10b66d 100644
--- a/tools/perf/util/config.h
+++ b/tools/perf/util/config.h
@@ -29,6 +29,7 @@ typedef int (*config_fn_t)(const char *, const char *, void *);
 int perf_default_config(const char *, const char *, void *);
 int perf_config(config_fn_t fn, void *);
 int perf_config_int(int *dest, const char *, const char *);
+int perf_config_u8(u8 *dest, const char *name, const char *value);
 int perf_config_u64(u64 *dest, const char *, const char *);
 int perf_config_bool(const char *, const char *);
 int config_error_nonbool(const char *);

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [tip: perf/urgent] perf annotate: Fix --show-nr-samples for tui/stdio2
  2020-02-13  6:43 ` [PATCH 3/8] perf annotate: Fix --show-nr-samples " Ravi Bangoria
@ 2020-02-29  9:16   ` tip-bot2 for Ravi Bangoria
  0 siblings, 0 replies; 26+ messages in thread
From: tip-bot2 for Ravi Bangoria @ 2020-02-29  9:16 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Ravi Bangoria, Arnaldo Carvalho de Melo, Adrian Hunter,
	Alexey Budankov, Changbin Du, Ian Rogers, Jin Yao, Jiri Olsa,
	Leo Yan, Namhyung Kim, Song Liu, Taeung Song, Thomas Richter,
	Yisheng Xie, x86, LKML

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     46ccb44269665bba6a9bf0f77fe776421fc2304c
Gitweb:        https://git.kernel.org/tip/46ccb44269665bba6a9bf0f77fe776421fc2304c
Author:        Ravi Bangoria <ravi.bangoria@linux.ibm.com>
AuthorDate:    Thu, 13 Feb 2020 12:13:01 +05:30
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Thu, 27 Feb 2020 10:44:48 -03:00

perf annotate: Fix --show-nr-samples for tui/stdio2

perf annotate --show-nr-samples does not really show number of samples.

The reason is we have two separate variables for the same purpose.

One is in symbol_conf.show_nr_samples and another is
annotation_options.show_nr_samples.

We save command line option in symbol_conf.show_nr_samples but uses
annotation_option.show_nr_samples while rendering tui/stdio2 browser.

Though, we copy symbol_conf.show_nr_samples to
annotation__default_options.show_nr_samples but that is not really
effective as we don't use annotation__default_options once we copy
default options to dynamic variable annotate.opts in cmd_annotate().

Instead of all these complication, keep only one variable and use it all
over. symbol_conf.show_nr_samples is used by perf report/top as well. So
let's kill annotation_options.show_nr_samples.

On a side note, I've kept annotation_options.show_nr_samples definition
because it's still used by perf-config code. Follow up patch to fix
perf-config for annotate will remove annotation_options.show_nr_samples.

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Changbin Du <changbin.du@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Song Liu <songliubraving@fb.com>
Cc: Taeung Song <treeze.taeung@gmail.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Yisheng Xie <xieyisheng1@huawei.com>
Link: http://lore.kernel.org/lkml/20200213064306.160480-4-ravi.bangoria@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/browsers/annotate.c | 6 +++---
 tools/perf/util/annotate.c        | 6 ++----
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 7e5b44b..9023267 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -835,9 +835,9 @@ show_sup_ins:
 		case 't':
 			if (symbol_conf.show_total_period) {
 				symbol_conf.show_total_period = false;
-				notes->options->show_nr_samples = true;
-			} else if (notes->options->show_nr_samples)
-				notes->options->show_nr_samples = false;
+				symbol_conf.show_nr_samples = true;
+			} else if (symbol_conf.show_nr_samples)
+				symbol_conf.show_nr_samples = false;
 			else
 				symbol_conf.show_total_period = true;
 			annotation__update_column_widths(notes);
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index fe4b44d..f0741da 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -2917,7 +2917,7 @@ static void __annotation_line__write(struct annotation_line *al, struct annotati
 			obj__set_percent_color(obj, percent, current_entry);
 			if (symbol_conf.show_total_period) {
 				obj__printf(obj, "%11" PRIu64 " ", al->data[i].he.period);
-			} else if (notes->options->show_nr_samples) {
+			} else if (symbol_conf.show_nr_samples) {
 				obj__printf(obj, "%6" PRIu64 " ",
 						   al->data[i].he.nr_samples);
 			} else {
@@ -2932,7 +2932,7 @@ static void __annotation_line__write(struct annotation_line *al, struct annotati
 		else {
 			obj__printf(obj, "%-*s", pcnt_width,
 					   symbol_conf.show_total_period ? "Period" :
-					   notes->options->show_nr_samples ? "Samples" : "Percent");
+					   symbol_conf.show_nr_samples ? "Samples" : "Percent");
 		}
 	}
 
@@ -3154,8 +3154,6 @@ static int annotation__config(const char *var, const char *value,
 void annotation_config__init(void)
 {
 	perf_config(annotation__config, NULL);
-
-	annotation__default_options.show_nr_samples   = symbol_conf.show_nr_samples;
 }
 
 static unsigned int parse_percent_type(char *str1, char *str2)

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [tip: perf/urgent] perf annotate: Fix --show-total-period for tui/stdio2
  2020-02-13  6:43 ` [PATCH 2/8] perf annotate: Fix --show-total-period for tui/stdio2 Ravi Bangoria
  2020-02-27 13:14   ` Arnaldo Carvalho de Melo
@ 2020-02-29  9:16   ` tip-bot2 for Ravi Bangoria
  1 sibling, 0 replies; 26+ messages in thread
From: tip-bot2 for Ravi Bangoria @ 2020-02-29  9:16 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Ravi Bangoria, Arnaldo Carvalho de Melo, Adrian Hunter,
	Alexey Budankov, Changbin Du, Ian Rogers, Jin Yao, Jiri Olsa,
	Leo Yan, Namhyung Kim, Song Liu, Taeung Song, Thomas Richter,
	Yisheng Xie, x86, LKML

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     68aac855b643e1540012cbefa0dee06207c3dc64
Gitweb:        https://git.kernel.org/tip/68aac855b643e1540012cbefa0dee06207c3dc64
Author:        Ravi Bangoria <ravi.bangoria@linux.ibm.com>
AuthorDate:    Thu, 13 Feb 2020 12:13:00 +05:30
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Thu, 27 Feb 2020 10:44:40 -03:00

perf annotate: Fix --show-total-period for tui/stdio2

perf annotate --show-total-period does not really show total period.

The reason is we have two separate variables for the same purpose.

One is in symbol_conf.show_total_period and another is
annotation_options.show_total_period.

We save command line option in symbol_conf.show_total_period but uses
annotation_option.show_total_period while rendering tui/stdio2 browser.

Though, we copy symbol_conf.show_total_period to
annotation__default_options.show_total_period but that is not really
effective as we don't use annotation__default_options once we copy
default options to dynamic variable annotate.opts in cmd_annotate().

Instead of all these complication, keep only one variable and use it all
over. symbol_conf.show_total_period is used by perf report/top as well.
So let's kill annotation_options.show_total_period.

On a side note, I've kept annotation_options.show_total_period
definition because it's still used by perf-config code. Follow up patch
to fix perf-config for annotate will remove
annotation_options.show_total_period.

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Changbin Du <changbin.du@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Song Liu <songliubraving@fb.com>
Cc: Taeung Song <treeze.taeung@gmail.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Yisheng Xie <xieyisheng1@huawei.com>
Link: http://lore.kernel.org/lkml/20200213064306.160480-3-ravi.bangoria@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/browsers/annotate.c | 6 +++---
 tools/perf/util/annotate.c        | 5 ++---
 tools/perf/util/annotate.h        | 2 +-
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 0dbbf35..7e5b44b 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -833,13 +833,13 @@ show_sup_ins:
 			map_symbol__annotation_dump(ms, evsel, browser->opts);
 			continue;
 		case 't':
-			if (notes->options->show_total_period) {
-				notes->options->show_total_period = false;
+			if (symbol_conf.show_total_period) {
+				symbol_conf.show_total_period = false;
 				notes->options->show_nr_samples = true;
 			} else if (notes->options->show_nr_samples)
 				notes->options->show_nr_samples = false;
 			else
-				notes->options->show_total_period = true;
+				symbol_conf.show_total_period = true;
 			annotation__update_column_widths(notes);
 			continue;
 		case 'c':
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index ca73fb7..fe4b44d 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -2915,7 +2915,7 @@ static void __annotation_line__write(struct annotation_line *al, struct annotati
 			percent = annotation_data__percent(&al->data[i], percent_type);
 
 			obj__set_percent_color(obj, percent, current_entry);
-			if (notes->options->show_total_period) {
+			if (symbol_conf.show_total_period) {
 				obj__printf(obj, "%11" PRIu64 " ", al->data[i].he.period);
 			} else if (notes->options->show_nr_samples) {
 				obj__printf(obj, "%6" PRIu64 " ",
@@ -2931,7 +2931,7 @@ static void __annotation_line__write(struct annotation_line *al, struct annotati
 			obj__printf(obj, "%-*s", pcnt_width, " ");
 		else {
 			obj__printf(obj, "%-*s", pcnt_width,
-					   notes->options->show_total_period ? "Period" :
+					   symbol_conf.show_total_period ? "Period" :
 					   notes->options->show_nr_samples ? "Samples" : "Percent");
 		}
 	}
@@ -3155,7 +3155,6 @@ void annotation_config__init(void)
 {
 	perf_config(annotation__config, NULL);
 
-	annotation__default_options.show_total_period = symbol_conf.show_total_period;
 	annotation__default_options.show_nr_samples   = symbol_conf.show_nr_samples;
 }
 
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index 455403e..6237c2c 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -309,7 +309,7 @@ static inline int annotation__cycles_width(struct annotation *notes)
 
 static inline int annotation__pcnt_width(struct annotation *notes)
 {
-	return (notes->options->show_total_period ? 12 : 7) * notes->nr_events;
+	return (symbol_conf.show_total_period ? 12 : 7) * notes->nr_events;
 }
 
 static inline bool annotation_line__filter(struct annotation_line *al, struct annotation *notes)

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [tip: perf/urgent] perf annotate/tui: Re-render title bar after switching back from script browser
  2020-02-13  6:42 ` [PATCH 1/8] perf annotate/tui: Re-render title bar after switching back from script browser Ravi Bangoria
  2020-02-27 13:11   ` Arnaldo Carvalho de Melo
@ 2020-02-29  9:16   ` tip-bot2 for Ravi Bangoria
  1 sibling, 0 replies; 26+ messages in thread
From: tip-bot2 for Ravi Bangoria @ 2020-02-29  9:16 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Ravi Bangoria, Arnaldo Carvalho de Melo, Adrian Hunter,
	Alexey Budankov, Changbin Du, Ian Rogers, Jin Yao, Jiri Olsa,
	Leo Yan, Namhyung Kim, Song Liu, Taeung Song, Thomas Richter,
	Yisheng Xie, x86, LKML

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     54cf752cfb75602c256e94db6fdfd3de9dfbbef1
Gitweb:        https://git.kernel.org/tip/54cf752cfb75602c256e94db6fdfd3de9dfbbef1
Author:        Ravi Bangoria <ravi.bangoria@linux.ibm.com>
AuthorDate:    Thu, 13 Feb 2020 12:12:59 +05:30
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Thu, 27 Feb 2020 10:44:14 -03:00

perf annotate/tui: Re-render title bar after switching back from script browser

The 'perf annotate' TUI browser provides a 'r' hot key to switch to a
script browser. But the annotate browser title bar becomes hidden while
switching back from script browser. Fix it.

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Changbin Du <changbin.du@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Song Liu <songliubraving@fb.com>
Cc: Taeung Song <treeze.taeung@gmail.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Yisheng Xie <xieyisheng1@huawei.com>
Link: http://lore.kernel.org/lkml/20200213064306.160480-2-ravi.bangoria@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/browsers/annotate.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index badbddb..0dbbf35 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -754,10 +754,9 @@ static int annotate_browser__run(struct annotate_browser *browser,
 		"?             Search string backwards\n");
 			continue;
 		case 'r':
-			{
-				script_browse(NULL, NULL);
-				continue;
-			}
+			script_browse(NULL, NULL);
+			annotate_browser__show(&browser->b, title, help);
+			continue;
 		case 'k':
 			notes->options->show_linenr = !notes->options->show_linenr;
 			break;

^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2020-02-29  9:17 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-13  6:42 [PATCH 0/8] perf annotate/config: More fixes Ravi Bangoria
2020-02-13  6:42 ` [PATCH 1/8] perf annotate/tui: Re-render title bar after switching back from script browser Ravi Bangoria
2020-02-27 13:11   ` Arnaldo Carvalho de Melo
2020-02-29  9:16   ` [tip: perf/urgent] " tip-bot2 for Ravi Bangoria
2020-02-13  6:43 ` [PATCH 2/8] perf annotate: Fix --show-total-period for tui/stdio2 Ravi Bangoria
2020-02-27 13:14   ` Arnaldo Carvalho de Melo
2020-02-29  9:16   ` [tip: perf/urgent] " tip-bot2 for Ravi Bangoria
2020-02-13  6:43 ` [PATCH 3/8] perf annotate: Fix --show-nr-samples " Ravi Bangoria
2020-02-29  9:16   ` [tip: perf/urgent] " tip-bot2 for Ravi Bangoria
2020-02-13  6:43 ` [PATCH 4/8] perf config: Introduce perf_config_u8() Ravi Bangoria
2020-02-29  9:16   ` [tip: perf/urgent] " tip-bot2 for Ravi Bangoria
2020-02-13  6:43 ` [PATCH 5/8] perf annotate: Make perf config effective Ravi Bangoria
2020-02-27 13:32   ` Arnaldo Carvalho de Melo
2020-02-29  9:16   ` [tip: perf/urgent] " tip-bot2 for Ravi Bangoria
2020-02-13  6:43 ` [PATCH 6/8] perf annotate: Prefer cmdline option over default config Ravi Bangoria
2020-02-29  9:16   ` [tip: perf/urgent] " tip-bot2 for Ravi Bangoria
2020-02-13  6:43 ` [PATCH 7/8] perf annotate: Fix perf config option description Ravi Bangoria
2020-02-29  9:16   ` [tip: perf/urgent] " tip-bot2 for Ravi Bangoria
2020-02-13  6:43 ` [PATCH 8/8] perf config: Document missing config options Ravi Bangoria
2020-02-29  9:16   ` [tip: perf/urgent] " tip-bot2 for Ravi Bangoria
2020-02-16 21:15 ` [PATCH 0/8] perf annotate/config: More fixes Jiri Olsa
2020-02-17 13:02   ` Ravi Bangoria
2020-02-27 13:08   ` Arnaldo Carvalho de Melo
2020-02-27 13:16     ` Jiri Olsa
2020-02-27 13:43       ` Arnaldo Carvalho de Melo
2020-02-27 13:39 ` Arnaldo Carvalho de Melo

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).