* [PATCH] perf/amd/ibs: provide weights for all IBS op samples
@ 2024-03-13 17:54 Stephane Eranian
2024-03-18 10:44 ` Ravi Bangoria
0 siblings, 1 reply; 2+ messages in thread
From: Stephane Eranian @ 2024-03-13 17:54 UTC (permalink / raw)
To: linux-kernel
Cc: peterz, namhyung, irogers, sandipan.das, ravi.bangoria, ananth.narayan
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
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] perf/amd/ibs: provide weights for all IBS op samples
2024-03-13 17:54 [PATCH] perf/amd/ibs: provide weights for all IBS op samples Stephane Eranian
@ 2024-03-18 10:44 ` Ravi Bangoria
0 siblings, 0 replies; 2+ messages in thread
From: Ravi Bangoria @ 2024-03-18 10:44 UTC (permalink / raw)
To: Stephane Eranian, linux-kernel
Cc: peterz, namhyung, irogers, sandipan.das, ananth.narayan,
Ingo Molnar, Ravi Bangoria
cc: +Ingo
On 13-Mar-24 11:24 PM, Stephane Eranian wrote:
> 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>
Reviewed-by: Ravi Bangoria <ravi.bangoria@amd.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-03-18 10:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-13 17:54 [PATCH] perf/amd/ibs: provide weights for all IBS op samples Stephane Eranian
2024-03-18 10:44 ` Ravi Bangoria
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®