diff options
author | Kim Phillips <kim.phillips@arm.com> | 2018-03-27 07:09:56 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-04-02 06:57:37 -0400 |
commit | b74d12d598143c2dd30b9cb9636a50dded4cc49f (patch) | |
tree | b61aee49c86ab66d433ef91b0b4c427bdf91b53c | |
parent | 1159e09476536250c2a0173d4298d15114df7a89 (diff) |
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>
-rw-r--r-- | tools/perf/Documentation/perf-report.txt | 1 | ||||
-rw-r--r-- | tools/perf/util/hist.h | 1 | ||||
-rw-r--r-- | tools/perf/util/map.h | 4 | ||||
-rw-r--r-- | tools/perf/util/sort.c | 41 | ||||
-rw-r--r-- | tools/perf/util/sort.h | 1 |
5 files changed, 48 insertions, 0 deletions
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 | |||
80 | - comm: command (name) of the task which can be read via /proc/<pid>/comm | 80 | - comm: command (name) of the task which can be read via /proc/<pid>/comm |
81 | - pid: command and tid of the task | 81 | - pid: command and tid of the task |
82 | - dso: name of library or module executed at the time of sample | 82 | - dso: name of library or module executed at the time of sample |
83 | - dso_size: size of library or module executed at the time of sample | ||
83 | - symbol: name of function executed at the time of sample | 84 | - symbol: name of function executed at the time of sample |
84 | - symbol_size: size of function executed at the time of sample | 85 | - symbol_size: size of function executed at the time of sample |
85 | - parent: name of function matched to the parent regex filter. Unmatched | 86 | - 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 { | |||
61 | HISTC_SRCLINE_TO, | 61 | HISTC_SRCLINE_TO, |
62 | HISTC_TRACE, | 62 | HISTC_TRACE, |
63 | HISTC_SYM_SIZE, | 63 | HISTC_SYM_SIZE, |
64 | HISTC_DSO_SIZE, | ||
64 | HISTC_NR_COLS, /* Last entry */ | 65 | HISTC_NR_COLS, /* Last entry */ |
65 | }; | 66 | }; |
66 | 67 | ||
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) | |||
103 | return ip; | 103 | return ip; |
104 | } | 104 | } |
105 | 105 | ||
106 | static inline size_t map__size(const struct map *map) | ||
107 | { | ||
108 | return map->end - map->start; | ||
109 | } | ||
106 | 110 | ||
107 | /* rip/ip <-> addr suitable for passing to `objdump --start-address=` */ | 111 | /* rip/ip <-> addr suitable for passing to `objdump --start-address=` */ |
108 | u64 map__rip_2objdump(struct map *map, u64 rip); | 112 | 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 = { | |||
1545 | .se_width_idx = HISTC_SYM_SIZE, | 1545 | .se_width_idx = HISTC_SYM_SIZE, |
1546 | }; | 1546 | }; |
1547 | 1547 | ||
1548 | /* --sort dso_size */ | ||
1549 | |||
1550 | static int64_t _sort__dso_size_cmp(struct map *map_l, struct map *map_r) | ||
1551 | { | ||
1552 | int64_t size_l = map_l != NULL ? map__size(map_l) : 0; | ||
1553 | int64_t size_r = map_r != NULL ? map__size(map_r) : 0; | ||
1554 | |||
1555 | return size_l < size_r ? -1 : | ||
1556 | size_l == size_r ? 0 : 1; | ||
1557 | } | ||
1558 | |||
1559 | static int64_t | ||
1560 | sort__dso_size_cmp(struct hist_entry *left, struct hist_entry *right) | ||
1561 | { | ||
1562 | return _sort__dso_size_cmp(right->ms.map, left->ms.map); | ||
1563 | } | ||
1564 | |||
1565 | static int _hist_entry__dso_size_snprintf(struct map *map, char *bf, | ||
1566 | size_t bf_size, unsigned int width) | ||
1567 | { | ||
1568 | if (map && map->dso) | ||
1569 | return repsep_snprintf(bf, bf_size, "%*d", width, | ||
1570 | map__size(map)); | ||
1571 | |||
1572 | return repsep_snprintf(bf, bf_size, "%*s", width, "unknown"); | ||
1573 | } | ||
1574 | |||
1575 | static int hist_entry__dso_size_snprintf(struct hist_entry *he, char *bf, | ||
1576 | size_t size, unsigned int width) | ||
1577 | { | ||
1578 | return _hist_entry__dso_size_snprintf(he->ms.map, bf, size, width); | ||
1579 | } | ||
1580 | |||
1581 | struct sort_entry sort_dso_size = { | ||
1582 | .se_header = "DSO size", | ||
1583 | .se_cmp = sort__dso_size_cmp, | ||
1584 | .se_snprintf = hist_entry__dso_size_snprintf, | ||
1585 | .se_width_idx = HISTC_DSO_SIZE, | ||
1586 | }; | ||
1587 | |||
1548 | 1588 | ||
1549 | struct sort_dimension { | 1589 | struct sort_dimension { |
1550 | const char *name; | 1590 | const char *name; |
@@ -1569,6 +1609,7 @@ static struct sort_dimension common_sort_dimensions[] = { | |||
1569 | DIM(SORT_TRANSACTION, "transaction", sort_transaction), | 1609 | DIM(SORT_TRANSACTION, "transaction", sort_transaction), |
1570 | DIM(SORT_TRACE, "trace", sort_trace), | 1610 | DIM(SORT_TRACE, "trace", sort_trace), |
1571 | DIM(SORT_SYM_SIZE, "symbol_size", sort_sym_size), | 1611 | DIM(SORT_SYM_SIZE, "symbol_size", sort_sym_size), |
1612 | DIM(SORT_DSO_SIZE, "dso_size", sort_dso_size), | ||
1572 | DIM(SORT_CGROUP_ID, "cgroup_id", sort_cgroup_id), | 1613 | DIM(SORT_CGROUP_ID, "cgroup_id", sort_cgroup_id), |
1573 | }; | 1614 | }; |
1574 | 1615 | ||
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 { | |||
220 | SORT_TRANSACTION, | 220 | SORT_TRANSACTION, |
221 | SORT_TRACE, | 221 | SORT_TRACE, |
222 | SORT_SYM_SIZE, | 222 | SORT_SYM_SIZE, |
223 | SORT_DSO_SIZE, | ||
223 | SORT_CGROUP_ID, | 224 | SORT_CGROUP_ID, |
224 | 225 | ||
225 | /* branch stack specific sort keys */ | 226 | /* branch stack specific sort keys */ |