Re: [REGRESSION][BISECT] perf/core: Remove pmu linear searching code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jun 05, 2023 at 12:14:01PM +0200, Peter Zijlstra wrote:
> On Mon, Jun 05, 2023 at 11:27:31AM +0200, Peter Zijlstra wrote:
> 
> > That said; given that this commit has been tagged twice now, I suppose I
> > should go revert it and we'll try again after a more thorough audit.
> 
> I'll go queue this then...
> 
> ---
> Subject: perf: Re-instate the linear PMU search
> From: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Date: Mon Jun  5 11:42:39 CEST 2023
> 
> Full revert of commit 9551fbb64d09 ("perf/core: Remove pmu linear
> searching code").
> 
> Some architectures (notably arm/arm64) still relied on the linear
> search in order to find the PMU that consumes
> PERF_TYPE_{HARDWARE,HW_CACHE,RAW}.
> 
> This will need a more thorought audit and clean.
> 
> Reported-by: Nathan Chancellor <nathan@xxxxxxxxxx>
> Reported-by: Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxx>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>

Acked-by: Mark Rutland <mark.rutland@xxxxxxx>

Thanks for sorting this out!

Mark.

> ---
>  kernel/events/core.c |   39 +++++++++++++++++++++++++--------------
>  1 file changed, 25 insertions(+), 14 deletions(-)
> 
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -11630,27 +11630,38 @@ static struct pmu *perf_init_event(struc
>  	}
>  
>  again:
> -	ret = -ENOENT;
>  	rcu_read_lock();
>  	pmu = idr_find(&pmu_idr, type);
>  	rcu_read_unlock();
> -	if (!pmu)
> -		goto fail;
> +	if (pmu) {
> +		if (event->attr.type != type && type != PERF_TYPE_RAW &&
> +		    !(pmu->capabilities & PERF_PMU_CAP_EXTENDED_HW_TYPE))
> +			goto fail;
> +
> +		ret = perf_try_init_event(pmu, event);
> +		if (ret == -ENOENT && event->attr.type != type && !extended_type) {
> +			type = event->attr.type;
> +			goto again;
> +		}
>  
> -	if (event->attr.type != type && type != PERF_TYPE_RAW &&
> -	    !(pmu->capabilities & PERF_PMU_CAP_EXTENDED_HW_TYPE))
> -		goto fail;
> -
> -	ret = perf_try_init_event(pmu, event);
> -	if (ret == -ENOENT && event->attr.type != type && !extended_type) {
> -		type = event->attr.type;
> -		goto again;
> +		if (ret)
> +			pmu = ERR_PTR(ret);
> +
> +		goto unlock;
>  	}
>  
> +	list_for_each_entry_rcu(pmu, &pmus, entry, lockdep_is_held(&pmus_srcu)) {
> +		ret = perf_try_init_event(pmu, event);
> +		if (!ret)
> +			goto unlock;
> +
> +		if (ret != -ENOENT) {
> +			pmu = ERR_PTR(ret);
> +			goto unlock;
> +		}
> +	}
>  fail:
> -	if (ret)
> -		pmu = ERR_PTR(ret);
> -
> +	pmu = ERR_PTR(-ENOENT);
>  unlock:
>  	srcu_read_unlock(&pmus_srcu, idx);
>  



[Index of Archives]     [Linux SoC Development]     [Linux Rockchip Development]     [Linux for Synopsys ARC Processors]    
  • [Linux on Unisoc (RDA Micro) SoCs]     [Linux Actions SoC]     [Linux USB Development]     [Video for Linux]     [Linux Audio Users]     [Linux SCSI]     [Yosemite News]

  •   Powered by Linux