Subject: Re: [PATCH 08/11] powerpc/smp: Allocate cpumask only after searching thread group

From: Gautham R Shenoy <[email-masked]>
Date: Fri, 17 Jul 2020 13:38:54 +0530

On Tue, Jul 14, 2020 at 10:06:21AM +0530, Srikar Dronamraju wrote:
> If allocated earlier and the search fails, then cpumask need to be
> freed. However cpu_l1_cache_map can be allocated after we search thread
> group.
> 
> Cc: linuxppc-dev <[email-masked]>
> Cc: Michael Ellerman <[email-masked]>
> Cc: Nick Piggin <[email-masked]>
> Cc: Oliver OHalloran <[email-masked]>
> Cc: Nathan Lynch <[email-masked]>
> Cc: Michael Neuling <[email-masked]>
> Cc: Anton Blanchard <[email-masked]>
> Cc: Gautham R Shenoy <[email-masked]>
> Cc: Vaidyanathan Srinivasan <[email-masked]>
> Signed-off-by: Srikar Dronamraju <[email-masked]>

Good fix.

Reviewed-by: Gautham R. Shenoy <[email-masked]>

> ---
>  arch/powerpc/kernel/smp.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
> index 96e47450d9b3..ef19eeccd21e 100644
> --- a/arch/powerpc/kernel/smp.c
> +++ b/arch/powerpc/kernel/smp.c
> @@ -797,10 +797,6 @@ static int init_cpu_l1_cache_map(int cpu)
>  	if (err)
>  		goto out;
> 
> -	zalloc_cpumask_var_node(&per_cpu(cpu_l1_cache_map, cpu),
> -				GFP_KERNEL,
> -				cpu_to_node(cpu));
> -
>  	cpu_group_start = get_cpu_thread_group_start(cpu, &tg);
> 
>  	if (unlikely(cpu_group_start == -1)) {
> @@ -809,6 +805,9 @@ static int init_cpu_l1_cache_map(int cpu)
>  		goto out;
>  	}
> 
> +	zalloc_cpumask_var_node(&per_cpu(cpu_l1_cache_map, cpu),
> +				GFP_KERNEL, cpu_to_node(cpu));
> +
>  	for (i = first_thread; i < first_thread + threads_per_core; i++) {
>  		int i_group_start = get_cpu_thread_group_start(i, &tg);
> 
> -- 
> 2.17.1
>