[3/5] powerpc/perf: Replace last usage of get_cpu_var with this_cpu_ptr

Michael Ellerman mpe at ellerman.id.au
Mon Jul 27 15:15:30 AEST 2015


On Tue, 2015-30-06 at 08:20:29 UTC, Anshuman Khandual wrote:
> The commit 69111bac42f5ce ("powerpc: Replace __get_cpu_var uses")
> replaced all usage of get_cpu_var with this_cpu_ptr inside core
> perf event handling on powerpc. But it skipped one of them which
> is being replaced with this patch.

No it replaced all uses of __get_cpu_var(), not get_cpu_var(). The difference
is important.

get_cpu_var() disables preemption for you, so it's only safe to switch to
this_cpu_ptr() if preemption is already disabled. Is it?

cheers

> diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
> index f9ecd93..57f2c78 100644
> --- a/arch/powerpc/perf/core-book3s.c
> +++ b/arch/powerpc/perf/core-book3s.c
> @@ -1840,20 +1840,17 @@ static int power_pmu_event_init(struct perf_event *event)
>  	if (check_excludes(ctrs, cflags, n, 1))
>  		return -EINVAL;
>  
> -	cpuhw = &get_cpu_var(cpu_hw_events);
> +	cpuhw = this_cpu_ptr(&cpu_hw_events);
>  	err = power_check_constraints(cpuhw, events, cflags, n + 1);
>  
>  	if (has_branch_stack(event)) {
>  		cpuhw->bhrb_filter = ppmu->bhrb_filter_map(
>  					event->attr.branch_sample_type);
>  
> -		if (cpuhw->bhrb_filter == -1) {
> -			put_cpu_var(cpu_hw_events);
> +		if (cpuhw->bhrb_filter == -1)
>  			return -EOPNOTSUPP;
> -		}
>  	}
>  
> -	put_cpu_var(cpu_hw_events);
>  	if (err)
>  		return -EINVAL;


More information about the Linuxppc-dev mailing list