[RFC PATCH powerpc] Set cpu sibling mask before online cpu

Srivatsa S. Bhat srivatsa.bhat at linux.vnet.ibm.com
Tue Jun 11 18:35:48 EST 2013


On 05/16/2013 03:50 PM, Li Zhong wrote:
> It seems following race is possible:
> 
> 	cpu0					cpux
> smp_init->cpu_up->_cpu_up
> 	__cpu_up
> 		kick_cpu(1)
> -------------------------------------------------------------------------
> 		waiting online			...
> 		...				notify CPU_STARTING
> 							set cpux active
> 						set cpux online
> -------------------------------------------------------------------------
> 		finish waiting online
> 		...
> sched_init_smp
> 	init_sched_domains(cpu_active_mask)
> 		build_sched_domains
> 						set cpux sibling info
> -------------------------------------------------------------------------
> 
[...]
> This patch tries to move the sibling maps updating before
> notify_cpu_starting() and cpu online, and a write barrier there to make
> sure sibling maps are updated before active and online mask. 
> 
> Signed-off-by: Li Zhong <zhong at linux.vnet.ibm.com>
> ---

Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat at linux.vnet.ibm.com>

Regards,
Srivatsa S. Bhat

>  arch/powerpc/kernel/smp.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
> index ee7ac5e..c765937 100644
> --- a/arch/powerpc/kernel/smp.c
> +++ b/arch/powerpc/kernel/smp.c
> @@ -637,12 +637,10 @@ __cpuinit void start_secondary(void *unused)
> 
>  	vdso_getcpu_init();
>  #endif
> -	notify_cpu_starting(cpu);
> -	set_cpu_online(cpu, true);
>  	/* Update sibling maps */
>  	base = cpu_first_thread_sibling(cpu);
>  	for (i = 0; i < threads_per_core; i++) {
> -		if (cpu_is_offline(base + i))
> +		if (cpu_is_offline(base + i) && (cpu != base + i))
>  			continue;
>  		cpumask_set_cpu(cpu, cpu_sibling_mask(base + i));
>  		cpumask_set_cpu(base + i, cpu_sibling_mask(cpu));
> @@ -667,6 +665,10 @@ __cpuinit void start_secondary(void *unused)
>  	}
>  	of_node_put(l2_cache);
> 
> +	smp_wmb();
> +	notify_cpu_starting(cpu);
> +	set_cpu_online(cpu, true);
> +
>  	local_irq_enable();
> 
>  	cpu_startup_entry(CPUHP_ONLINE);
> 
> 
> 



More information about the Linuxppc-dev mailing list