diff options
author | Jiri Olsa <jolsa@kernel.org> | 2016-06-05 07:40:53 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-10-19 12:18:31 -0400 |
commit | 92062d543f1fb83b9b03ecafdb92f00e1328a992 (patch) | |
tree | 510582d55098ce5af48d410d0ca21caeee99674f /tools/perf/builtin-c2c.c | |
parent | 1e181b92a2da30ba1f80c61a41cfb9ef02f43b79 (diff) |
perf c2c report: Add stats related sort keys
It is to be displayed in the single cacheline output:
median, mean_rmt, mean_lcl, mean_load, stddev
It displays statistics hits related to cacheline accesses.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-m1r4uc9lcykf1jhpvwk2gkj8@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-c2c.c')
-rw-r--r-- | tools/perf/builtin-c2c.c | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index ca2f37479e6d..043344a720bf 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c | |||
@@ -20,11 +20,20 @@ struct c2c_hists { | |||
20 | struct c2c_stats stats; | 20 | struct c2c_stats stats; |
21 | }; | 21 | }; |
22 | 22 | ||
23 | struct compute_stats { | ||
24 | struct stats lcl_hitm; | ||
25 | struct stats rmt_hitm; | ||
26 | struct stats load; | ||
27 | }; | ||
28 | |||
23 | struct c2c_hist_entry { | 29 | struct c2c_hist_entry { |
24 | struct c2c_hists *hists; | 30 | struct c2c_hists *hists; |
25 | struct c2c_stats stats; | 31 | struct c2c_stats stats; |
26 | unsigned long *cpuset; | 32 | unsigned long *cpuset; |
27 | struct c2c_stats *node_stats; | 33 | struct c2c_stats *node_stats; |
34 | |||
35 | struct compute_stats cstats; | ||
36 | |||
28 | /* | 37 | /* |
29 | * must be at the end, | 38 | * must be at the end, |
30 | * because of its callchain dynamic entry | 39 | * because of its callchain dynamic entry |
@@ -61,6 +70,10 @@ static void *c2c_he_zalloc(size_t size) | |||
61 | if (!c2c_he->node_stats) | 70 | if (!c2c_he->node_stats) |
62 | return NULL; | 71 | return NULL; |
63 | 72 | ||
73 | init_stats(&c2c_he->cstats.lcl_hitm); | ||
74 | init_stats(&c2c_he->cstats.rmt_hitm); | ||
75 | init_stats(&c2c_he->cstats.load); | ||
76 | |||
64 | return &c2c_he->he; | 77 | return &c2c_he->he; |
65 | } | 78 | } |
66 | 79 | ||
@@ -122,6 +135,20 @@ static void c2c_he__set_cpu(struct c2c_hist_entry *c2c_he, | |||
122 | set_bit(sample->cpu, c2c_he->cpuset); | 135 | set_bit(sample->cpu, c2c_he->cpuset); |
123 | } | 136 | } |
124 | 137 | ||
138 | static void compute_stats(struct c2c_hist_entry *c2c_he, | ||
139 | struct c2c_stats *stats, | ||
140 | u64 weight) | ||
141 | { | ||
142 | struct compute_stats *cstats = &c2c_he->cstats; | ||
143 | |||
144 | if (stats->rmt_hitm) | ||
145 | update_stats(&cstats->rmt_hitm, weight); | ||
146 | else if (stats->lcl_hitm) | ||
147 | update_stats(&cstats->lcl_hitm, weight); | ||
148 | else if (stats->load) | ||
149 | update_stats(&cstats->load, weight); | ||
150 | } | ||
151 | |||
125 | static int process_sample_event(struct perf_tool *tool __maybe_unused, | 152 | static int process_sample_event(struct perf_tool *tool __maybe_unused, |
126 | union perf_event *event, | 153 | union perf_event *event, |
127 | struct perf_sample *sample, | 154 | struct perf_sample *sample, |
@@ -200,6 +227,8 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused, | |||
200 | c2c_add_stats(&c2c_hists->stats, &stats); | 227 | c2c_add_stats(&c2c_hists->stats, &stats); |
201 | c2c_add_stats(&c2c_he->node_stats[node], &stats); | 228 | c2c_add_stats(&c2c_he->node_stats[node], &stats); |
202 | 229 | ||
230 | compute_stats(c2c_he, &stats, sample->weight); | ||
231 | |||
203 | c2c_he__set_cpu(c2c_he, sample); | 232 | c2c_he__set_cpu(c2c_he, sample); |
204 | 233 | ||
205 | hists__inc_nr_samples(&c2c_hists->hists, he->filtered); | 234 | hists__inc_nr_samples(&c2c_hists->hists, he->filtered); |
@@ -962,6 +991,30 @@ node_entry(struct perf_hpp_fmt *fmt __maybe_unused, struct perf_hpp *hpp, | |||
962 | return 0; | 991 | return 0; |
963 | } | 992 | } |
964 | 993 | ||
994 | static int | ||
995 | mean_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, | ||
996 | struct hist_entry *he, double mean) | ||
997 | { | ||
998 | int width = c2c_width(fmt, hpp, he->hists); | ||
999 | char buf[10]; | ||
1000 | |||
1001 | scnprintf(buf, 10, "%6.0f", mean); | ||
1002 | return scnprintf(hpp->buf, hpp->size, "%*s", width, buf); | ||
1003 | } | ||
1004 | |||
1005 | #define MEAN_ENTRY(__func, __val) \ | ||
1006 | static int \ | ||
1007 | __func(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, struct hist_entry *he) \ | ||
1008 | { \ | ||
1009 | struct c2c_hist_entry *c2c_he; \ | ||
1010 | c2c_he = container_of(he, struct c2c_hist_entry, he); \ | ||
1011 | return mean_entry(fmt, hpp, he, avg_stats(&c2c_he->cstats.__val)); \ | ||
1012 | } | ||
1013 | |||
1014 | MEAN_ENTRY(mean_rmt_entry, rmt_hitm); | ||
1015 | MEAN_ENTRY(mean_lcl_entry, lcl_hitm); | ||
1016 | MEAN_ENTRY(mean_load_entry, load); | ||
1017 | |||
965 | #define HEADER_LOW(__h) \ | 1018 | #define HEADER_LOW(__h) \ |
966 | { \ | 1019 | { \ |
967 | .line[1] = { \ | 1020 | .line[1] = { \ |
@@ -1264,6 +1317,30 @@ static struct c2c_dimension dim_node = { | |||
1264 | .width = 4, | 1317 | .width = 4, |
1265 | }; | 1318 | }; |
1266 | 1319 | ||
1320 | static struct c2c_dimension dim_mean_rmt = { | ||
1321 | .header = HEADER_SPAN("---------- cycles ----------", "rmt hitm", 2), | ||
1322 | .name = "mean_rmt", | ||
1323 | .cmp = empty_cmp, | ||
1324 | .entry = mean_rmt_entry, | ||
1325 | .width = 8, | ||
1326 | }; | ||
1327 | |||
1328 | static struct c2c_dimension dim_mean_lcl = { | ||
1329 | .header = HEADER_SPAN_LOW("lcl hitm"), | ||
1330 | .name = "mean_lcl", | ||
1331 | .cmp = empty_cmp, | ||
1332 | .entry = mean_lcl_entry, | ||
1333 | .width = 8, | ||
1334 | }; | ||
1335 | |||
1336 | static struct c2c_dimension dim_mean_load = { | ||
1337 | .header = HEADER_SPAN_LOW("load"), | ||
1338 | .name = "mean_load", | ||
1339 | .cmp = empty_cmp, | ||
1340 | .entry = mean_load_entry, | ||
1341 | .width = 8, | ||
1342 | }; | ||
1343 | |||
1267 | static struct c2c_dimension *dimensions[] = { | 1344 | static struct c2c_dimension *dimensions[] = { |
1268 | &dim_dcacheline, | 1345 | &dim_dcacheline, |
1269 | &dim_offset, | 1346 | &dim_offset, |
@@ -1298,6 +1375,9 @@ static struct c2c_dimension *dimensions[] = { | |||
1298 | &dim_symbol, | 1375 | &dim_symbol, |
1299 | &dim_dso, | 1376 | &dim_dso, |
1300 | &dim_node, | 1377 | &dim_node, |
1378 | &dim_mean_rmt, | ||
1379 | &dim_mean_lcl, | ||
1380 | &dim_mean_load, | ||
1301 | NULL, | 1381 | NULL, |
1302 | }; | 1382 | }; |
1303 | 1383 | ||