From: Anton Blanchard <hidden> Date: 2012-06-26 11:00:13
We want to access the MMCRA_SIHV and MMCRA_SIPR bits elsewhere so
create mmcra_sihv and mmcra_sipr which hide the differences between
the old and new layout of the bits.
Signed-off-by: Anton Blanchard <redacted>
---
Index: linux-build/arch/powerpc/perf/core-book3s.c
===================================================================
@@ -128,8 +148,6 @@ static inline u32 perf_flags_from_msr(ststaticinlineu32perf_get_misc_flags(structpt_regs*regs){unsignedlongmmcra=regs->dsisr;-unsignedlongsihv=MMCRA_SIHV;-unsignedlongsipr=MMCRA_SIPR;/* Not a PMU interrupt: Make up flags from regs->msr */if(TRAP(regs)!=0xf00)
@@ -156,15 +174,10 @@ static inline u32 perf_get_misc_flags(streturnPERF_RECORD_MISC_USER;}-if(ppmu->flags&PPMU_ALT_SIPR){-sihv=POWER6_MMCRA_SIHV;-sipr=POWER6_MMCRA_SIPR;-}-/* PR has priority over HV, so order below is important */-if(mmcra&sipr)+if(mmcra_sipr(mmcra))returnPERF_RECORD_MISC_USER;-if((mmcra&sihv)&&(freeze_events_kernel!=MMCR0_FCHV))+if(mmcra_sihv(mmcra)&&(freeze_events_kernel!=MMCR0_FCHV))returnPERF_RECORD_MISC_HYPERVISOR;returnPERF_RECORD_MISC_KERNEL;}
From: Anton Blanchard <hidden> Date: 2012-06-26 11:01:36
The logic to choose whether to use the SIAR or get the information
out of pt_regs is going to get more complicated, so do it once in
perf_read_regs.
We overload regs->result which is gross but we are already doing it
with regs->dsisr.
Signed-off-by: Anton Blanchard <redacted>
---
Other architectures appear to be playing similar overloading tricks
so we should probably solve this in a nicer way.
Index: linux-build/arch/powerpc/include/asm/perf_event.h
===================================================================
@@ -148,17 +151,9 @@ static inline u32 perf_flags_from_msr(ststaticinlineu32perf_get_misc_flags(structpt_regs*regs){unsignedlongmmcra=regs->dsisr;+unsignedlonguse_siar=regs->result;-/* Not a PMU interrupt: Make up flags from regs->msr */-if(TRAP(regs)!=0xf00)-returnperf_flags_from_msr(regs);--/*-*Ifwedon'tsupportcontinuoussamplingandthis-*isnotamarkedevent,samedeal-*/-if((ppmu->flags&PPMU_NO_CONT_SAMPLING)&&-!(mmcra&MMCRA_SAMPLE_ENABLE))+if(!use_siar)returnperf_flags_from_msr(regs);/*
@@ -1342,18 +1351,12 @@ unsigned long perf_misc_flags(struct pt_*/unsignedlongperf_instruction_pointer(structpt_regs*regs){-unsignedlongmmcra=regs->dsisr;+unsignedlonguse_siar=regs->result;-/* Not a PMU interrupt */-if(TRAP(regs)!=0xf00)-returnregs->nip;--/* Processor doesn't support sampling non marked events */-if((ppmu->flags&PPMU_NO_CONT_SAMPLING)&&-!(mmcra&MMCRA_SAMPLE_ENABLE))+if(use_siar)+returnmfspr(SPRN_SIAR)+perf_ip_adjust(regs);+elsereturnregs->nip;--returnmfspr(SPRN_SIAR)+perf_ip_adjust(regs);}staticboolpmc_overflow(unsignedlongval)
From: Anton Blanchard <hidden> Date: 2012-06-26 11:02:15
At the moment we always use the SIAR if the PMU supports continuous
sampling. Unfortunately the SIAR and the PMU exception are not
synchronised for non marked events so we can end up with callchains
that dont make sense.
The following patch checks the HV and PR bits for samples coming from
userspace and always uses pt_regs for them. Userspace will never have
interrupts off so there is no real advantage to using the SIAR for
non marked events in userspace.
I had experimented with a patch that did a similar thing for kernel
samples but we lost a significant amount of information. I was
unable to profile any of our early exception code for example.
Signed-off-by: Anton Blanchard <redacted>
---
Index: linux-build/arch/powerpc/perf/core-book3s.c
===================================================================
From: Anton Blanchard <hidden> Date: 2012-06-26 11:04:20
We use SIAR or regs->nip for the instruction pointer depending on
the PMU configuration, but we always use regs->nip in the callchain.
Use perf_instruction_pointer so the backtrace is consistent.
Signed-off-by: Anton Blanchard <redacted>
---
Index: linux-build/arch/powerpc/perf/callchain.c
===================================================================
From: Scott Wood <hidden> Date: 2012-06-26 23:05:08
On 06/26/2012 06:04 AM, Anton Blanchard wrote:
quoted hunk
We use SIAR or regs->nip for the instruction pointer depending on
the PMU configuration, but we always use regs->nip in the callchain.
Use perf_instruction_pointer so the backtrace is consistent.
Signed-off-by: Anton Blanchard <redacted>
---
Index: linux-build/arch/powerpc/perf/callchain.c
===================================================================
From: Anton Blanchard <hidden> Date: 2012-06-27 03:59:28
Hi Scott,
Won't this break core-fsl-emb, which doesn't define
perf_instruction_pointer()?
It links ok for me. You should get the default version:
#ifndef perf_misc_flags
# define perf_misc_flags(regs) \
(user_mode(regs) ? PERF_RECORD_MISC_USER : PERF_RECORD_MISC_KERNEL)
# define perf_instruction_pointer(regs) instruction_pointer(regs)
#endif
Anton
From: Scott Wood <hidden> Date: 2012-06-27 15:03:57
On 06/26/2012 10:59 PM, Anton Blanchard wrote:
Hi Scott,
quoted
Won't this break core-fsl-emb, which doesn't define
perf_instruction_pointer()?
It links ok for me. You should get the default version:
#ifndef perf_misc_flags
# define perf_misc_flags(regs) \
(user_mode(regs) ? PERF_RECORD_MISC_USER : PERF_RECORD_MISC_KERNEL)
# define perf_instruction_pointer(regs) instruction_pointer(regs)
#endif
OK, sorry -- forgot to grep outside arch/powerpc. :-)
-Scott
On Tuesday 26 June 2012 04:30 PM, Anton Blanchard wrote:
We want to access the MMCRA_SIHV and MMCRA_SIPR bits elsewhere so
create mmcra_sihv and mmcra_sipr which hide the differences between
the old and new layout of the bits.
Hey Anton,
Going further in this direction, we can actually create wrapper functions
to capture SIHV and SIPR values whether they are based out of MMCRA register or
not. It would help us decide PERF_RECORD_MISC_USER | PERF_RECORD_MISC_HYPERVISOR
| PERF_RECORD_MISC_KERNEL hiding the register and related bit details.
quoted hunk
Signed-off-by: Anton Blanchard <redacted>
---
Index: linux-build/arch/powerpc/perf/core-book3s.c
===================================================================