Skip to content

Commit 5b26af6

Browse files
Ravi BangoriaPeter Zijlstra
authored andcommitted
perf/x86/amd: Support PERF_SAMPLE_PHY_ADDR
IBS_DC_PHYSADDR provides the physical data address for the tagged load/ store operation. Populate perf sample physical address using it. 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 cb2bb85 commit 5b26af6

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

arch/x86/events/amd/ibs.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,11 @@ static void perf_ibs_parse_ld_st_data(__u64 sample_type,
989989
data->addr = ibs_data->regs[ibs_op_msr_idx(MSR_AMD64_IBSDCLINAD)];
990990
data->sample_flags |= PERF_SAMPLE_ADDR;
991991
}
992+
993+
if (sample_type & PERF_SAMPLE_PHYS_ADDR && op_data3.dc_phy_addr_valid) {
994+
data->phys_addr = ibs_data->regs[ibs_op_msr_idx(MSR_AMD64_IBSDCPHYSAD)];
995+
data->sample_flags |= PERF_SAMPLE_PHYS_ADDR;
996+
}
992997
}
993998

994999
static int perf_ibs_get_offset_max(struct perf_ibs *perf_ibs, u64 sample_type,
@@ -998,7 +1003,8 @@ static int perf_ibs_get_offset_max(struct perf_ibs *perf_ibs, u64 sample_type,
9981003
(perf_ibs == &perf_ibs_op &&
9991004
(sample_type & PERF_SAMPLE_DATA_SRC ||
10001005
sample_type & PERF_SAMPLE_WEIGHT_TYPE ||
1001-
sample_type & PERF_SAMPLE_ADDR)))
1006+
sample_type & PERF_SAMPLE_ADDR ||
1007+
sample_type & PERF_SAMPLE_PHYS_ADDR)))
10021008
return perf_ibs->offset_max;
10031009
else if (check_rip)
10041010
return 3;

kernel/events/core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7435,7 +7435,8 @@ void perf_prepare_sample(struct perf_event_header *header,
74357435
header->size += size;
74367436
}
74377437

7438-
if (sample_type & PERF_SAMPLE_PHYS_ADDR)
7438+
if (sample_type & PERF_SAMPLE_PHYS_ADDR &&
7439+
filtered_sample_type & PERF_SAMPLE_PHYS_ADDR)
74397440
data->phys_addr = perf_virt_to_phys(data->addr);
74407441

74417442
#ifdef CONFIG_CGROUP_PERF

0 commit comments

Comments
 (0)