Skip to content

Commit 6b2ae49

Browse files
Ravi BangoriaPeter Zijlstra
authored andcommitted
perf/x86/amd: Support PERF_SAMPLE_{WEIGHT|WEIGHT_STRUCT}
IbsDcMissLat indicates the number of clock cycles from when a miss is detected in the data cache to when the data was delivered to the core. Similarly, IbsTagToRetCtr provides number of cycles from when the op was tagged to when the op was retired. Consider these fields for sample->weight. Signed-off-by: Ravi Bangoria <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 7c10dd0 commit 6b2ae49

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

arch/x86/events/amd/ibs.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,7 @@ static void perf_ibs_parse_ld_st_data(__u64 sample_type,
955955
{
956956
union ibs_op_data3 op_data3;
957957
union ibs_op_data2 op_data2;
958+
union ibs_op_data op_data;
958959

959960
data->data_src.val = PERF_MEM_NA;
960961
op_data3.val = ibs_data->regs[ibs_op_msr_idx(MSR_AMD64_IBSOPDATA3)];
@@ -970,14 +971,28 @@ static void perf_ibs_parse_ld_st_data(__u64 sample_type,
970971
perf_ibs_get_data_src(ibs_data, data, &op_data2, &op_data3);
971972
data->sample_flags |= PERF_SAMPLE_DATA_SRC;
972973
}
974+
975+
if (sample_type & PERF_SAMPLE_WEIGHT_TYPE && op_data3.dc_miss &&
976+
data->data_src.mem_op == PERF_MEM_OP_LOAD) {
977+
op_data.val = ibs_data->regs[ibs_op_msr_idx(MSR_AMD64_IBSOPDATA)];
978+
979+
if (sample_type & PERF_SAMPLE_WEIGHT_STRUCT) {
980+
data->weight.var1_dw = op_data3.dc_miss_lat;
981+
data->weight.var2_w = op_data.tag_to_ret_ctr;
982+
} else if (sample_type & PERF_SAMPLE_WEIGHT) {
983+
data->weight.full = op_data3.dc_miss_lat;
984+
}
985+
data->sample_flags |= PERF_SAMPLE_WEIGHT_TYPE;
986+
}
973987
}
974988

975989
static int perf_ibs_get_offset_max(struct perf_ibs *perf_ibs, u64 sample_type,
976990
int check_rip)
977991
{
978992
if (sample_type & PERF_SAMPLE_RAW ||
979993
(perf_ibs == &perf_ibs_op &&
980-
sample_type & PERF_SAMPLE_DATA_SRC))
994+
(sample_type & PERF_SAMPLE_DATA_SRC ||
995+
sample_type & PERF_SAMPLE_WEIGHT_TYPE)))
981996
return perf_ibs->offset_max;
982997
else if (check_rip)
983998
return 3;

0 commit comments

Comments
 (0)