All of lore.kernel.org
 help / color / mirror / Atom feed
From: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
To: mpe@ellerman.id.au
Cc: maddy@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org
Subject: [PATCH] powerpc/perf: Fix reading of MSR[HV PR] bits in trace-imc
Date: Wed, 26 Aug 2020 02:40:29 -0400	[thread overview]
Message-ID: <1598424029-1662-1-git-send-email-atrajeev@linux.vnet.ibm.com> (raw)

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")
Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
---
 arch/powerpc/perf/imc-pmu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/perf/imc-pmu.c b/arch/powerpc/perf/imc-pmu.c
index a45d694..62d0b54 100644
--- a/arch/powerpc/perf/imc-pmu.c
+++ b/arch/powerpc/perf/imc-pmu.c
@@ -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;
-- 
1.8.3.1


             reply	other threads:[~2020-08-26  6:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-26  6:40 Athira Rajeev [this message]
2020-08-27  7:46 ` [PATCH] powerpc/perf: Fix reading of MSR[HV PR] bits in trace-imc Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1598424029-1662-1-git-send-email-atrajeev@linux.vnet.ibm.com \
    --to=atrajeev@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.vnet.ibm.com \
    --cc=mpe@ellerman.id.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.