linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
To: Nicholas Piggin <npiggin@gmail.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] powerpc/64s/perf: Always use SIAR for kernel interrupts
Date: Wed, 21 Jul 2021 11:06:13 +0530	[thread overview]
Message-ID: <3B701B8E-5C49-49A6-BAF7-246F42F7B0E7@linux.vnet.ibm.com> (raw)
In-Reply-To: <20210720141504.420110-1-npiggin@gmail.com>



> On 20-Jul-2021, at 7:45 PM, Nicholas Piggin <npiggin@gmail.com> wrote:
> 
> If an interrupt is taken in kernel mode, always use SIAR for it rather than
> looking at regs_sipr. This prevents samples piling up around interrupt
> enable (hard enable or interrupt replay via soft enable) in PMUs / modes
> where the PR sample indication is not in synch with SIAR.
> 
> This results in better sampling of interrupt entry and exit in particular.
> 
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> arch/powerpc/perf/core-book3s.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
> 
> diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
> index bb0ee716de91..91203ed9d0ff 100644
> --- a/arch/powerpc/perf/core-book3s.c
> +++ b/arch/powerpc/perf/core-book3s.c
> @@ -340,6 +340,13 @@ static inline void perf_read_regs(struct pt_regs *regs)
> 	 * If the PMU doesn't update the SIAR for non marked events use
> 	 * pt_regs.
> 	 *
> +	 * If regs is a kernel interrupt, always use SIAR. Some PMUs have an
> +	 * issue with regs_sipr not being in synch with SIAR in interrupt entry
> +	 * and return sequences, which can result in regs_sipr being true for
> +	 * kernel interrupts and SIAR, which has the effect of causing samples
> +	 * to pile up at mtmsrd MSR[EE] 0->1 or pending irq replay around
> +	 * interrupt entry/exit.
> +	 *
> 	 * If the PMU has HV/PR flags then check to see if they
> 	 * place the exception in userspace. If so, use pt_regs. In
> 	 * continuous sampling mode the SIAR and the PMU exception are
> @@ -356,6 +363,8 @@ static inline void perf_read_regs(struct pt_regs *regs)
> 		use_siar = 1;
> 	else if ((ppmu->flags & PPMU_NO_CONT_SAMPLING))
> 		use_siar = 0;
> +	else if (!user_mode(regs))
> +		use_siar = 1;


Tested the change.

Workload used: Testcase that runs a loop of “scv” syscalls

Before the patch:
# perf record <test>
# perf report|grep replay
     3.90%  scvonly  [kernel.vmlinux]            [k] replay_soft_interrupts

Samples were present around interrupt replay code.

After the fix, perf report didn’t had samples pointing to replay code.

Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>

Thanks
Athira
> 	else if (!(ppmu->flags & PPMU_NO_SIPR) && regs_sipr(regs))
> 		use_siar = 0;
> 	else
> -- 
> 2.23.0
> 


  reply	other threads:[~2021-07-21  5:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-20 14:15 [PATCH] powerpc/64s/perf: Always use SIAR for kernel interrupts Nicholas Piggin
2021-07-21  5:36 ` Athira Rajeev [this message]
2021-08-18 13:38 ` 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=3B701B8E-5C49-49A6-BAF7-246F42F7B0E7@linux.vnet.ibm.com \
    --to=atrajeev@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=npiggin@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).