From: Stephane Eranian <eranian@google.com>
To: linux-kernel@vger.kernel.org
Cc: peterz@infradead.org, namhyung@kernel.org, irogers@google.com,
sandipan.das@amd.com, ravi.bangoria@amd.com,
ananth.narayan@amd.com
Subject: [PATCH] perf/amd/ibs: provide weights for all IBS op samples
Date: Wed, 13 Mar 2024 10:54:53 -0700 [thread overview]
Message-ID: <20240313175453.433166-1-eranian@google.com> (raw)
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@google.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
next reply other threads:[~2024-03-13 17:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-13 17:54 Stephane Eranian [this message]
2024-03-18 10:44 ` Ravi Bangoria
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240313175453.433166-1-eranian@google.com \
--to=eranian@google.com \
--cc=ananth.narayan@amd.com \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=ravi.bangoria@amd.com \
--cc=sandipan.das@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®