Thread (16 messages) flat view 16 messages, 4 authors, 2021-08-17

Re: [PATCH v2 2/2] powerpc/perf: Return regs->nip as instruction pointer value when SIAR is 0

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2021-08-17 12:50:05

Christophe Leroy [off-list ref] writes:
Le 16/08/2021 à 08:44, kajoljain a écrit :
quoted
On 8/14/21 6:14 PM, Michael Ellerman wrote:
...
quoted
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help