File perf-annotate-stdio-support-show-nr-samples-option.patch of Package perf
119
1
From: Taeung Song <treeze.taeung@gmail.com>
2
Date: Fri, 18 Aug 2017 17:46:48 +0900
3
Subject: perf annotate stdio: Support --show-nr-samples option
4
Git-commit: 1ac39372e06f5009982aaaf890fc5bbd044bb047
5
Patch-mainline: v4.14-rc1
6
References: bsc#1070010 (git-fixes - dependency)
7
Signed-off-By: Tony Jones <tonyj@suse.de>
8
9
Add --show-nr-samples option to "perf annotate" so that it matches "perf
10
report".
11
12
Committer note:
13
14
Note that it can't be used together with --show-total-period, which
15
seems like a silly limitation, that can be lifted at some point.
16
17
Made it bail out if not on --stdio.
18
19
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
20
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
21
Cc: Jiri Olsa <jolsa@redhat.com>
22
Cc: Milian Wolff <milian.wolff@kdab.com>
23
Cc: Namhyung Kim <namhyung@kernel.org>
24
Link: http://lkml.kernel.org/r/1503046008-5511-1-git-send-email-treeze.taeung@gmail.com
25
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
26
---
27
tools/perf/Documentation/perf-annotate.txt | 4 ++++
28
tools/perf/builtin-annotate.c | 16 ++++++++++++++--
29
tools/perf/util/annotate.c | 6 +++++-
30
3 files changed, 23 insertions(+), 3 deletions(-)
31
32
diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Documentation/perf-annotate.txt
33
index a89273d8e744..2a5975c91cbd 100644
34
--- a/tools/perf/Documentation/perf-annotate.txt
35
+++ b/tools/perf/Documentation/perf-annotate.txt
36
37
--quiet::
38
Do not show any message. (Suppress -v)
39
40
+-n::
41
+--show-nr-samples::
42
+ Show the number of samples for each symbol
43
+
44
-D::
45
--dump-raw-trace::
46
Dump raw trace in ASCII.
47
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
48
index 658c920d74b9..89fc0389dc76 100644
49
--- a/tools/perf/builtin-annotate.c
50
+++ b/tools/perf/builtin-annotate.c
51
52
struct perf_data_file file = {
53
.mode = PERF_DATA_MODE_READ,
54
};
55
- const struct option options[] = {
56
+ struct option options[] = {
57
OPT_STRING('i', "input", &input_name, "file",
58
"input file name"),
59
OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]",
60
61
"Show event group information together"),
62
OPT_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period,
63
"Show a column with the sum of periods"),
64
+ OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
65
+ "Show a column with the number of samples"),
66
OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
67
"'always' (default), 'never' or 'auto' only applicable to --stdio mode",
68
stdio__config_color, "always"),
69
OPT_END()
70
};
71
- int ret = hists__init();
72
+ int ret;
73
+
74
+ set_option_flag(options, 0, "show-total-period", PARSE_OPT_EXCLUSIVE);
75
+ set_option_flag(options, 0, "show-nr-samples", PARSE_OPT_EXCLUSIVE);
76
+
77
78
+ ret = hists__init();
79
if (ret < 0)
80
return ret;
81
82
83
annotate.sym_hist_filter = argv[0];
84
}
85
86
+ if (symbol_conf.show_nr_samples && !annotate.use_stdio) {
87
+ pr_err("--show-nr-samples is only available in --stdio mode at this time\n");
88
+ return ret;
89
+ }
90
+
91
if (quiet)
92
perf_quiet_option();
93
94
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
95
index 2dab0e5a7f2f..4397a8b6e6cd 100644
96
--- a/tools/perf/util/annotate.c
97
+++ b/tools/perf/util/annotate.c
98
99
if (symbol_conf.show_total_period)
100
color_fprintf(stdout, color, " %11" PRIu64,
101
sample.period);
102
+ else if (symbol_conf.show_nr_samples)
103
+ color_fprintf(stdout, color, " %7" PRIu64,
104
+ sample.nr_samples);
105
else
106
color_fprintf(stdout, color, " %7.2f", percent);
107
}
108
109
width *= evsel->nr_members;
110
111
graph_dotted_len = printf(" %-*.*s| Source code & Disassembly of %s for %s (%" PRIu64 " samples)\n",
112
- width, width, symbol_conf.show_total_period ? "Event count" : "Percent",
113
+ width, width, symbol_conf.show_total_period ? "Period" :
114
+ symbol_conf.show_nr_samples ? "Samples" : "Percent",
115
d_filename, evsel_name, h->nr_samples);
116
117
printf("%-*.*s----\n",
118
119