Skip to contentSkip to conversation

powerpc/perf: Fix reading of MSR[HV PR] bits in trace-imc

PATCH Applied Athira Rajeev 2 participants 2 messages Aug 26, 2020 – Aug 27, 2020 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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 third DW of the trace record. Reading third DW 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 77ca3951cc37 ("powerpc/perf: Add kernel support for new

MSR[HV PR] bits in trace-imc")

---
 arch/powerpc/perf/imc-pmu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/perf/imc-pmu.c +2 -2
index a45d694..62d0b54 100644
@@ -1289,7 +1289,7 @@ static int trace_imc_prepare_sample(struct trace_imc_data *mem,
 	header->misc = 0;
 
 	if (cpu_has_feature(CPU_FTR_ARCH_31)) {
-		switch (IMC_TRACE_RECORD_VAL_HVPR(mem->val)) {
+		switch (IMC_TRACE_RECORD_VAL_HVPR(be64_to_cpu(READ_ONCE(mem->val)))) {
 		case 0:/* when MSR HV and PR not set in the trace-record */
 			header->misc |= PERF_RECORD_MISC_GUEST_KERNEL;
 			break;
@@ -1297,7 +1297,7 @@ static int trace_imc_prepare_sample(struct trace_imc_data *mem,
 			header->misc |= PERF_RECORD_MISC_GUEST_USER;
 			break;
 		case 2: /* MSR HV is 1 and PR is 0 */
-			header->misc |= PERF_RECORD_MISC_HYPERVISOR;
+			header->misc |= PERF_RECORD_MISC_KERNEL;
 			break;
 		case 3: /* MSR HV is 1 and PR is 1 */
 			header->misc |= PERF_RECORD_MISC_USER;
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 8 lines · Athira Rajeev

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 third DW of the trace record. Reading third DW 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.

[...]

Applied to powerpc/fixes.

[1/1] powerpc/perf: Fix reading of MSR[HV/PR] bits in trace-imc

      https://git.kernel.org/powerpc/c/82715a0f332843d3a1830d7ebc9ac7c99a00c880

cheers