lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 27 Apr 2022 23:50:07 +0800
From:   Leo Yan <leo.yan@...aro.org>
To:     Arnaldo Carvalho de Melo <acme@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...nel.org>,
        Namhyung Kim <namhyung@...nel.org>,
        Ian Rogers <irogers@...gle.com>, Alyssa Ross <hi@...ssa.is>,
        Like Xu <likexu@...cent.com>, Kajol Jain <kjain@...ux.ibm.com>,
        Li Huafei <lihuafei1@...wei.com>,
        Ali Saidi <alisaidi@...zon.com>,
        German Gomez <german.gomez@....com>,
        James Clark <james.clark@....com>,
        linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     Leo Yan <leo.yan@...aro.org>
Subject: [PATCH v1 05/11] perf c2c: Add dimensions for peer load operations

This patch is to add dimensions for peer load operations, include a
dimension for the total statistics for metric 'ld_peer', and also add
dimensions for the single cache line view.

Same as HTIM metrics, this patch also adds the dimension for mean value
for peer load operations.

Signed-off-by: Leo Yan <leo.yan@...aro.org>
Tested-by: Ali Saidi <alisaidi@...zon.com>
---
 tools/perf/builtin-c2c.c | 93 +++++++++++++++++++++++++++++++++++++---
 1 file changed, 88 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index 9ef439610a2b..cef6513012e2 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -55,6 +55,7 @@ struct c2c_hists {
 struct compute_stats {
 	struct stats		 lcl_hitm;
 	struct stats		 rmt_hitm;
+	struct stats		 ld_peer;
 	struct stats		 load;
 };
 
@@ -154,6 +155,7 @@ static void *c2c_he_zalloc(size_t size)
 
 	init_stats(&c2c_he->cstats.lcl_hitm);
 	init_stats(&c2c_he->cstats.rmt_hitm);
+	init_stats(&c2c_he->cstats.ld_peer);
 	init_stats(&c2c_he->cstats.load);
 
 	return &c2c_he->he;
@@ -253,6 +255,8 @@ static void compute_stats(struct c2c_hist_entry *c2c_he,
 		update_stats(&cstats->rmt_hitm, weight);
 	else if (stats->lcl_hitm)
 		update_stats(&cstats->lcl_hitm, weight);
+	else if (stats->ld_peer)
+		update_stats(&cstats->ld_peer, weight);
 	else if (stats->load)
 		update_stats(&cstats->load, weight);
 }
@@ -658,6 +662,7 @@ STAT_FN(ld_fbhit)
 STAT_FN(ld_l1hit)
 STAT_FN(ld_l2hit)
 STAT_FN(ld_llchit)
+STAT_FN(ld_peer)
 STAT_FN(rmt_hit)
 
 static uint64_t total_records(struct c2c_stats *stats)
@@ -674,7 +679,8 @@ static uint64_t total_records(struct c2c_stats *stats)
 		   stats->ld_l1hit +
 		   stats->ld_l2hit +
 		   stats->ld_llchit +
-		   stats->lcl_hitm;
+		   stats->lcl_hitm +
+		   stats->ld_peer;
 
 	total    = ldcnt +
 		   stats->st_l1hit +
@@ -730,7 +736,8 @@ static uint64_t total_loads(struct c2c_stats *stats)
 		   stats->ld_l1hit +
 		   stats->ld_l2hit +
 		   stats->ld_llchit +
-		   stats->lcl_hitm;
+		   stats->lcl_hitm +
+		   stats->ld_peer;
 
 	return ldcnt;
 }
@@ -899,6 +906,7 @@ static double percent_ ## __f(struct c2c_hist_entry *c2c_he)			\
 
 PERCENT_FN(rmt_hitm)
 PERCENT_FN(lcl_hitm)
+PERCENT_FN(ld_peer)
 PERCENT_FN(st_l1hit)
 PERCENT_FN(st_l1miss)
 PERCENT_FN(st_anylvl)
@@ -965,6 +973,37 @@ percent_lcl_hitm_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
 	return per_left - per_right;
 }
 
+static int
+percent_ld_peer_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
+		       struct hist_entry *he)
+{
+	int width = c2c_width(fmt, hpp, he->hists);
+	double per = PERCENT(he, ld_peer);
+	char buf[10];
+
+	return scnprintf(hpp->buf, hpp->size, "%*s", width, PERC_STR(buf, per));
+}
+
+static int
+percent_ld_peer_color(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
+		       struct hist_entry *he)
+{
+	return percent_color(fmt, hpp, he, percent_ld_peer);
+}
+
+static int64_t
+percent_ld_peer_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
+		    struct hist_entry *left, struct hist_entry *right)
+{
+	double per_left;
+	double per_right;
+
+	per_left  = PERCENT(left, ld_peer);
+	per_right = PERCENT(right, ld_peer);
+
+	return per_left - per_right;
+}
+
 static int
 percent_stores_l1hit_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
 			   struct hist_entry *he)
@@ -1213,6 +1252,7 @@ __func(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, struct hist_entry *he)	\
 MEAN_ENTRY(mean_rmt_entry,  rmt_hitm);
 MEAN_ENTRY(mean_lcl_entry,  lcl_hitm);
 MEAN_ENTRY(mean_load_entry, load);
+MEAN_ENTRY(mean_peer_entry, ld_peer);
 
 static int
 cpucnt_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
@@ -1360,6 +1400,14 @@ static struct c2c_dimension dim_rmt_hitm = {
 	.width		= 7,
 };
 
+static struct c2c_dimension dim_ld_peer = {
+	.header		= HEADER_BOTH("Snoop", "Peer"),
+	.name		= "ld_peer",
+	.cmp		= ld_peer_cmp,
+	.entry		= ld_peer_entry,
+	.width		= 7,
+};
+
 static struct c2c_dimension dim_cl_rmt_hitm = {
 	.header		= HEADER_SPAN("----- HITM -----", "Rmt", 1),
 	.name		= "cl_rmt_hitm",
@@ -1376,6 +1424,14 @@ static struct c2c_dimension dim_cl_lcl_hitm = {
 	.width		= 7,
 };
 
+static struct c2c_dimension dim_cl_ld_peer = {
+	.header		= HEADER_BOTH("Snoop", "Peer"),
+	.name		= "cl_ld_peer",
+	.cmp		= ld_peer_cmp,
+	.entry		= ld_peer_entry,
+	.width		= 7,
+};
+
 static struct c2c_dimension dim_tot_stores = {
 	.header		= HEADER_BOTH("Total", "Stores"),
 	.name		= "tot_stores",
@@ -1520,6 +1576,15 @@ static struct c2c_dimension dim_percent_lcl_hitm = {
 	.width		= 7,
 };
 
+static struct c2c_dimension dim_percent_ld_peer = {
+	.header		= HEADER_BOTH("Snoop", "Peer"),
+	.name		= "percent_ld_peer",
+	.cmp		= percent_ld_peer_cmp,
+	.entry		= percent_ld_peer_entry,
+	.color		= percent_ld_peer_color,
+	.width		= 7,
+};
+
 static struct c2c_dimension dim_percent_stores_l1hit = {
 	.header		= HEADER_SPAN("------- Store Refs ------", "L1 Hit", 2),
 	.name		= "percent_stores_l1hit",
@@ -1602,7 +1667,7 @@ static struct c2c_dimension dim_node = {
 };
 
 static struct c2c_dimension dim_mean_rmt = {
-	.header		= HEADER_SPAN("---------- cycles ----------", "rmt hitm", 2),
+	.header		= HEADER_SPAN("--------------- cycles ---------------", "rmt hitm", 3),
 	.name		= "mean_rmt",
 	.cmp		= empty_cmp,
 	.entry		= mean_rmt_entry,
@@ -1625,6 +1690,14 @@ static struct c2c_dimension dim_mean_load = {
 	.width		= 8,
 };
 
+static struct c2c_dimension dim_mean_peer = {
+	.header		= HEADER_SPAN_LOW("peer"),
+	.name		= "mean_peer",
+	.cmp		= empty_cmp,
+	.entry		= mean_peer_entry,
+	.width		= 8,
+};
+
 static struct c2c_dimension dim_cpucnt = {
 	.header		= HEADER_BOTH("cpu", "cnt"),
 	.name		= "cpucnt",
@@ -1672,8 +1745,10 @@ static struct c2c_dimension *dimensions[] = {
 	&dim_tot_hitm,
 	&dim_lcl_hitm,
 	&dim_rmt_hitm,
+	&dim_ld_peer,
 	&dim_cl_lcl_hitm,
 	&dim_cl_rmt_hitm,
+	&dim_cl_ld_peer,
 	&dim_tot_stores,
 	&dim_stores_l1hit,
 	&dim_stores_l1miss,
@@ -1691,6 +1766,7 @@ static struct c2c_dimension *dimensions[] = {
 	&dim_percent_hitm,
 	&dim_percent_rmt_hitm,
 	&dim_percent_lcl_hitm,
+	&dim_percent_ld_peer,
 	&dim_percent_stores_l1hit,
 	&dim_percent_stores_l1miss,
 	&dim_percent_stores_anylvl,
@@ -1704,6 +1780,7 @@ static struct c2c_dimension *dimensions[] = {
 	&dim_mean_rmt,
 	&dim_mean_lcl,
 	&dim_mean_load,
+	&dim_mean_peer,
 	&dim_cpucnt,
 	&dim_srcline,
 	&dim_dcacheline_idx,
@@ -2192,6 +2269,7 @@ static void print_c2c__display_stats(FILE *out)
 	fprintf(out, "  Load L1D hit                      : %10d\n", stats->ld_l1hit);
 	fprintf(out, "  Load L2D hit                      : %10d\n", stats->ld_l2hit);
 	fprintf(out, "  Load LLC hit                      : %10d\n", stats->ld_llchit + stats->lcl_hitm);
+	fprintf(out, "  Load HIT Peer                     : %10d\n", stats->ld_peer);
 	fprintf(out, "  Load Local HITM                   : %10d\n", stats->lcl_hitm);
 	fprintf(out, "  Load Remote HITM                  : %10d\n", stats->rmt_hitm);
 	fprintf(out, "  Load Remote HIT                   : %10d\n", stats->rmt_hit);
@@ -2229,6 +2307,7 @@ static void print_shared_cacheline_info(FILE *out)
 	fprintf(out, "  Fill Buffer Hits on shared lines  : %10d\n", stats->ld_fbhit);
 	fprintf(out, "  L1D hits on shared lines          : %10d\n", stats->ld_l1hit);
 	fprintf(out, "  L2D hits on shared lines          : %10d\n", stats->ld_l2hit);
+	fprintf(out, "  Load HITs on peer cache lines     : %10d\n", stats->ld_peer);
 	fprintf(out, "  LLC hits on shared lines          : %10d\n", stats->ld_llchit + stats->lcl_hitm);
 	fprintf(out, "  Locked Access on shared lines     : %10d\n", stats->locks);
 	fprintf(out, "  Blocked Access on shared lines    : %10d\n", stats->blk_data + stats->blk_addr);
@@ -2257,10 +2336,10 @@ static void print_cacheline(struct c2c_hists *c2c_hists,
 		fprintf(out, "\n");
 	}
 
-	fprintf(out, "  ----------------------------------------------------------------------\n");
+	fprintf(out, "  -------------------------------------------------------------------------------\n");
 	__hist_entry__snprintf(he_cl, &hpp, hpp_list);
 	fprintf(out, "%s\n", bf);
-	fprintf(out, "  ----------------------------------------------------------------------\n");
+	fprintf(out, "  -------------------------------------------------------------------------------\n");
 
 	hists__fprintf(&c2c_hists->hists, false, 0, 0, 0, out, false);
 }
@@ -2275,6 +2354,7 @@ static void print_pareto(FILE *out)
 	cl_output = "cl_num,"
 		    "cl_rmt_hitm,"
 		    "cl_lcl_hitm,"
+		    "cl_ld_peer,"
 		    "cl_stores_l1hit,"
 		    "cl_stores_l1miss,"
 		    "cl_stores_anylvl,"
@@ -2727,6 +2807,7 @@ static int build_cl_output(char *cl_sort, bool no_source)
 		c2c.use_stdio ? "cl_num_empty," : "",
 		"percent_rmt_hitm,"
 		"percent_lcl_hitm,"
+		"percent_ld_peer,"
 		"percent_stores_l1hit,"
 		"percent_stores_l1miss,"
 		"percent_stores_anylvl,"
@@ -2737,6 +2818,7 @@ static int build_cl_output(char *cl_sort, bool no_source)
 		"mean_rmt,"
 		"mean_lcl,"
 		"mean_load,"
+		"mean_peer,"
 		"tot_recs,"
 		"cpucnt,",
 		add_sym ? "symbol," : "",
@@ -2913,6 +2995,7 @@ static int perf_c2c__report(int argc, const char **argv)
 		     "dcacheline_count,"
 		     "percent_hitm,"
 		     "tot_hitm,lcl_hitm,rmt_hitm,"
+		     "ld_peer,"
 		     "tot_recs,"
 		     "tot_loads,"
 		     "tot_stores,"
-- 
2.25.1

Powered by blists - more mailing lists