Patchwork [RFC,09/10] POWERPC: smp: remove call to ipi_call_lock()/ipi_call_unlock()

login
register
mail settings
Submitter Yong Zhang
Date May 29, 2012, 7:16 a.m.
Message ID <1338275765-3217-10-git-send-email-yong.zhang0@gmail.com>
Download mbox | patch
Permalink /patch/161661/
State Accepted
Commit e250d4bca6cb91471e0757179a152c0943ecce4a
Delegated to: Michael Ellerman
Headers show

Comments

Yong Zhang - May 29, 2012, 7:16 a.m.
From: Yong Zhang <yong.zhang@windriver.com>

1) call_function.lock used in smp_call_function_many() is just to protect
   call_function.queue and &data->refs, cpu_online_mask is outside of the
   lock. And it's not necessary to protect cpu_online_mask,
   because data->cpumask is pre-calculate and even if a cpu is brougt up
   when calling arch_send_call_function_ipi_mask(), it's harmless because
   validation test in generic_smp_call_function_interrupt() will take care
   of it.

2) For cpu down issue, stop_machine() will guarantee that no concurrent
   smp_call_fuction() is processing.

Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
---
 arch/powerpc/kernel/smp.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
Paul E. McKenney - June 16, 2012, 4:32 p.m.
On Tue, May 29, 2012 at 03:16:04PM +0800, Yong Zhang wrote:
> From: Yong Zhang <yong.zhang@windriver.com>
> 
> 1) call_function.lock used in smp_call_function_many() is just to protect
>    call_function.queue and &data->refs, cpu_online_mask is outside of the
>    lock. And it's not necessary to protect cpu_online_mask,
>    because data->cpumask is pre-calculate and even if a cpu is brougt up
>    when calling arch_send_call_function_ipi_mask(), it's harmless because
>    validation test in generic_smp_call_function_interrupt() will take care
>    of it.
> 
> 2) For cpu down issue, stop_machine() will guarantee that no concurrent
>    smp_call_fuction() is processing.

However, there is an effort to get rid of stop_machine() from the
CPU-down path...  So something else will be needed.

							Thanx, Paul

> Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: linuxppc-dev@lists.ozlabs.org
> ---
>  arch/powerpc/kernel/smp.c |    2 --
>  1 files changed, 0 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
> index e4cb343..e1417c4 100644
> --- a/arch/powerpc/kernel/smp.c
> +++ b/arch/powerpc/kernel/smp.c
> @@ -571,7 +571,6 @@ void __devinit start_secondary(void *unused)
>  	if (system_state == SYSTEM_RUNNING)
>  		vdso_data->processorCount++;
>  #endif
> -	ipi_call_lock();
>  	notify_cpu_starting(cpu);
>  	set_cpu_online(cpu, true);
>  	/* Update sibling maps */
> @@ -601,7 +600,6 @@ void __devinit start_secondary(void *unused)
>  		of_node_put(np);
>  	}
>  	of_node_put(l2_cache);
> -	ipi_call_unlock();
> 
>  	local_irq_enable();
> 
> -- 
> 1.7.5.4
>
Peter Zijlstra - June 16, 2012, 5:30 p.m.
On Sat, 2012-06-16 at 09:32 -0700, Paul E. McKenney wrote:
> However, there is an effort to get rid of stop_machine() from the
> CPU-down path...  So something else will be needed. 

Elsewhere in this thread I mentioned we could do a synchronize_sched().
I think that covers most of what stop-machine is doing these days.
Paul E. McKenney - June 16, 2012, 8:57 p.m.
On Sat, Jun 16, 2012 at 07:30:58PM +0200, Peter Zijlstra wrote:
> On Sat, 2012-06-16 at 09:32 -0700, Paul E. McKenney wrote:
> > However, there is an effort to get rid of stop_machine() from the
> > CPU-down path...  So something else will be needed. 
> 
> Elsewhere in this thread I mentioned we could do a synchronize_sched().
> I think that covers most of what stop-machine is doing these days.

Ah, apologies for the noise!

							Thanx, Paul
Yong Zhang - June 18, 2012, 2:51 a.m.
On Sat, Jun 16, 2012 at 09:32:19AM -0700, Paul E. McKenney wrote:
> On Tue, May 29, 2012 at 03:16:04PM +0800, Yong Zhang wrote:
> > From: Yong Zhang <yong.zhang@windriver.com>
> > 
> > 1) call_function.lock used in smp_call_function_many() is just to protect
> >    call_function.queue and &data->refs, cpu_online_mask is outside of the
> >    lock. And it's not necessary to protect cpu_online_mask,
> >    because data->cpumask is pre-calculate and even if a cpu is brougt up
> >    when calling arch_send_call_function_ipi_mask(), it's harmless because
> >    validation test in generic_smp_call_function_interrupt() will take care
> >    of it.
> > 
> > 2) For cpu down issue, stop_machine() will guarantee that no concurrent
> >    smp_call_fuction() is processing.
> 
> However, there is an effort to get rid of stop_machine() from the
> CPU-down path...  So something else will be needed.

Yeah. So Thomas changed the commit log like below:
[
    ipi_call_lock/unlock() lock resp. unlock call_function.lock. This lock
    protects only the call_function data structure itself, but it's
    completely unrelated to cpu_online_mask. The mask to which the IPIs
    are sent is calculated before call_function.lock is taken in
    smp_call_function_many(), so the locking around set_cpu_online() is
    pointless and can be removed.
    
    [ tglx: Massaged changelog ]
]

in tip/smp/hotplug.

Thanks,
Yong

> 
> 							Thanx, Paul
> 
> > Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
> > Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> > Cc: Paul Mackerras <paulus@samba.org>
> > Cc: linuxppc-dev@lists.ozlabs.org
> > ---
> >  arch/powerpc/kernel/smp.c |    2 --
> >  1 files changed, 0 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
> > index e4cb343..e1417c4 100644
> > --- a/arch/powerpc/kernel/smp.c
> > +++ b/arch/powerpc/kernel/smp.c
> > @@ -571,7 +571,6 @@ void __devinit start_secondary(void *unused)
> >  	if (system_state == SYSTEM_RUNNING)
> >  		vdso_data->processorCount++;
> >  #endif
> > -	ipi_call_lock();
> >  	notify_cpu_starting(cpu);
> >  	set_cpu_online(cpu, true);
> >  	/* Update sibling maps */
> > @@ -601,7 +600,6 @@ void __devinit start_secondary(void *unused)
> >  		of_node_put(np);
> >  	}
> >  	of_node_put(l2_cache);
> > -	ipi_call_unlock();
> > 
> >  	local_irq_enable();
> > 
> > -- 
> > 1.7.5.4
> > 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
Paul E. McKenney - June 18, 2012, 5:05 p.m.
On Mon, Jun 18, 2012 at 10:51:59AM +0800, Yong Zhang wrote:
> On Sat, Jun 16, 2012 at 09:32:19AM -0700, Paul E. McKenney wrote:
> > On Tue, May 29, 2012 at 03:16:04PM +0800, Yong Zhang wrote:
> > > From: Yong Zhang <yong.zhang@windriver.com>
> > > 
> > > 1) call_function.lock used in smp_call_function_many() is just to protect
> > >    call_function.queue and &data->refs, cpu_online_mask is outside of the
> > >    lock. And it's not necessary to protect cpu_online_mask,
> > >    because data->cpumask is pre-calculate and even if a cpu is brougt up
> > >    when calling arch_send_call_function_ipi_mask(), it's harmless because
> > >    validation test in generic_smp_call_function_interrupt() will take care
> > >    of it.
> > > 
> > > 2) For cpu down issue, stop_machine() will guarantee that no concurrent
> > >    smp_call_fuction() is processing.
> > 
> > However, there is an effort to get rid of stop_machine() from the
> > CPU-down path...  So something else will be needed.
> 
> Yeah. So Thomas changed the commit log like below:
> [
>     ipi_call_lock/unlock() lock resp. unlock call_function.lock. This lock
>     protects only the call_function data structure itself, but it's
>     completely unrelated to cpu_online_mask. The mask to which the IPIs
>     are sent is calculated before call_function.lock is taken in
>     smp_call_function_many(), so the locking around set_cpu_online() is
>     pointless and can be removed.
>     
>     [ tglx: Massaged changelog ]
> ]
> 
> in tip/smp/hotplug.

Got it, thank you!

							Thanx, Paul

> Thanks,
> Yong
> 
> > 
> > 							Thanx, Paul
> > 
> > > Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
> > > Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> > > Cc: Paul Mackerras <paulus@samba.org>
> > > Cc: linuxppc-dev@lists.ozlabs.org
> > > ---
> > >  arch/powerpc/kernel/smp.c |    2 --
> > >  1 files changed, 0 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
> > > index e4cb343..e1417c4 100644
> > > --- a/arch/powerpc/kernel/smp.c
> > > +++ b/arch/powerpc/kernel/smp.c
> > > @@ -571,7 +571,6 @@ void __devinit start_secondary(void *unused)
> > >  	if (system_state == SYSTEM_RUNNING)
> > >  		vdso_data->processorCount++;
> > >  #endif
> > > -	ipi_call_lock();
> > >  	notify_cpu_starting(cpu);
> > >  	set_cpu_online(cpu, true);
> > >  	/* Update sibling maps */
> > > @@ -601,7 +600,6 @@ void __devinit start_secondary(void *unused)
> > >  		of_node_put(np);
> > >  	}
> > >  	of_node_put(l2_cache);
> > > -	ipi_call_unlock();
> > > 
> > >  	local_irq_enable();
> > > 
> > > -- 
> > > 1.7.5.4
> > > 
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at  http://www.tux.org/lkml/
> 
> -- 
> Only stand for myself
>

Patch

diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index e4cb343..e1417c4 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -571,7 +571,6 @@  void __devinit start_secondary(void *unused)
 	if (system_state == SYSTEM_RUNNING)
 		vdso_data->processorCount++;
 #endif
-	ipi_call_lock();
 	notify_cpu_starting(cpu);
 	set_cpu_online(cpu, true);
 	/* Update sibling maps */
@@ -601,7 +600,6 @@  void __devinit start_secondary(void *unused)
 		of_node_put(np);
 	}
 	of_node_put(l2_cache);
-	ipi_call_unlock();
 
 	local_irq_enable();