[tip:perf/urgent] perf tools: Add a "dso_size" sort order

2018-04-03 Thread tip-bot for Kim Phillips
Commit-ID:  b74d12d598143c2dd30b9cb9636a50dded4cc49f
Gitweb: https://git.kernel.org/tip/b74d12d598143c2dd30b9cb9636a50dded4cc49f
Author: Kim Phillips 
AuthorDate: Tue, 27 Mar 2018 06:09:56 -0500
Committer:  Arnaldo Carvalho de Melo 
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  432600724129587295%
  libglib-2.0.so.0.5400.11125680 111820899%
  libc-2.26.so   1960656 1925120101%
  libdbus-1.so.3.14.13309456  303104102%

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
  
 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%
 398  libmozjs-17.0.so   0.00%
 4218880  libperl.so.5.26.1  0.18%
 4452352  libpython2.7.so.1.00.02%
 4472832  perf   0.02%
 4603904  git0.01%
 4751360  libcrypto.so.1.1.0g0.00%
 5005312  libslang.so.2.3.1  0.00%
 7315456  libgtk-3.so.0.2200.26  0.09%
 8818688  i965_dri.so2.46%
 8818688  i965_dri.so (deleted)  1.26%
12414976  libmozjs-52.so.0.0.0   0.03%
23642112  cc12.02%
27889664  [kernel.kallsyms] 25.41%
80834560  libxul.so (deleted)   15.68%
98078720  chrome32.03%
  1056964608  [kernel.kallsyms]  1.59%
  #

Signed-off-by: Kim Phillips 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Alexander Shishkin 
Cc: Andi Kleen 
Cc: Jin Yao 
Cc: Jiri Olsa 
Cc: Maxim Kuvyrkov 
Cc: Milian Wolff 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/20180327060956.1c01ebe67a2a941bb4468...@arm.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 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//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 

[tip:perf/urgent] perf tools: Add a "dso_size" sort order

2018-04-03 Thread tip-bot for Kim Phillips
Commit-ID:  b74d12d598143c2dd30b9cb9636a50dded4cc49f
Gitweb: https://git.kernel.org/tip/b74d12d598143c2dd30b9cb9636a50dded4cc49f
Author: Kim Phillips 
AuthorDate: Tue, 27 Mar 2018 06:09:56 -0500
Committer:  Arnaldo Carvalho de Melo 
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  432600724129587295%
  libglib-2.0.so.0.5400.11125680 111820899%
  libc-2.26.so   1960656 1925120101%
  libdbus-1.so.3.14.13309456  303104102%

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
  
 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%
 398  libmozjs-17.0.so   0.00%
 4218880  libperl.so.5.26.1  0.18%
 4452352  libpython2.7.so.1.00.02%
 4472832  perf   0.02%
 4603904  git0.01%
 4751360  libcrypto.so.1.1.0g0.00%
 5005312  libslang.so.2.3.1  0.00%
 7315456  libgtk-3.so.0.2200.26  0.09%
 8818688  i965_dri.so2.46%
 8818688  i965_dri.so (deleted)  1.26%
12414976  libmozjs-52.so.0.0.0   0.03%
23642112  cc12.02%
27889664  [kernel.kallsyms] 25.41%
80834560  libxul.so (deleted)   15.68%
98078720  chrome32.03%
  1056964608  [kernel.kallsyms]  1.59%
  #

Signed-off-by: Kim Phillips 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Alexander Shishkin 
Cc: Andi Kleen 
Cc: Jin Yao 
Cc: Jiri Olsa 
Cc: Maxim Kuvyrkov 
Cc: Milian Wolff 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/20180327060956.1c01ebe67a2a941bb4468...@arm.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 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//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;