aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2016-05-04 04:50:09 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-10-19 12:18:31 -0400
commitf0c50c15934e6300fca6fe2d1921dbd12a1fdf1c (patch)
tree6ece76e5ac0b033547c842718081d8fad5646b6f
parent55177c4ea6696332e2de44370eed3a62d7fceb67 (diff)
perf c2c report: Add hitm percent sort key
It is to be displayed in the main cachelines overall output: percent_hitm It displays HITMs percentage for cacheline. It counts remote HITMs at the moment, but it is changed later to support local as well, based on the sort configuration. 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-czd17qsh5u5z0yc1estz9l2y@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/builtin-c2c.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index 2411fe025bc7..dd356d88285c 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -565,6 +565,87 @@ tot_loads_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
565 return tot_recs_left - tot_recs_right; 565 return tot_recs_left - tot_recs_right;
566} 566}
567 567
568typedef double (get_percent_cb)(struct c2c_hist_entry *);
569
570static int
571percent_color(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
572 struct hist_entry *he, get_percent_cb get_percent)
573{
574 struct c2c_hist_entry *c2c_he;
575 int width = c2c_width(fmt, hpp, he->hists);
576 double per;
577
578 c2c_he = container_of(he, struct c2c_hist_entry, he);
579 per = get_percent(c2c_he);
580
581 return hpp_color_scnprintf(hpp, "%*.2f%%", width - 1, per);
582}
583
584static double percent_hitm(struct c2c_hist_entry *c2c_he)
585{
586 struct c2c_hists *hists;
587 struct c2c_stats *stats;
588 struct c2c_stats *total;
589 int tot, st;
590 double p;
591
592 hists = container_of(c2c_he->he.hists, struct c2c_hists, hists);
593 stats = &c2c_he->stats;
594 total = &hists->stats;
595
596 st = stats->rmt_hitm;
597 tot = total->rmt_hitm;
598
599 p = tot ? (double) st / tot : 0;
600
601 return 100 * p;
602}
603
604#define PERC_STR(__s, __v) \
605({ \
606 scnprintf(__s, sizeof(__s), "%.2F%%", __v); \
607 __s; \
608})
609
610static int
611percent_hitm_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
612 struct hist_entry *he)
613{
614 struct c2c_hist_entry *c2c_he;
615 int width = c2c_width(fmt, hpp, he->hists);
616 char buf[10];
617 double per;
618
619 c2c_he = container_of(he, struct c2c_hist_entry, he);
620 per = percent_hitm(c2c_he);
621 return scnprintf(hpp->buf, hpp->size, "%*s", width, PERC_STR(buf, per));
622}
623
624static int
625percent_hitm_color(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
626 struct hist_entry *he)
627{
628 return percent_color(fmt, hpp, he, percent_hitm);
629}
630
631static int64_t
632percent_hitm_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
633 struct hist_entry *left, struct hist_entry *right)
634{
635 struct c2c_hist_entry *c2c_left;
636 struct c2c_hist_entry *c2c_right;
637 double per_left;
638 double per_right;
639
640 c2c_left = container_of(left, struct c2c_hist_entry, he);
641 c2c_right = container_of(right, struct c2c_hist_entry, he);
642
643 per_left = percent_hitm(c2c_left);
644 per_right = percent_hitm(c2c_right);
645
646 return per_left - per_right;
647}
648
568#define HEADER_LOW(__h) \ 649#define HEADER_LOW(__h) \
569 { \ 650 { \
570 .line[1] = { \ 651 .line[1] = { \
@@ -768,6 +849,15 @@ static struct c2c_dimension dim_tot_loads = {
768 .width = 7, 849 .width = 7,
769}; 850};
770 851
852static struct c2c_dimension dim_percent_hitm = {
853 .header = HEADER_LOW("%hitm"),
854 .name = "percent_hitm",
855 .cmp = percent_hitm_cmp,
856 .entry = percent_hitm_entry,
857 .color = percent_hitm_color,
858 .width = 7,
859};
860
771static struct c2c_dimension *dimensions[] = { 861static struct c2c_dimension *dimensions[] = {
772 &dim_dcacheline, 862 &dim_dcacheline,
773 &dim_offset, 863 &dim_offset,
@@ -790,6 +880,7 @@ static struct c2c_dimension *dimensions[] = {
790 &dim_ld_llcmiss, 880 &dim_ld_llcmiss,
791 &dim_tot_recs, 881 &dim_tot_recs,
792 &dim_tot_loads, 882 &dim_tot_loads,
883 &dim_percent_hitm,
793 NULL, 884 NULL,
794}; 885};
795 886