All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman.id.au>
To: Christophe Leroy <christophe.leroy@csgroup.eu>,
	kajoljain <kjain@linux.ibm.com>,
	linuxppc-dev@lists.ozlabs.org
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>,
	atrajeev@linux.vnet.ibm.com, maddy@linux.ibm.com,
	rnsastry@linux.ibm.com
Subject: Re: [PATCH v2 2/2] powerpc/perf: Return regs->nip as instruction pointer value when SIAR is 0
Date: Tue, 17 Aug 2021 22:49:22 +1000	[thread overview]
Message-ID: <871r6sgrsd.fsf@mpe.ellerman.id.au> (raw)
In-Reply-To: <3a34c79d-b800-1a11-7a4b-1fb3babb9df1@csgroup.eu>

Christophe Leroy <christophe.leroy@csgroup.eu> writes:
> Le 16/08/2021 à 08:44, kajoljain a écrit :
>> On 8/14/21 6:14 PM, Michael Ellerman wrote:
...
>>>
>>> eg.
>>>
>>> 	if (use_siar && siar_valid(regs) && siar)
>>> 		return siar + perf_ip_adjust(regs);
>>> 	else if (use_siar)
>>> 		return 0;		// no valid instruction pointer
>>> 	else
>>> 		return regs->nip;
>>>
>>>
>>> I'm also not sure why we have that return 0 case, I can't think of why
>>> we'd ever want to do that rather than using nip. So maybe we should do
>>> another patch to drop that case.
>> 
>> Yeah make sense. I will remove return 0 case in my next version.
>
> This was added by commit 
> https://github.com/linuxppc/linux/commit/e6878835ac4794f25385522d29c634b7bbb7cca9
>
> Are we sure it was an error to add it and it can be removed ?

I think so.

That commit added siar_valid(), and updated record_and_restart() to only
record if siar_valid() returned true.

  -                        record = 1;
  +                        record = siar_valid(regs);

It then also changed perf_instruction_pointer():

  -        if (use_siar)
  +        if (use_siar && siar_valid(regs))
                   return mfspr(SPRN_SIAR) + perf_ip_adjust(regs);
  +        else if (use_siar)
  +                return 0;                // no valid instruction pointer
           else
                   return regs->nip;


The first change means we would never even call
perf_instruction_pointer() if siar_valid() is false, so we could never
hit the use_siar && !siar_valid() case.

But even so it's always preferable to use regs->nip than 0, even if nip
is somewhat skewed due to interrupts being disabled etc.

cheers

  parent reply	other threads:[~2021-08-17 12:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13  8:24 [PATCH v2 1/2] powerpc/perf: Use stack siar instead of mfspr Kajol Jain
2021-08-13  8:24 ` [PATCH v2 2/2] powerpc/perf: Return regs->nip as instruction pointer value when SIAR is 0 Kajol Jain
2021-08-13  9:29   ` Christophe Leroy
2021-08-14 12:25     ` Michael Ellerman
2021-08-13  9:34   ` Christophe Leroy
2021-08-14 12:44     ` Michael Ellerman
2021-08-16  6:44       ` kajoljain
2021-08-16  6:56         ` Christophe Leroy
2021-08-17  5:37           ` Madhavan Srinivasan
2021-08-17  8:29             ` kajoljain
2021-08-17 12:49           ` Michael Ellerman [this message]
2021-08-16  6:46     ` kajoljain
2021-08-13  8:29 ` [PATCH v2 1/2] powerpc/perf: Use stack siar instead of mfspr kajoljain
2021-08-13  9:23   ` Christophe Leroy
2021-08-14 12:30     ` Michael Ellerman
2021-08-16  5:58       ` kajoljain

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=871r6sgrsd.fsf@mpe.ellerman.id.au \
    --to=mpe@ellerman.id.au \
    --cc=atrajeev@linux.vnet.ibm.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=kjain@linux.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=rnsastry@linux.ibm.com \
    --cc=sukadev@linux.vnet.ibm.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 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.