All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf tools: Add a dso_size option to perf report --sort
@ 2018-03-27 11:09 Kim Phillips
  2018-03-27 11:27 ` Andi Kleen
  2018-04-04  5:28 ` [tip:perf/urgent] perf tools: Add a "dso_size" sort order tip-bot for Kim Phillips
  0 siblings, 2 replies; 6+ messages in thread
From: Kim Phillips @ 2018-03-27 11:09 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, linux-kernel, linux-perf-users
  Cc: Maxim Kuvyrkov, Peter Zijlstra, Ingo Molnar, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Jin Yao, Milian Wolff, Andi Kleen

Add DSO size to perf report/top sort output list.

This includes adding a map__size fn to map.h, which is
approximately equal to the DSO data file_size:

DSO				file size	map (end-start)	file / (end-start)
libwebkit2gtk-4.0.so.37.24.9	43260072	41295872	95%
libglib-2.0.so.0.5400.1		 1125680	 1118208	99%
libc-2.26.so			 1960656 	 1925120	101%
libdbus-1.so.3.14.13		  309456 	  303104	102%

Sample output:

$ ./perf report -s dso_size,dso
Samples: 2K of event 'cycles:uppp', Event count (approx.): 128373340
Overhead  DSO size  Shared Object
  90.62%   unknown  [unknown]
   2.87%   1118208  libglib-2.0.so.0.5400.1
   1.92%    303104  libdbus-1.so.3.14.13
   1.42%   1925120  libc-2.26.so
   0.77%  41295872  libwebkit2gtk-4.0.so.37.24.9
   0.61%    335872  libgobject-2.0.so.0.5400.1
   0.41%   1052672  libgdk-3.so.0.2200.25
   0.36%    106496  libpthread-2.26.so
   0.29%    221184  dbus-daemon
   0.17%    159744  ld-2.26.so
   0.13%     49152  libwayland-client.so.0.3.0
   0.12%   1642496  libgio-2.0.so.0.5400.1
   0.09%   7327744  libgtk-3.so.0.2200.25
   0.09%  12324864  libmozjs-52.so.0.0.0
   0.05%   4796416  perf
   0.04%    843776  libgjs.so.0.0.0
   0.03%   1409024  libmutter-clutter-1.so

Cc: Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>
Signed-off-by: Kim Phillips <kim.phillips@arm.com>
---
 tools/perf/Documentation/perf-report.txt |  1 +
 tools/perf/util/hist.h                   |  1 +
 tools/perf/util/map.h                    |  4 ++++
 tools/perf/util/sort.c                   | 41 ++++++++++++++++++++++++++++++++
 tools/perf/util/sort.h                   |  1 +
 5 files changed, 48 insertions(+)

diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index e1a660e60849..917e36fde6d8 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -80,6 +80,7 @@ OPTIONS
 	- comm: command (name) of the task which can be read via /proc/<pid>/comm
 	- pid: command and tid of the task
 	- dso: name of library or module executed at the time of sample
+	- dso_size: size of library or module executed at the time of sample
 	- symbol: name of function executed at the time of sample
 	- symbol_size: size of function executed at the time of sample
 	- parent: name of function matched to the parent regex filter. Unmatched
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index e869cad4d89f..32fbf26e0c18 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -61,6 +61,7 @@ enum hist_column {
 	HISTC_SRCLINE_TO,
 	HISTC_TRACE,
 	HISTC_SYM_SIZE,
+	HISTC_DSO_SIZE,
 	HISTC_NR_COLS, /* Last entry */
 };
 
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index edeb7291c8e1..0e9bbe01b0ab 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -103,6 +103,10 @@ static inline u64 identity__map_ip(struct map *map __maybe_unused, u64 ip)
 	return ip;
 }
 
+static inline size_t map__size(const struct map *map)
+{
+	return map->end - map->start;
+}
 
 /* rip/ip <-> addr suitable for passing to `objdump --start-address=` */
 u64 map__rip_2objdump(struct map *map, u64 rip);
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index e8514f651865..26a68dfd8a4f 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1545,6 +1545,46 @@ struct sort_entry sort_sym_size = {
 	.se_width_idx	= HISTC_SYM_SIZE,
 };
 
+/* --sort dso_size */
+
+static int64_t _sort__dso_size_cmp(struct map *map_l, struct map *map_r)
+{
+	int64_t size_l = map_l != NULL ? map__size(map_l) : 0;
+	int64_t size_r = map_r != NULL ? map__size(map_r) : 0;
+
+	return size_l < size_r ? -1 :
+		size_l == size_r ? 0 : 1;
+}
+
+static int64_t
+sort__dso_size_cmp(struct hist_entry *left, struct hist_entry *right)
+{
+	return _sort__dso_size_cmp(right->ms.map, left->ms.map);
+}
+
+static int _hist_entry__dso_size_snprintf(struct map *map, char *bf,
+					  size_t bf_size, unsigned int width)
+{
+	if (map && map->dso)
+		return repsep_snprintf(bf, bf_size, "%*d", width,
+				       map__size(map));
+
+	return repsep_snprintf(bf, bf_size, "%*s", width, "unknown");
+}
+
+static int hist_entry__dso_size_snprintf(struct hist_entry *he, char *bf,
+					 size_t size, unsigned int width)
+{
+	return _hist_entry__dso_size_snprintf(he->ms.map, bf, size, width);
+}
+
+struct sort_entry sort_dso_size = {
+	.se_header	= "DSO size",
+	.se_cmp		= sort__dso_size_cmp,
+	.se_snprintf	= hist_entry__dso_size_snprintf,
+	.se_width_idx	= HISTC_DSO_SIZE,
+};
+
 
 struct sort_dimension {
 	const char		*name;
@@ -1569,6 +1609,7 @@ static struct sort_dimension common_sort_dimensions[] = {
 	DIM(SORT_TRANSACTION, "transaction", sort_transaction),
 	DIM(SORT_TRACE, "trace", sort_trace),
 	DIM(SORT_SYM_SIZE, "symbol_size", sort_sym_size),
+	DIM(SORT_DSO_SIZE, "dso_size", sort_dso_size),
 	DIM(SORT_CGROUP_ID, "cgroup_id", sort_cgroup_id),
 };
 
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index f5901c10a563..035b62e2c60b 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -220,6 +220,7 @@ enum sort_type {
 	SORT_TRANSACTION,
 	SORT_TRACE,
 	SORT_SYM_SIZE,
+	SORT_DSO_SIZE,
 	SORT_CGROUP_ID,
 
 	/* branch stack specific sort keys */
-- 
2.16.2

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

* Re: [PATCH] perf tools: Add a dso_size option to perf report --sort
  2018-03-27 11:09 [PATCH] perf tools: Add a dso_size option to perf report --sort Kim Phillips
@ 2018-03-27 11:27 ` Andi Kleen
  2018-03-27 14:05     ` Kim Phillips
  2018-04-04  5:28 ` [tip:perf/urgent] perf tools: Add a "dso_size" sort order tip-bot for Kim Phillips
  1 sibling, 1 reply; 6+ messages in thread
From: Andi Kleen @ 2018-03-27 11:27 UTC (permalink / raw)
  To: Kim Phillips
  Cc: Arnaldo Carvalho de Melo, linux-kernel, linux-perf-users,
	Maxim Kuvyrkov, Peter Zijlstra, Ingo Molnar, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Jin Yao, Milian Wolff

On Tue, Mar 27, 2018 at 06:09:56AM -0500, Kim Phillips wrote:
> Add DSO size to perf report/top sort output list.
> 
> This includes adding a map__size fn to map.h, which is
> approximately equal to the DSO data file_size:

What's the point of knowing the size?  

Most of the DSO may not be faulted in. If anything the working
set would be more interesting. This would need more changes
though.

-Andi

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

* Re: [PATCH] perf tools: Add a dso_size option to perf report --sort
  2018-03-27 11:27 ` Andi Kleen
@ 2018-03-27 14:05     ` Kim Phillips
  0 siblings, 0 replies; 6+ messages in thread
From: Kim Phillips @ 2018-03-27 14:05 UTC (permalink / raw)
  To: Andi Kleen, Maxim Kuvyrkov
  Cc: Arnaldo Carvalho de Melo, linux-kernel, linux-perf-users,
	Peter Zijlstra, Ingo Molnar, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, Jin Yao, Milian Wolff

On Tue, 27 Mar 2018 04:27:02 -0700
Andi Kleen <ak@linux.intel.com> wrote:

> On Tue, Mar 27, 2018 at 06:09:56AM -0500, Kim Phillips wrote:
> > Add DSO size to perf report/top sort output list.
> > 
> > This includes adding a map__size fn to map.h, which is
> > approximately equal to the DSO data file_size:
> 
> What's the point of knowing the size?  

I think it's just an extra convenience over symbol_size (added in
commit 7768f8dada66d6  "perf tools: Allow sorting by symbol size") for
tools developers' aggregation statistics.

> Most of the DSO may not be faulted in. If anything the working
> set would be more interesting. This would need more changes
> though.

Indeed.  Maxim?

Kim

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

* Re: [PATCH] perf tools: Add a dso_size option to perf report --sort
@ 2018-03-27 14:05     ` Kim Phillips
  0 siblings, 0 replies; 6+ messages in thread
From: Kim Phillips @ 2018-03-27 14:05 UTC (permalink / raw)
  To: Andi Kleen, Maxim Kuvyrkov
  Cc: Arnaldo Carvalho de Melo, linux-kernel, linux-perf-users,
	Peter Zijlstra, Ingo Molnar, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, Jin Yao, Milian Wolff

On Tue, 27 Mar 2018 04:27:02 -0700
Andi Kleen <ak@linux.intel.com> wrote:

> On Tue, Mar 27, 2018 at 06:09:56AM -0500, Kim Phillips wrote:
> > Add DSO size to perf report/top sort output list.
> > 
> > This includes adding a map__size fn to map.h, which is
> > approximately equal to the DSO data file_size:
> 
> What's the point of knowing the size?  

I think it's just an extra convenience over symbol_size (added in
commit 7768f8dada66d6  "perf tools: Allow sorting by symbol size") for
tools developers' aggregation statistics.

> Most of the DSO may not be faulted in. If anything the working
> set would be more interesting. This would need more changes
> though.

Indeed.  Maxim?

Kim

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

* Re: [PATCH] perf tools: Add a dso_size option to perf report --sort
  2018-03-27 14:05     ` Kim Phillips
  (?)
@ 2018-03-27 15:45     ` Arnaldo Carvalho de Melo
  -1 siblings, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-03-27 15:45 UTC (permalink / raw)
  To: Kim Phillips
  Cc: Andi Kleen, Maxim Kuvyrkov, linux-kernel, linux-perf-users,
	Peter Zijlstra, Ingo Molnar, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, Jin Yao, Milian Wolff

Em Tue, Mar 27, 2018 at 09:05:07AM -0500, Kim Phillips escreveu:
> On Tue, 27 Mar 2018 04:27:02 -0700
> Andi Kleen <ak@linux.intel.com> wrote:
> 
> > On Tue, Mar 27, 2018 at 06:09:56AM -0500, Kim Phillips wrote:
> > > Add DSO size to perf report/top sort output list.
> > > 
> > > This includes adding a map__size fn to map.h, which is
> > > approximately equal to the DSO data file_size:
> > 
> > What's the point of knowing the size?  
 
> I think it's just an extra convenience over symbol_size (added in
> commit 7768f8dada66d6  "perf tools: Allow sorting by symbol size") for
> tools developers' aggregation statistics.

Yeah, for completeness, may be useful for someone, probably for Maxim?
:-)
 
> > Most of the DSO may not be faulted in. If anything the working
> > set would be more interesting. This would need more changes
> > though.
> 
> Indeed.  Maxim?

Right, that would be another interesting metric to have,

- Arnaldo

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

* [tip:perf/urgent] perf tools: Add a "dso_size" sort order
  2018-03-27 11:09 [PATCH] perf tools: Add a dso_size option to perf report --sort Kim Phillips
  2018-03-27 11:27 ` Andi Kleen
@ 2018-04-04  5:28 ` tip-bot for Kim Phillips
  1 sibling, 0 replies; 6+ messages in thread
From: tip-bot for Kim Phillips @ 2018-04-04  5:28 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, peterz, yao.jin, milian.wolff, namhyung, tglx, kim.phillips,
	mingo, alexander.shishkin, linux-kernel, maxim.kuvyrkov, ak,
	jolsa, acme

Commit-ID:  b74d12d598143c2dd30b9cb9636a50dded4cc49f
Gitweb:     https://git.kernel.org/tip/b74d12d598143c2dd30b9cb9636a50dded4cc49f
Author:     Kim Phillips <kim.phillips@arm.com>
AuthorDate: Tue, 27 Mar 2018 06:09:56 -0500
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 2 Apr 2018 07:57:37 -0300

perf tools: Add a "dso_size" sort order

Add DSO size to perf report/top sort output list.

This includes adding a map__size fn to map.h, which is
approximately equal to the DSO data file_size:

  DSO				file size	map (end-start)	file / (end-start)
  libwebkit2gtk-4.0.so.37.24.9	43260072	41295872	95%
  libglib-2.0.so.0.5400.1		 1125680	 1118208	99%
  libc-2.26.so			 1960656 	 1925120	101%
  libdbus-1.so.3.14.13		  309456 	  303104	102%

Sample output:

  $ ./perf report -s dso_size,dso
  Samples: 2K of event 'cycles:uppp', Event count (approx.): 128373340
  Overhead  DSO size  Shared Object
    90.62%   unknown  [unknown]
     2.87%   1118208  libglib-2.0.so.0.5400.1
     1.92%    303104  libdbus-1.so.3.14.13
     1.42%   1925120  libc-2.26.so
     0.77%  41295872  libwebkit2gtk-4.0.so.37.24.9
     0.61%    335872  libgobject-2.0.so.0.5400.1
     0.41%   1052672  libgdk-3.so.0.2200.25
     0.36%    106496  libpthread-2.26.so
     0.29%    221184  dbus-daemon
     0.17%    159744  ld-2.26.so
     0.13%     49152  libwayland-client.so.0.3.0
     0.12%   1642496  libgio-2.0.so.0.5400.1
     0.09%   7327744  libgtk-3.so.0.2200.25
     0.09%  12324864  libmozjs-52.so.0.0.0
     0.05%   4796416  perf
     0.04%    843776  libgjs.so.0.0.0
     0.03%   1409024  libmutter-clutter-1.so

Committer testing:

To sort by DSO size, use:

  # perf report -F dso_size,dso,overhead -s dso_size
  <SNIP>
     3465216  libdns-export.so.174.0.1   0.00%
     3522560  libgc.so.1.0.3             0.00%
     3538944  libbfd-2.29-13.fc27.so     0.59%
     3670016  libunistring.so.2.1.0      0.00%
     3723264  libguile-2.0.so.22.8.1     0.00%
     3776512  libgio-2.0.so.0.5400.3     0.00%
     3891200  libc-2.26.so               0.96%
     3944448  libmozjs-17.0.so           0.00%
     4218880  libperl.so.5.26.1          0.18%
     4452352  libpython2.7.so.1.0        0.02%
     4472832  perf                       0.02%
     4603904  git                        0.01%
     4751360  libcrypto.so.1.1.0g        0.00%
     5005312  libslang.so.2.3.1          0.00%
     7315456  libgtk-3.so.0.2200.26      0.09%
     8818688  i965_dri.so                2.46%
     8818688  i965_dri.so (deleted)      1.26%
    12414976  libmozjs-52.so.0.0.0       0.03%
    23642112  cc1                        2.02%
    27889664  [kernel.kallsyms]         25.41%
    80834560  libxul.so (deleted)       15.68%
    98078720  chrome                    32.03%
  1056964608  [kernel.kallsyms]          1.59%
  #

Signed-off-by: Kim Phillips <kim.phillips@arm.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>
Cc: Milian Wolff <milian.wolff@kdab.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20180327060956.1c01ebe67a2a941bb4468c6f@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-report.txt |  1 +
 tools/perf/util/hist.h                   |  1 +
 tools/perf/util/map.h                    |  4 ++++
 tools/perf/util/sort.c                   | 41 ++++++++++++++++++++++++++++++++
 tools/perf/util/sort.h                   |  1 +
 5 files changed, 48 insertions(+)

diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index e1a660e60849..917e36fde6d8 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -80,6 +80,7 @@ OPTIONS
 	- comm: command (name) of the task which can be read via /proc/<pid>/comm
 	- pid: command and tid of the task
 	- dso: name of library or module executed at the time of sample
+	- dso_size: size of library or module executed at the time of sample
 	- symbol: name of function executed at the time of sample
 	- symbol_size: size of function executed at the time of sample
 	- parent: name of function matched to the parent regex filter. Unmatched
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index e869cad4d89f..32fbf26e0c18 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -61,6 +61,7 @@ enum hist_column {
 	HISTC_SRCLINE_TO,
 	HISTC_TRACE,
 	HISTC_SYM_SIZE,
+	HISTC_DSO_SIZE,
 	HISTC_NR_COLS, /* Last entry */
 };
 
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index edeb7291c8e1..0e9bbe01b0ab 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -103,6 +103,10 @@ static inline u64 identity__map_ip(struct map *map __maybe_unused, u64 ip)
 	return ip;
 }
 
+static inline size_t map__size(const struct map *map)
+{
+	return map->end - map->start;
+}
 
 /* rip/ip <-> addr suitable for passing to `objdump --start-address=` */
 u64 map__rip_2objdump(struct map *map, u64 rip);
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index e8514f651865..26a68dfd8a4f 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1545,6 +1545,46 @@ struct sort_entry sort_sym_size = {
 	.se_width_idx	= HISTC_SYM_SIZE,
 };
 
+/* --sort dso_size */
+
+static int64_t _sort__dso_size_cmp(struct map *map_l, struct map *map_r)
+{
+	int64_t size_l = map_l != NULL ? map__size(map_l) : 0;
+	int64_t size_r = map_r != NULL ? map__size(map_r) : 0;
+
+	return size_l < size_r ? -1 :
+		size_l == size_r ? 0 : 1;
+}
+
+static int64_t
+sort__dso_size_cmp(struct hist_entry *left, struct hist_entry *right)
+{
+	return _sort__dso_size_cmp(right->ms.map, left->ms.map);
+}
+
+static int _hist_entry__dso_size_snprintf(struct map *map, char *bf,
+					  size_t bf_size, unsigned int width)
+{
+	if (map && map->dso)
+		return repsep_snprintf(bf, bf_size, "%*d", width,
+				       map__size(map));
+
+	return repsep_snprintf(bf, bf_size, "%*s", width, "unknown");
+}
+
+static int hist_entry__dso_size_snprintf(struct hist_entry *he, char *bf,
+					 size_t size, unsigned int width)
+{
+	return _hist_entry__dso_size_snprintf(he->ms.map, bf, size, width);
+}
+
+struct sort_entry sort_dso_size = {
+	.se_header	= "DSO size",
+	.se_cmp		= sort__dso_size_cmp,
+	.se_snprintf	= hist_entry__dso_size_snprintf,
+	.se_width_idx	= HISTC_DSO_SIZE,
+};
+
 
 struct sort_dimension {
 	const char		*name;
@@ -1569,6 +1609,7 @@ static struct sort_dimension common_sort_dimensions[] = {
 	DIM(SORT_TRANSACTION, "transaction", sort_transaction),
 	DIM(SORT_TRACE, "trace", sort_trace),
 	DIM(SORT_SYM_SIZE, "symbol_size", sort_sym_size),
+	DIM(SORT_DSO_SIZE, "dso_size", sort_dso_size),
 	DIM(SORT_CGROUP_ID, "cgroup_id", sort_cgroup_id),
 };
 
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index f5901c10a563..035b62e2c60b 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -220,6 +220,7 @@ enum sort_type {
 	SORT_TRANSACTION,
 	SORT_TRACE,
 	SORT_SYM_SIZE,
+	SORT_DSO_SIZE,
 	SORT_CGROUP_ID,
 
 	/* branch stack specific sort keys */

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

end of thread, other threads:[~2018-04-04  5:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-27 11:09 [PATCH] perf tools: Add a dso_size option to perf report --sort Kim Phillips
2018-03-27 11:27 ` Andi Kleen
2018-03-27 14:05   ` Kim Phillips
2018-03-27 14:05     ` Kim Phillips
2018-03-27 15:45     ` Arnaldo Carvalho de Melo
2018-04-04  5:28 ` [tip:perf/urgent] perf tools: Add a "dso_size" sort order tip-bot for Kim Phillips

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.