All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf report: Add raw displaying of per-thread counters
@ 2009-08-10 13:26 Brice Goglin
  2009-08-10 13:51 ` [tip:perfcounters/core] " tip-bot for Brice Goglin
  0 siblings, 1 reply; 3+ messages in thread
From: Brice Goglin @ 2009-08-10 13:26 UTC (permalink / raw)
  To: Ingo Molnar, LKML

If --pretty=raw is given to perf report -T, it now displays
one line per-thread per-counter with the raw event id added.
    
We get:
#   PID    TID              Name  Raw    Count
  18608  18609      cache-misses  28e   416744
  18608  18609  cache-references  28f  6456792
  18608  18608      cache-misses  28e   448219
  18608  18608  cache-references  28f  7270244
instead of:
#   PID    TID  cache-misses  cache-references
  18608  18609        416744           6456792
  18608  18608        448219           7270244
    
Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 4163918..2357c66 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -57,6 +57,9 @@ static int		show_nr_samples;
 static int		show_threads;
 static struct perf_read_values	show_threads_values;
 
+static char		default_pretty_printing_style[] = "normal";
+static char		*pretty_printing_style = default_pretty_printing_style;
+
 static unsigned long	page_size;
 static unsigned long	mmap_window = 32;
 
@@ -1401,6 +1404,9 @@ static size_t output__fprintf(FILE *fp, u64 total_samples)
 	size_t ret = 0;
 	unsigned int width;
 	char *col_width = col_width_list_str;
+	int raw_printing_style;
+
+	raw_printing_style = !strcmp(pretty_printing_style, "raw");
 
 	init_rem_hits();
 
@@ -1478,7 +1484,8 @@ print_entries:
 	free(rem_sq_bracket);
 
 	if (show_threads)
-		perf_read_values_display(fp, &show_threads_values);
+		perf_read_values_display(fp, &show_threads_values,
+					 raw_printing_style);
 
 	return ret;
 }
@@ -2091,6 +2098,8 @@ static const struct option options[] = {
 		    "Show a column with the number of samples"),
 	OPT_BOOLEAN('T', "threads", &show_threads,
 		    "Show per-thread event counters"),
+	OPT_STRING(0, "pretty", &pretty_printing_style, "key",
+		   "pretty printing style key: normal raw"),
 	OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
 		   "sort by key(s): pid, comm, dso, symbol, parent"),
 	OPT_BOOLEAN('P', "full-paths", &full_paths,
diff --git a/tools/perf/util/values.c b/tools/perf/util/values.c
index 8551c0b..614cfaf 100644
--- a/tools/perf/util/values.c
+++ b/tools/perf/util/values.c
@@ -126,7 +126,8 @@ void perf_read_values_add_value(struct perf_read_values *values,
 	values->value[tindex][cindex] = value;
 }
 
-void perf_read_values_display(FILE *fp, struct perf_read_values *values)
+static void perf_read_values__display_pretty(FILE *fp,
+					     struct perf_read_values *values)
 {
 	int i, j;
 	int pidwidth, tidwidth;
@@ -169,3 +170,62 @@ void perf_read_values_display(FILE *fp, struct perf_read_values *values)
 		fprintf(fp, "\n");
 	}
 }
+
+static void perf_read_values__display_raw(FILE *fp,
+					  struct perf_read_values *values)
+{
+	int width, pidwidth, tidwidth, namewidth, rawwidth, countwidth;
+	int i, j;
+
+	tidwidth = 3; /* TID */
+	pidwidth = 3; /* PID */
+	namewidth = 4; /* "Name" */
+	rawwidth = 3; /* "Raw" */
+	countwidth = 5; /* "Count" */
+
+	for (i = 0; i < values->threads; i++) {
+		width = snprintf(NULL, 0, "%d", values->pid[i]);
+		if (width > pidwidth)
+			pidwidth = width;
+		width = snprintf(NULL, 0, "%d", values->tid[i]);
+		if (width > tidwidth)
+			tidwidth = width;
+	}
+	for (j = 0; j < values->counters; j++) {
+		width = strlen(values->countername[j]);
+		if (width > namewidth)
+			namewidth = width;
+		width = snprintf(NULL, 0, "%llx", values->counterrawid[j]);
+		if (width > rawwidth)
+			rawwidth = width;
+	}
+	for (i = 0; i < values->threads; i++) {
+		for (j = 0; j < values->counters; j++) {
+			width = snprintf(NULL, 0, "%Lu", values->value[i][j]);
+			if (width > countwidth)
+				countwidth = width;
+		}
+	}
+
+	fprintf(fp, "# %*s  %*s  %*s  %*s  %*s\n",
+		pidwidth, "PID", tidwidth, "TID",
+		namewidth, "Name", rawwidth, "Raw",
+		countwidth, "Count");
+	for (i = 0; i < values->threads; i++)
+		for (j = 0; j < values->counters; j++)
+			fprintf(fp, "  %*d  %*d  %*s  %*llx  %*Lu\n",
+				pidwidth, values->pid[i],
+				tidwidth, values->tid[i],
+				namewidth, values->countername[j],
+				rawwidth, values->counterrawid[j],
+				countwidth, values->value[i][j]);
+}
+
+void perf_read_values_display(FILE *fp, struct perf_read_values *values,
+			      int raw)
+{
+	if (raw)
+		perf_read_values__display_raw(fp, values);
+	else
+		perf_read_values__display_pretty(fp, values);
+}
diff --git a/tools/perf/util/values.h b/tools/perf/util/values.h
index e41be5e..f8960fd 100644
--- a/tools/perf/util/values.h
+++ b/tools/perf/util/values.h
@@ -21,6 +21,7 @@ void perf_read_values_add_value(struct perf_read_values *values,
 				u32 pid, u32 tid,
 				u64 rawid, char *name, u64 value);
 
-void perf_read_values_display(FILE *fp, struct perf_read_values *values);
+void perf_read_values_display(FILE *fp, struct perf_read_values *values,
+			      int raw);
 
 #endif /* _PERF_VALUES_H */



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

* [tip:perfcounters/core] perf report: Add raw displaying of per-thread counters
  2009-08-10 13:26 [PATCH] perf report: Add raw displaying of per-thread counters Brice Goglin
@ 2009-08-10 13:51 ` tip-bot for Brice Goglin
  2009-08-10 14:05   ` Ingo Molnar
  0 siblings, 1 reply; 3+ messages in thread
From: tip-bot for Brice Goglin @ 2009-08-10 13:51 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, Brice.Goglin, hpa, mingo, peterz, tglx, mingo

Commit-ID:  9f8666971185b86615a074bcac67c90fdf8af8bc
Gitweb:     http://git.kernel.org/tip/9f8666971185b86615a074bcac67c90fdf8af8bc
Author:     Brice Goglin <Brice.Goglin@inria.fr>
AuthorDate: Mon, 10 Aug 2009 15:26:32 +0200
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Mon, 10 Aug 2009 15:48:17 +0200

perf report: Add raw displaying of per-thread counters

If --pretty=raw is given to perf report -T, it now displays one
line per-thread per-counter with the raw event id added.

We get:
 #   PID    TID              Name  Raw    Count
   18608  18609      cache-misses  28e   416744
   18608  18609  cache-references  28f  6456792
   18608  18608      cache-misses  28e   448219
   18608  18608  cache-references  28f  7270244
 instead of:

#   PID    TID  cache-misses  cache-references
   18608  18609        416744           6456792
   18608  18608        448219           7270244

Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
Acked-by: Peter Zijlstra <peterz@infradead.org>
LKML-Reference: <4A802008.5050409@inria.fr>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 tools/perf/builtin-report.c |   11 +++++++-
 tools/perf/util/values.c    |   62 ++++++++++++++++++++++++++++++++++++++++++-
 tools/perf/util/values.h    |    3 +-
 3 files changed, 73 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 4163918..2357c66 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -57,6 +57,9 @@ static int		show_nr_samples;
 static int		show_threads;
 static struct perf_read_values	show_threads_values;
 
+static char		default_pretty_printing_style[] = "normal";
+static char		*pretty_printing_style = default_pretty_printing_style;
+
 static unsigned long	page_size;
 static unsigned long	mmap_window = 32;
 
@@ -1401,6 +1404,9 @@ static size_t output__fprintf(FILE *fp, u64 total_samples)
 	size_t ret = 0;
 	unsigned int width;
 	char *col_width = col_width_list_str;
+	int raw_printing_style;
+
+	raw_printing_style = !strcmp(pretty_printing_style, "raw");
 
 	init_rem_hits();
 
@@ -1478,7 +1484,8 @@ print_entries:
 	free(rem_sq_bracket);
 
 	if (show_threads)
-		perf_read_values_display(fp, &show_threads_values);
+		perf_read_values_display(fp, &show_threads_values,
+					 raw_printing_style);
 
 	return ret;
 }
@@ -2091,6 +2098,8 @@ static const struct option options[] = {
 		    "Show a column with the number of samples"),
 	OPT_BOOLEAN('T', "threads", &show_threads,
 		    "Show per-thread event counters"),
+	OPT_STRING(0, "pretty", &pretty_printing_style, "key",
+		   "pretty printing style key: normal raw"),
 	OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
 		   "sort by key(s): pid, comm, dso, symbol, parent"),
 	OPT_BOOLEAN('P', "full-paths", &full_paths,
diff --git a/tools/perf/util/values.c b/tools/perf/util/values.c
index 8551c0b..614cfaf 100644
--- a/tools/perf/util/values.c
+++ b/tools/perf/util/values.c
@@ -126,7 +126,8 @@ void perf_read_values_add_value(struct perf_read_values *values,
 	values->value[tindex][cindex] = value;
 }
 
-void perf_read_values_display(FILE *fp, struct perf_read_values *values)
+static void perf_read_values__display_pretty(FILE *fp,
+					     struct perf_read_values *values)
 {
 	int i, j;
 	int pidwidth, tidwidth;
@@ -169,3 +170,62 @@ void perf_read_values_display(FILE *fp, struct perf_read_values *values)
 		fprintf(fp, "\n");
 	}
 }
+
+static void perf_read_values__display_raw(FILE *fp,
+					  struct perf_read_values *values)
+{
+	int width, pidwidth, tidwidth, namewidth, rawwidth, countwidth;
+	int i, j;
+
+	tidwidth = 3; /* TID */
+	pidwidth = 3; /* PID */
+	namewidth = 4; /* "Name" */
+	rawwidth = 3; /* "Raw" */
+	countwidth = 5; /* "Count" */
+
+	for (i = 0; i < values->threads; i++) {
+		width = snprintf(NULL, 0, "%d", values->pid[i]);
+		if (width > pidwidth)
+			pidwidth = width;
+		width = snprintf(NULL, 0, "%d", values->tid[i]);
+		if (width > tidwidth)
+			tidwidth = width;
+	}
+	for (j = 0; j < values->counters; j++) {
+		width = strlen(values->countername[j]);
+		if (width > namewidth)
+			namewidth = width;
+		width = snprintf(NULL, 0, "%llx", values->counterrawid[j]);
+		if (width > rawwidth)
+			rawwidth = width;
+	}
+	for (i = 0; i < values->threads; i++) {
+		for (j = 0; j < values->counters; j++) {
+			width = snprintf(NULL, 0, "%Lu", values->value[i][j]);
+			if (width > countwidth)
+				countwidth = width;
+		}
+	}
+
+	fprintf(fp, "# %*s  %*s  %*s  %*s  %*s\n",
+		pidwidth, "PID", tidwidth, "TID",
+		namewidth, "Name", rawwidth, "Raw",
+		countwidth, "Count");
+	for (i = 0; i < values->threads; i++)
+		for (j = 0; j < values->counters; j++)
+			fprintf(fp, "  %*d  %*d  %*s  %*llx  %*Lu\n",
+				pidwidth, values->pid[i],
+				tidwidth, values->tid[i],
+				namewidth, values->countername[j],
+				rawwidth, values->counterrawid[j],
+				countwidth, values->value[i][j]);
+}
+
+void perf_read_values_display(FILE *fp, struct perf_read_values *values,
+			      int raw)
+{
+	if (raw)
+		perf_read_values__display_raw(fp, values);
+	else
+		perf_read_values__display_pretty(fp, values);
+}
diff --git a/tools/perf/util/values.h b/tools/perf/util/values.h
index e41be5e..f8960fd 100644
--- a/tools/perf/util/values.h
+++ b/tools/perf/util/values.h
@@ -21,6 +21,7 @@ void perf_read_values_add_value(struct perf_read_values *values,
 				u32 pid, u32 tid,
 				u64 rawid, char *name, u64 value);
 
-void perf_read_values_display(FILE *fp, struct perf_read_values *values);
+void perf_read_values_display(FILE *fp, struct perf_read_values *values,
+			      int raw);
 
 #endif /* _PERF_VALUES_H */

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

* Re: [tip:perfcounters/core] perf report: Add raw displaying of per-thread counters
  2009-08-10 13:51 ` [tip:perfcounters/core] " tip-bot for Brice Goglin
@ 2009-08-10 14:05   ` Ingo Molnar
  0 siblings, 0 replies; 3+ messages in thread
From: Ingo Molnar @ 2009-08-10 14:05 UTC (permalink / raw)
  To: mingo, hpa, Brice.Goglin, linux-kernel, peterz, tglx; +Cc: linux-tip-commits


* tip-bot for Brice Goglin <Brice.Goglin@inria.fr> wrote:

> Commit-ID:  9f8666971185b86615a074bcac67c90fdf8af8bc
> Gitweb:     http://git.kernel.org/tip/9f8666971185b86615a074bcac67c90fdf8af8bc
> Author:     Brice Goglin <Brice.Goglin@inria.fr>
> AuthorDate: Mon, 10 Aug 2009 15:26:32 +0200
> Committer:  Ingo Molnar <mingo@elte.hu>
> CommitDate: Mon, 10 Aug 2009 15:48:17 +0200
> 
> perf report: Add raw displaying of per-thread counters
> 
> If --pretty=raw is given to perf report -T, it now displays one
> line per-thread per-counter with the raw event id added.
> 
> We get:
>  #   PID    TID              Name  Raw    Count
>    18608  18609      cache-misses  28e   416744
>    18608  18609  cache-references  28f  6456792
>    18608  18608      cache-misses  28e   448219
>    18608  18608  cache-references  28f  7270244

btw., this is the full output we do:

aldebaran:~> perf record -f -n -s ./hackbench 1
aldebaran:~> perf report -T --pretty=raw

# Samples: 0
#
# Overhead    Command  Shared Object  Symbol
# ........  .........  .............  ......
#
#
# (For a higher level overview, try: perf report --sort comm,dso)
#

#   PID    TID    Name  Raw     Count
  17937  17937  cycles   3b  11590867
  17935  17935  cycles   3b  11461700
  17942  17942  cycles   3b  10912077
  17927  17927  cycles   3b  10904967
  17924  17924  cycles   3b  13313815
  17934  17934  cycles   3b  11639158
  17939  17939  cycles   3b  10803818
  17931  17931  cycles   3b  11802979
  17925  17925  cycles   3b  11303473
  17926  17926  cycles   3b  12243882
  17936  17936  cycles   3b   9997099
  17938  17938  cycles   3b  11255911
  17932  17932  cycles   3b  11957781
  17929  17929  cycles   3b  12936176
  17933  17933  cycles   3b  12685907
  17930  17930  cycles   3b  12455278
  17928  17928  cycles   3b  13187215
  17940  17940  cycles   3b  15426327
  17923  17923  cycles   3b  15754461
  17903  17903  cycles   3b  11156016
  17905  17905  cycles   3b   9747782
  17904  17904  cycles   3b   8743904
  17907  17907  cycles   3b  10827088
  17906  17906  cycles   3b  10109984
  17908  17908  cycles   3b  11092446
  17909  17909  cycles   3b   8167235
  17910  17910  cycles   3b  12132769
  17911  17911  cycles   3b   9469716
  17912  17912  cycles   3b   9541507
  17914  17914  cycles   3b   8612516
  17913  17913  cycles   3b   9805519
  17915  17915  cycles   3b  10021933
  17916  17916  cycles   3b  10763787
  17917  17917  cycles   3b  10519547
  17918  17918  cycles   3b   9749113
  17919  17919  cycles   3b  10582943
  17921  17921  cycles   3b   8717079
  17920  17920  cycles   3b   9113000
  17922  17922  cycles   3b  12102473
  17941  17941  cycles   3b  15668897
  17902  17902  cycles   3b   9148959

I think we should supress the header portion, as it's highly 
confusing in this case when we dont sample RIPs but only counts, 
right?

	Ingo

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

end of thread, other threads:[~2009-08-10 14:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-10 13:26 [PATCH] perf report: Add raw displaying of per-thread counters Brice Goglin
2009-08-10 13:51 ` [tip:perfcounters/core] " tip-bot for Brice Goglin
2009-08-10 14:05   ` Ingo Molnar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.