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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240313175453.433166-1-eranian@google.com>
Date: Wed, 13 Mar 2024 10:54:53 -0700
From: Stephane Eranian <eranian@...gle.com>
To: linux-kernel@...r.kernel.org
Cc: peterz@...radead.org, namhyung@...nel.org, irogers@...gle.com, 
	sandipan.das@....com, ravi.bangoria@....com, ananth.narayan@....com
Subject: [PATCH] perf/amd/ibs: provide weights for all IBS op samples

IBS Op provides instructions latencies for each uop sampled. The current
code was only providing the weights only for loads. This is useful
information for performance analysis. This patch modifies the logic to
provide the weights for all uops.

$ perf record -a -W -c 100003 -e ibs_op/cnt_ctl=1/GH ....

Signed-off-by: Stephane Eranian <eranian@...gle.com>
---
 arch/x86/events/amd/ibs.c | 46 +++++++++++++++++++++++++++++----------
 1 file changed, 35 insertions(+), 11 deletions(-)

diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
index e91970b01d62..d2f4d3b19cf9 100644
--- a/arch/x86/events/amd/ibs.c
+++ b/arch/x86/events/amd/ibs.c
@@ -957,6 +957,28 @@ static __u64 perf_ibs_get_op_data2(struct perf_ibs_data *ibs_data,
 	return val;
 }
 
+static void perf_ibs_parse_uop_latencies(__u64 sample_type,
+					 struct perf_ibs_data *ibs_data,
+					 struct perf_sample_data *data)
+{
+	union ibs_op_data op_data;
+
+	/* latencies not requested by user */
+	if (!(sample_type & PERF_SAMPLE_WEIGHT_TYPE))
+		return;
+
+	op_data.val = ibs_data->regs[ibs_op_msr_idx(MSR_AMD64_IBSOPDATA)];
+
+	if (sample_type & PERF_SAMPLE_WEIGHT_STRUCT) {
+		data->weight.var1_dw = 0;
+		data->weight.var2_w = op_data.tag_to_ret_ctr;
+		data->weight.var3_w = op_data.comp_to_ret_ctr;
+	} else {
+		data->weight.full = op_data.tag_to_ret_ctr;
+	}
+	data->sample_flags |= PERF_SAMPLE_WEIGHT_TYPE;
+}
+
 static void perf_ibs_parse_ld_st_data(__u64 sample_type,
 				      struct perf_ibs_data *ibs_data,
 				      struct perf_sample_data *data)
@@ -980,17 +1002,15 @@ static void perf_ibs_parse_ld_st_data(__u64 sample_type,
 		data->sample_flags |= PERF_SAMPLE_DATA_SRC;
 	}
 
-	if (sample_type & PERF_SAMPLE_WEIGHT_TYPE && op_data3.dc_miss &&
-	    data->data_src.mem_op == PERF_MEM_OP_LOAD) {
+	if (sample_type & PERF_SAMPLE_WEIGHT_TYPE) {
 		op_data.val = ibs_data->regs[ibs_op_msr_idx(MSR_AMD64_IBSOPDATA)];
-
-		if (sample_type & PERF_SAMPLE_WEIGHT_STRUCT) {
-			data->weight.var1_dw = op_data3.dc_miss_lat;
-			data->weight.var2_w = op_data.tag_to_ret_ctr;
-		} else if (sample_type & PERF_SAMPLE_WEIGHT) {
-			data->weight.full = op_data3.dc_miss_lat;
+		if (op_data3.dc_miss && data->data_src.mem_op == PERF_MEM_OP_LOAD) {
+			if (sample_type & PERF_SAMPLE_WEIGHT_STRUCT) {
+				data->weight.var1_dw = op_data3.dc_miss_lat;
+			} else if (sample_type & PERF_SAMPLE_WEIGHT) {
+				data->weight.full = op_data3.dc_miss_lat;
+			}
 		}
-		data->sample_flags |= PERF_SAMPLE_WEIGHT_TYPE;
 	}
 
 	if (sample_type & PERF_SAMPLE_ADDR && op_data3.dc_lin_addr_valid) {
@@ -1121,8 +1141,12 @@ static int perf_ibs_handle_irq(struct perf_ibs *perf_ibs, struct pt_regs *iregs)
 		perf_sample_save_raw_data(&data, &raw);
 	}
 
-	if (perf_ibs == &perf_ibs_op)
-		perf_ibs_parse_ld_st_data(event->attr.sample_type, &ibs_data, &data);
+	if (perf_ibs == &perf_ibs_op) {
+		__u32 type = event->attr.sample_type;
+
+		perf_ibs_parse_uop_latencies(type, &ibs_data, &data);
+		perf_ibs_parse_ld_st_data(type, &ibs_data, &data);
+	}
 
 	/*
 	 * rip recorded by IbsOpRip will not be consistent with rsp and rbp
-- 
2.44.0.278.ge034bb2e1d-goog


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ