[PATCH 5/5] powerpc/perf: use regs->nip when siar is zero

Christophe Leroy christophe.leroy at csgroup.eu
Wed Oct 21 20:13:39 AEDT 2020



Le 21/10/2020 à 10:53, Madhavan Srinivasan a écrit :
> In power10 DD1, there is an issue where the
> Sampled Instruction Address Register (SIAR)
> not latching to the sampled address during
> random sampling. This results in value of 0s
> in the SIAR. Patch adds a check to use regs->nip
> when SIAR is zero.

Why not use regs->nip at all time in that case, and not read SPRN_SIAR at all ?

Christophe


> 
> Signed-off-by: Madhavan Srinivasan <maddy at linux.ibm.com>
> ---
>   arch/powerpc/perf/core-book3s.c | 21 +++++++++++++++++----
>   1 file changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
> index e675c7c8ce0e..63de77eb0ac0 100644
> --- a/arch/powerpc/perf/core-book3s.c
> +++ b/arch/powerpc/perf/core-book3s.c
> @@ -263,9 +263,16 @@ static inline u32 perf_get_misc_flags(struct pt_regs *regs)
>   	 * DD1.
>   	 */
>   	if (marked && (ppmu->flags & PPMU_P10_DD1)) {
> -		if (is_kernel_addr(mfspr(SPRN_SIAR)))
> -			return PERF_RECORD_MISC_KERNEL;
> -		return PERF_RECORD_MISC_USER;
> +		unsigned long siar = mfspr(SPRN_SIAR);
> +		if (siar) {
> +			if (is_kernel_addr(siar))
> +				return PERF_RECORD_MISC_KERNEL;
> +			return PERF_RECORD_MISC_USER;
> +		} else {
> +			if (is_kernel_addr(regs->nip))
> +				return PERF_RECORD_MISC_KERNEL;
> +			return PERF_RECORD_MISC_USER;
> +		}
>   	}
>   
>   	/*
> @@ -2211,8 +2218,14 @@ unsigned long perf_misc_flags(struct pt_regs *regs)
>   unsigned long perf_instruction_pointer(struct pt_regs *regs)
>   {
>   	bool use_siar = regs_use_siar(regs);
> +	unsigned long siar = mfspr(SPRN_SIAR);
>   
> -	if (use_siar && siar_valid(regs))
> +	if (ppmu->flags & PPMU_P10_DD1) {
> +		if (siar)
> +			return siar;
> +		else
> +			return regs->nip;
> +	} else if (use_siar && siar_valid(regs))
>   		return mfspr(SPRN_SIAR) + perf_ip_adjust(regs);
>   	else if (use_siar)
>   		return 0;		// no valid instruction pointer
> 


More information about the Linuxppc-dev mailing list