linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
To: Li Zhong <zhong@linux.vnet.ibm.com>
Cc: Paul Mackerras <paulus@samba.org>,
	PowerPC email list <linuxppc-dev@lists.ozlabs.org>
Subject: Re: [RFC PATCH powerpc] Set cpu sibling mask before online cpu
Date: Tue, 11 Jun 2013 14:05:48 +0530	[thread overview]
Message-ID: <51B6E164.4050603@linux.vnet.ibm.com> (raw)
In-Reply-To: <1368699626.2618.183.camel@ThinkPad-T5421>

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@linux.vnet.ibm.com>
> ---

Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@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);
> 
> 
> 

      parent reply	other threads:[~2013-06-11  8:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-16 10:20 [RFC PATCH powerpc] Set cpu sibling mask before online cpu Li Zhong
2013-06-11  7:00 ` Benjamin Herrenschmidt
2013-06-11  8:33   ` Srivatsa S. Bhat
2013-06-11  9:03     ` Benjamin Herrenschmidt
2013-06-13  9:42     ` Li Zhong
2013-06-11  8:35 ` Srivatsa S. Bhat [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51B6E164.4050603@linux.vnet.ibm.com \
    --to=srivatsa.bhat@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.org \
    --cc=zhong@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).