Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1434369 > unrolled thread

[PATCH] perf/annotate: Add number of samples to the header

Started byPeter Zijlstra <peterz@infradead.org>
First post2016-06-30 10:40 +0200
Last post2016-07-01 08:50 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] perf/annotate: Add number of samples to the header Peter Zijlstra <peterz@infradead.org> - 2016-06-30 10:40 +0200
    [tip:perf/core] perf annotate: Add number of samples to the header "tip-bot for Peter Zijlstra (Intel)" <tipbot@zytor.com> - 2016-07-01 08:50 +0200
    [tip:perf/core] perf annotate: Simplify header dotted line sizing "tip-bot for Peter Zijlstra (Intel)" <tipbot@zytor.com> - 2016-07-01 08:50 +0200

#1434369 — [PATCH] perf/annotate: Add number of samples to the header

FromPeter Zijlstra <peterz@infradead.org>
Date2016-06-30 10:40 +0200
Subject[PATCH] perf/annotate: Add number of samples to the header
Message-ID<rPFFU-7jk-49@gated-at.bofh.it>
Staring at annotations of large functions is useless if there's only a
few samples in them. Report the number of samples in the header to make
this easier to determine.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 tools/perf/util/annotate.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 7e5a1e8..7aba36f 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1512,13 +1512,14 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
 	const char *d_filename;
 	const char *evsel_name = perf_evsel__name(evsel);
 	struct annotation *notes = symbol__annotation(sym);
+	struct sym_hist *h = annotation__histogram(notes, evsel->idx);
 	struct disasm_line *pos, *queue = NULL;
 	u64 start = map__rip_2objdump(map, sym->start);
 	int printed = 2, queue_len = 0;
 	int more = 0;
 	u64 len;
 	int width = 8;
-	int namelen, evsel_name_len, graph_dotted_len;
+	int graph_dotted_len;
 
 	filename = strdup(dso->long_name);
 	if (!filename)
@@ -1530,17 +1531,14 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
 		d_filename = basename(filename);
 
 	len = symbol__size(sym);
-	namelen = strlen(d_filename);
-	evsel_name_len = strlen(evsel_name);
 
 	if (perf_evsel__is_group_event(evsel))
 		width *= evsel->nr_members;
 
-	printf(" %-*.*s|	Source code & Disassembly of %s for %s\n",
-	       width, width, "Percent", d_filename, evsel_name);
+	graph_dotted_len = printf(" %-*.*s|	Source code & Disassembly of %s for %s (%" PRIu64 " samples)\n",
+	       width, width, "Percent", d_filename, evsel_name, h->sum);
 
-	graph_dotted_len = width + namelen + evsel_name_len;
-	printf("-%-*.*s-----------------------------------------\n",
+	printf("%-*.*s-----\n",
 	       graph_dotted_len, graph_dotted_len, graph_dotted_line);
 
 	if (verbose)

[toc] | [next] | [standalone]


#1435051 — [tip:perf/core] perf annotate: Add number of samples to the header

From"tip-bot for Peter Zijlstra (Intel)" <tipbot@zytor.com>
Date2016-07-01 08:50 +0200
Subject[tip:perf/core] perf annotate: Add number of samples to the header
Message-ID<rQ0r0-3gE-11@gated-at.bofh.it>
In reply to#1434369
Commit-ID:  135cce1bf12bd30d7d66360022f9dac6ea3a07cd
Gitweb:     http://git.kernel.org/tip/135cce1bf12bd30d7d66360022f9dac6ea3a07cd
Author:     Peter Zijlstra (Intel) <peterz@infradead.org>
AuthorDate: Thu, 30 Jun 2016 10:29:55 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 30 Jun 2016 18:27:42 -0300

perf annotate: Add number of samples to the header

Staring at annotations of large functions is useless if there's only a
few samples in them. Report the number of samples in the header to make
this easier to determine.

Committer note:

The change amounts to:

  - Percent | Source code & Disassembly of perf-vdso.so for cycles:u
  ------------------------------------------------------------------
  + Percent | Source code & Disassembly of perf-vdso.so for cycles:u (3278 samples)
  +--------------------------------------------------------------------------------

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20160630082955.GA30921@twins.programming.kicks-ass.net
[ split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/annotate.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 78e5d6f..e9825fe 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1522,6 +1522,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
 	const char *d_filename;
 	const char *evsel_name = perf_evsel__name(evsel);
 	struct annotation *notes = symbol__annotation(sym);
+	struct sym_hist *h = annotation__histogram(notes, evsel->idx);
 	struct disasm_line *pos, *queue = NULL;
 	u64 start = map__rip_2objdump(map, sym->start);
 	int printed = 2, queue_len = 0;
@@ -1544,8 +1545,8 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
 	if (perf_evsel__is_group_event(evsel))
 		width *= evsel->nr_members;
 
-	graph_dotted_len = printf(" %-*.*s|	Source code & Disassembly of %s for %s\n",
-	       width, width, "Percent", d_filename, evsel_name);
+	graph_dotted_len = printf(" %-*.*s|	Source code & Disassembly of %s for %s (%" PRIu64 " samples)\n",
+	       width, width, "Percent", d_filename, evsel_name, h->sum);
 
 	printf("%-*.*s----\n",
 	       graph_dotted_len, graph_dotted_len, graph_dotted_line);

[toc] | [prev] | [next] | [standalone]


#1435053 — [tip:perf/core] perf annotate: Simplify header dotted line sizing

From"tip-bot for Peter Zijlstra (Intel)" <tipbot@zytor.com>
Date2016-07-01 08:50 +0200
Subject[tip:perf/core] perf annotate: Simplify header dotted line sizing
Message-ID<rQ0r0-3gE-17@gated-at.bofh.it>
In reply to#1434369
Commit-ID:  53dd9b5f95dda95bcadda1b4680be42dfe1f9e5e
Gitweb:     http://git.kernel.org/tip/53dd9b5f95dda95bcadda1b4680be42dfe1f9e5e
Author:     Peter Zijlstra (Intel) <peterz@infradead.org>
AuthorDate: Thu, 30 Jun 2016 09:17:26 -0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 30 Jun 2016 09:21:03 -0300

perf annotate: Simplify header dotted line sizing

No need to use strlen, etc to figure that out, just use the return from
printf(), it will tell how wide the following line needs to be.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20160630082955.GA30921@twins.programming.kicks-ass.net
[ split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/annotate.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index c385fec..78e5d6f 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1528,7 +1528,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
 	int more = 0;
 	u64 len;
 	int width = 8;
-	int namelen, evsel_name_len, graph_dotted_len;
+	int graph_dotted_len;
 
 	filename = strdup(dso->long_name);
 	if (!filename)
@@ -1540,17 +1540,14 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
 		d_filename = basename(filename);
 
 	len = symbol__size(sym);
-	namelen = strlen(d_filename);
-	evsel_name_len = strlen(evsel_name);
 
 	if (perf_evsel__is_group_event(evsel))
 		width *= evsel->nr_members;
 
-	printf(" %-*.*s|	Source code & Disassembly of %s for %s\n",
+	graph_dotted_len = printf(" %-*.*s|	Source code & Disassembly of %s for %s\n",
 	       width, width, "Percent", d_filename, evsel_name);
 
-	graph_dotted_len = width + namelen + evsel_name_len;
-	printf("-%-*.*s-----------------------------------------\n",
+	printf("%-*.*s----\n",
 	       graph_dotted_len, graph_dotted_len, graph_dotted_line);
 
 	if (verbose)

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web