[PATCH 53/57] perf c2c report: Add cacheline index entry

2016-09-22 Thread Jiri Olsa
It's convenient to have an index for each cacheline to
help discussions about results over the phone.

Add new 'Index' and 'Num' fields in main and single
cacheline tables.

$ perf c2c report
  =
 Shared Data Cache Line Table
  =
  #
  #  Total  Lcl  - LLC Load Hitm -
  # Index   Cacheline  records HitmTotal  Lcl  Rmt  ...
  # .  ..  ...  ...  ...  ...  ...
  #
0  0x880036233b401   11.11%110
1  0x88009ccb29001   11.11%110
2  0x8800b5b3bc407   11.11%110
  ...

  =
Shared Cache Line Distribution Pareto
  =
  #
  #- HITM -  -- Store Refs --Data address
  #   Num  Rmt  Lcl   L1 Hit  L1 Miss  Offset  Pid  ...
  # .  ...  ...  ...  ...  ..  ...
  #
-
00100  0x880036233b40
-
 0.00%  100.00%0.00%0.00%0x300

-
10100  0x88009ccb2900
-
 0.00%  100.00%0.00%0.00%0x28  549
  ...

Link: http://lkml.kernel.org/n/tip-4dhfagaz57tvrfjbg8nd2...@git.kernel.org
Signed-off-by: Jiri Olsa 
---
 tools/perf/builtin-c2c.c | 64 +---
 1 file changed, 61 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index c7fe81d49016..f39947d29765 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -36,6 +36,7 @@ struct c2c_hist_entry {
struct c2c_stats stats;
unsigned long   *cpuset;
struct c2c_stats*node_stats;
+   unsigned int cacheline_idx;
 
struct compute_stats cstats;
 
@@ -1085,6 +1086,29 @@ cpucnt_entry(struct perf_hpp_fmt *fmt __maybe_unused, 
struct perf_hpp *hpp,
return snprintf(hpp->buf, hpp->size, "%*s", width, buf);
 }
 
+static int
+cl_idx_entry(struct perf_hpp_fmt *fmt __maybe_unused, struct perf_hpp *hpp,
+struct hist_entry *he)
+{
+   struct c2c_hist_entry *c2c_he;
+   int width = c2c_width(fmt, hpp, he->hists);
+   char buf[10];
+
+   c2c_he = container_of(he, struct c2c_hist_entry, he);
+
+   snprintf(buf, 10, "%u", c2c_he->cacheline_idx);
+   return snprintf(hpp->buf, hpp->size, "%*s", width, buf);
+}
+
+static int
+cl_idx_empty_entry(struct perf_hpp_fmt *fmt __maybe_unused, struct perf_hpp 
*hpp,
+  struct hist_entry *he)
+{
+   int width = c2c_width(fmt, hpp, he->hists);
+
+   return snprintf(hpp->buf, hpp->size, "%*s", width, "");
+}
+
 #define HEADER_LOW(__h)\
{   \
.line[1] = {\
@@ -1430,6 +1454,30 @@ static struct c2c_dimension dim_srcline = {
.se = _srcline,
 };
 
+static struct c2c_dimension dim_dcacheline_idx = {
+   .header = HEADER_LOW("Index"),
+   .name   = "cl_idx",
+   .cmp= empty_cmp,
+   .entry  = cl_idx_entry,
+   .width  = 5,
+};
+
+static struct c2c_dimension dim_dcacheline_num = {
+   .header = HEADER_LOW("Num"),
+   .name   = "cl_num",
+   .cmp= empty_cmp,
+   .entry  = cl_idx_entry,
+   .width  = 5,
+};
+
+static struct c2c_dimension dim_dcacheline_num_empty = {
+   .header = HEADER_LOW("Num"),
+   .name   = "cl_num_empty",
+   .cmp= empty_cmp,
+   .entry  = cl_idx_empty_entry,
+   .width  = 5,
+};
+
 static struct c2c_dimension *dimensions[] = {
_dcacheline,
_offset,
@@ -1469,6 +1517,9 @@ static struct c2c_dimension *dimensions[] = {
_mean_load,
_cpucnt,
_srcline,
+   _dcacheline_idx,
+   _dcacheline_num,
+   _dcacheline_num_empty,
NULL,
 };
 
@@ -1755,6 +1806,10 @@ static int resort_cl_cb(struct hist_entry *he)
calc_width(he);
 
if (display && c2c_hists) {
+   static unsigned int idx;
+
+   c2c_he->cacheline_idx = idx++;
+
c2c_hists__reinit(c2c_hists, c2c.cl_output, c2c.cl_resort);
 
hists__collapse_resort(_hists->hists, NULL);
@@ -1942,10 +1997,10 @@ static void 

[PATCH 53/57] perf c2c report: Add cacheline index entry

2016-09-22 Thread Jiri Olsa
It's convenient to have an index for each cacheline to
help discussions about results over the phone.

Add new 'Index' and 'Num' fields in main and single
cacheline tables.

$ perf c2c report
  =
 Shared Data Cache Line Table
  =
  #
  #  Total  Lcl  - LLC Load Hitm -
  # Index   Cacheline  records HitmTotal  Lcl  Rmt  ...
  # .  ..  ...  ...  ...  ...  ...
  #
0  0x880036233b401   11.11%110
1  0x88009ccb29001   11.11%110
2  0x8800b5b3bc407   11.11%110
  ...

  =
Shared Cache Line Distribution Pareto
  =
  #
  #- HITM -  -- Store Refs --Data address
  #   Num  Rmt  Lcl   L1 Hit  L1 Miss  Offset  Pid  ...
  # .  ...  ...  ...  ...  ..  ...
  #
-
00100  0x880036233b40
-
 0.00%  100.00%0.00%0.00%0x300

-
10100  0x88009ccb2900
-
 0.00%  100.00%0.00%0.00%0x28  549
  ...

Link: http://lkml.kernel.org/n/tip-4dhfagaz57tvrfjbg8nd2...@git.kernel.org
Signed-off-by: Jiri Olsa 
---
 tools/perf/builtin-c2c.c | 64 +---
 1 file changed, 61 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index c7fe81d49016..f39947d29765 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -36,6 +36,7 @@ struct c2c_hist_entry {
struct c2c_stats stats;
unsigned long   *cpuset;
struct c2c_stats*node_stats;
+   unsigned int cacheline_idx;
 
struct compute_stats cstats;
 
@@ -1085,6 +1086,29 @@ cpucnt_entry(struct perf_hpp_fmt *fmt __maybe_unused, 
struct perf_hpp *hpp,
return snprintf(hpp->buf, hpp->size, "%*s", width, buf);
 }
 
+static int
+cl_idx_entry(struct perf_hpp_fmt *fmt __maybe_unused, struct perf_hpp *hpp,
+struct hist_entry *he)
+{
+   struct c2c_hist_entry *c2c_he;
+   int width = c2c_width(fmt, hpp, he->hists);
+   char buf[10];
+
+   c2c_he = container_of(he, struct c2c_hist_entry, he);
+
+   snprintf(buf, 10, "%u", c2c_he->cacheline_idx);
+   return snprintf(hpp->buf, hpp->size, "%*s", width, buf);
+}
+
+static int
+cl_idx_empty_entry(struct perf_hpp_fmt *fmt __maybe_unused, struct perf_hpp 
*hpp,
+  struct hist_entry *he)
+{
+   int width = c2c_width(fmt, hpp, he->hists);
+
+   return snprintf(hpp->buf, hpp->size, "%*s", width, "");
+}
+
 #define HEADER_LOW(__h)\
{   \
.line[1] = {\
@@ -1430,6 +1454,30 @@ static struct c2c_dimension dim_srcline = {
.se = _srcline,
 };
 
+static struct c2c_dimension dim_dcacheline_idx = {
+   .header = HEADER_LOW("Index"),
+   .name   = "cl_idx",
+   .cmp= empty_cmp,
+   .entry  = cl_idx_entry,
+   .width  = 5,
+};
+
+static struct c2c_dimension dim_dcacheline_num = {
+   .header = HEADER_LOW("Num"),
+   .name   = "cl_num",
+   .cmp= empty_cmp,
+   .entry  = cl_idx_entry,
+   .width  = 5,
+};
+
+static struct c2c_dimension dim_dcacheline_num_empty = {
+   .header = HEADER_LOW("Num"),
+   .name   = "cl_num_empty",
+   .cmp= empty_cmp,
+   .entry  = cl_idx_empty_entry,
+   .width  = 5,
+};
+
 static struct c2c_dimension *dimensions[] = {
_dcacheline,
_offset,
@@ -1469,6 +1517,9 @@ static struct c2c_dimension *dimensions[] = {
_mean_load,
_cpucnt,
_srcline,
+   _dcacheline_idx,
+   _dcacheline_num,
+   _dcacheline_num_empty,
NULL,
 };
 
@@ -1755,6 +1806,10 @@ static int resort_cl_cb(struct hist_entry *he)
calc_width(he);
 
if (display && c2c_hists) {
+   static unsigned int idx;
+
+   c2c_he->cacheline_idx = idx++;
+
c2c_hists__reinit(c2c_hists, c2c.cl_output, c2c.cl_resort);
 
hists__collapse_resort(_hists->hists, NULL);
@@ -1942,10 +1997,10 @@ static void