Skip to content

Commit 82715a0

Browse files
athira-rajeevmpe
authored andcommitted
powerpc/perf: Fix reading of MSR[HV/PR] bits in trace-imc
IMC trace-mode uses MSR[HV/PR] bits to set the cpumode for the instruction pointer captured in each sample. The bits are fetched from the third double word of the trace record. Reading third double word from IMC trace record should use be64_to_cpu() along with READ_ONCE inorder to fetch correct MSR[HV/PR] bits. Patch addresses this change. Currently we are using PERF_RECORD_MISC_HYPERVISOR as cpumode if MSR HV is 1 and PR is 0 which means the address is from host counter. But using PERF_RECORD_MISC_HYPERVISOR for host counter data will fail to resolve the address -> symbol during "perf report" because perf tools side uses PERF_RECORD_MISC_KERNEL to represent the host counter data. Therefore, fix the trace imc sample data to use PERF_RECORD_MISC_KERNEL as cpumode for host kernel information. Fixes: 77ca395 ("powerpc/perf: Add kernel support for new MSR[HV PR] bits in trace-imc") Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/1598424029-1662-1-git-send-email-atrajeev@linux.vnet.ibm.com
1 parent b460b51 commit 82715a0

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

arch/powerpc/perf/imc-pmu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,15 +1289,15 @@ static int trace_imc_prepare_sample(struct trace_imc_data *mem,
12891289
header->misc = 0;
12901290

12911291
if (cpu_has_feature(CPU_FTR_ARCH_31)) {
1292-
switch (IMC_TRACE_RECORD_VAL_HVPR(mem->val)) {
1292+
switch (IMC_TRACE_RECORD_VAL_HVPR(be64_to_cpu(READ_ONCE(mem->val)))) {
12931293
case 0:/* when MSR HV and PR not set in the trace-record */
12941294
header->misc |= PERF_RECORD_MISC_GUEST_KERNEL;
12951295
break;
12961296
case 1: /* MSR HV is 0 and PR is 1 */
12971297
header->misc |= PERF_RECORD_MISC_GUEST_USER;
12981298
break;
12991299
case 2: /* MSR HV is 1 and PR is 0 */
1300-
header->misc |= PERF_RECORD_MISC_HYPERVISOR;
1300+
header->misc |= PERF_RECORD_MISC_KERNEL;
13011301
break;
13021302
case 3: /* MSR HV is 1 and PR is 1 */
13031303
header->misc |= PERF_RECORD_MISC_USER;

0 commit comments

Comments
 (0)