Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1344561 > unrolled thread

[patch 00/20] cpu/hotplug: Core infrastructure for cpu hotplug rework

Started byThomas Gleixner <tglx@linutronix.de>
First post2016-02-26 19:50 +0100
Last post2016-02-29 21:10 +0100
Articles 15 on this page of 55 — 8 participants

Back to article view | Back to linux.kernel


Contents

  [patch 00/20] cpu/hotplug: Core infrastructure for cpu hotplug rework Thomas Gleixner <tglx@linutronix.de> - 2016-02-26 19:50 +0100
    [patch 14/20] cpu/hotplug: Split out the state walk into functions Thomas Gleixner <tglx@linutronix.de> - 2016-02-26 19:50 +0100
      [tip:smp/hotplug] cpu/hotplug: Split out the state walk into  functions tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2016-03-01 21:00 +0100
    [patch 17/20] arch/hotplug: Call into idle with a proper state Thomas Gleixner <tglx@linutronix.de> - 2016-02-26 19:50 +0100
      [tip:smp/hotplug] arch/hotplug: Call into idle with a proper state tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2016-03-01 21:00 +0100
    [patch 04/20] cpu/hotplug: Split out cpu down functions Thomas Gleixner <tglx@linutronix.de> - 2016-02-26 19:50 +0100
      [tip:smp/hotplug] cpu/hotplug: Split out cpu down functions tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2016-03-01 21:00 +0100
        Re: [tip:smp/hotplug] cpu/hotplug: Split out cpu down functions "Srivatsa S. Bhat" <srivatsa@csail.mit.edu> - 2016-03-03 00:10 +0100
    [patch 03/20] cpu/hotplug: Restructure cpu_up code Thomas Gleixner <tglx@linutronix.de> - 2016-02-26 19:50 +0100
      [tip:smp/hotplug] cpu/hotplug: Restructure cpu_up code tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2016-03-01 21:00 +0100
        Re: [tip:smp/hotplug] cpu/hotplug: Restructure cpu_up code "Srivatsa S. Bhat" <srivatsa@csail.mit.edu> - 2016-03-03 00:00 +0100
    [patch 16/20] cpu/hotplug: Move online calls to hotplugged cpu Thomas Gleixner <tglx@linutronix.de> - 2016-02-26 19:50 +0100
      [tip:smp/hotplug] cpu/hotplug: Move online calls to hotplugged cpu tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2016-03-01 21:00 +0100
    [patch 02/20] cpu/hotplug: Restructure FROZEN state handling Thomas Gleixner <tglx@linutronix.de> - 2016-02-26 19:50 +0100
      [tip:smp/hotplug] cpu/hotplug: Restructure FROZEN state handling tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2016-03-01 21:00 +0100
        Re: [tip:smp/hotplug] cpu/hotplug: Restructure FROZEN state handling "Srivatsa S. Bhat" <srivatsa@csail.mit.edu> - 2016-03-03 00:10 +0100
        Re: [tip:smp/hotplug] cpu/hotplug: Restructure FROZEN state handling "Srivatsa S. Bhat" <srivatsa@csail.mit.edu> - 2016-03-03 00:50 +0100
    [patch 11/20] cpu/hotplug: Implement setup/removal interface Thomas Gleixner <tglx@linutronix.de> - 2016-02-26 19:50 +0100
      [tip:smp/hotplug] cpu/hotplug: Implement setup/removal interface tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2016-03-01 21:00 +0100
    [patch 12/20] cpu/hotplug: Move scheduler cpu_online notifier to  hotplug core Thomas Gleixner <tglx@linutronix.de> - 2016-02-26 19:50 +0100
      [tip:smp/hotplug] cpu/hotplug: Move scheduler cpu_online notifier  to hotplug core tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2016-03-01 21:00 +0100
    [patch 18/20] cpu/hotplug: Let upcoming cpu bring itself fully up Thomas Gleixner <tglx@linutronix.de> - 2016-02-26 19:50 +0100
      [tip:smp/hotplug] cpu/hotplug: Let upcoming cpu bring itself fully  up tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2016-03-01 21:00 +0100
      Re: [patch 18/20] cpu/hotplug: Let upcoming cpu bring itself fully up Richard Cochran <richardcochran@gmail.com> - 2016-03-02 18:30 +0100
    [patch 15/20] cpu/hotplug: Create hotplug threads Thomas Gleixner <tglx@linutronix.de> - 2016-02-26 19:50 +0100
      [tip:smp/hotplug] cpu/hotplug: Create hotplug threads tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2016-03-01 21:00 +0100
    [patch 09/20] cpu/hotplug: Add sysfs state interface Thomas Gleixner <tglx@linutronix.de> - 2016-02-26 19:50 +0100
      [tip:smp/hotplug] cpu/hotplug: Add sysfs state interface tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2016-03-01 21:00 +0100
        Re: [tip:smp/hotplug] cpu/hotplug: Add sysfs state interface Peter Zijlstra <peterz@infradead.org> - 2016-03-02 13:50 +0100
    [patch 06/20] cpu/hotplug: Convert to a state machine for the control  processor Thomas Gleixner <tglx@linutronix.de> - 2016-02-26 19:50 +0100
      [tip:smp/hotplug] cpu/hotplug: Convert to a state machine for the  control processor tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2016-03-01 21:00 +0100
        Re: [tip:smp/hotplug] cpu/hotplug: Convert to a state machine for  the control processor Peter Zijlstra <peterz@infradead.org> - 2016-03-02 12:30 +0100
    [patch 20/20] rcu: Make CPU_DYING_IDLE an explicit call Thomas Gleixner <tglx@linutronix.de> - 2016-02-26 19:50 +0100
      Re: [patch 20/20] rcu: Make CPU_DYING_IDLE an explicit call "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-02-27 03:20 +0100
        Re: [patch 20/20] rcu: Make CPU_DYING_IDLE an explicit call "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-02-27 03:30 +0100
          Re: [patch 20/20] rcu: Make CPU_DYING_IDLE an explicit call Thomas Gleixner <tglx@linutronix.de> - 2016-02-27 08:50 +0100
            Re: [patch 20/20] rcu: Make CPU_DYING_IDLE an explicit call "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-02-27 12:10 +0100
              Re: [patch 20/20] rcu: Make CPU_DYING_IDLE an explicit call Thomas Gleixner <tglx@linutronix.de> - 2016-02-27 12:40 +0100
                Re: [patch 20/20] rcu: Make CPU_DYING_IDLE an explicit call "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-02-27 17:40 +0100
      [tip:smp/hotplug] rcu: Make CPU_DYING_IDLE an explicit call tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2016-03-01 21:00 +0100
        Re: [tip:smp/hotplug] rcu: Make CPU_DYING_IDLE an explicit call "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-03-02 21:20 +0100
          Re: [tip:smp/hotplug] rcu: Make CPU_DYING_IDLE an explicit call Thomas Gleixner <tglx@linutronix.de> - 2016-03-03 08:40 +0100
          [tip:smp/hotplug] cpu/hotplug: Plug death reporting race tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2016-03-03 11:10 +0100
            Re: [tip:smp/hotplug] cpu/hotplug: Plug death reporting race "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-03-03 15:20 +0100
    [patch 08/20] cpu/hotplug: Hand in target state to _cpu_up/down Thomas Gleixner <tglx@linutronix.de> - 2016-02-26 19:50 +0100
      [tip:smp/hotplug] cpu/hotplug: Hand in target state to _cpu_up/down tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2016-03-01 21:00 +0100
    [patch 19/20] cpu/hotplug: Make wait for dead cpu completion based Thomas Gleixner <tglx@linutronix.de> - 2016-02-26 19:50 +0100
      [tip:smp/hotplug] cpu/hotplug: Make wait for dead cpu completion  based tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2016-03-01 21:00 +0100
    [patch 07/20] cpu/hotplug: Convert the hotplugged cpu work to a state  machine Thomas Gleixner <tglx@linutronix.de> - 2016-02-26 20:00 +0100
      [tip:smp/hotplug] cpu/hotplug: Convert the hotplugged cpu work to a  state machine tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2016-03-01 21:00 +0100
    [patch 01/20] idle: Move x86ism out of generic code Thomas Gleixner <tglx@linutronix.de> - 2016-02-26 20:00 +0100
      Re: [patch 01/20] idle: Move x86ism out of generic code Brian Gerst <brgerst@gmail.com> - 2016-02-27 21:30 +0100
        Re: [patch 01/20] idle: Move x86ism out of generic code Thomas Gleixner <tglx@linutronix.de> - 2016-02-29 20:40 +0100
          Re: [patch 01/20] idle: Move x86ism out of generic code Will Deacon <will.deacon@arm.com> - 2016-02-29 20:50 +0100
            Re: [patch 01/20] idle: Move x86ism out of generic code Thomas Gleixner <tglx@linutronix.de> - 2016-02-29 21:10 +0100

Page 3 of 3 — ← Prev page 1 2 [3]


#1348454 — Re: [tip:smp/hotplug] rcu: Make CPU_DYING_IDLE an explicit call

From"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Date2016-03-02 21:20 +0100
SubjectRe: [tip:smp/hotplug] rcu: Make CPU_DYING_IDLE an explicit call
Message-ID<r8lpx-4I9-15@gated-at.bofh.it>
In reply to#1346989
On Tue, Mar 01, 2016 at 11:58:59AM -0800, tip-bot for Thomas Gleixner wrote:
> Commit-ID:  27d50c7eeb0f03c3d3ca72aac4d2dd487ca1f3f0
> Gitweb:     http://git.kernel.org/tip/27d50c7eeb0f03c3d3ca72aac4d2dd487ca1f3f0
> Author:     Thomas Gleixner <tglx@linutronix.de>
> AuthorDate: Fri, 26 Feb 2016 18:43:44 +0000
> Committer:  Thomas Gleixner <tglx@linutronix.de>
> CommitDate: Tue, 1 Mar 2016 20:36:58 +0100
> 
> rcu: Make CPU_DYING_IDLE an explicit call
> 
> Make the RCU CPU_DYING_IDLE callback an explicit function call, so it gets
> invoked at the proper place.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: linux-arch@vger.kernel.org
> Cc: Rik van Riel <riel@redhat.com>
> Cc: Rafael Wysocki <rafael.j.wysocki@intel.com>
> Cc: "Srivatsa S. Bhat" <srivatsa@mit.edu>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Arjan van de Ven <arjan@linux.intel.com>
> Cc: Sebastian Siewior <bigeasy@linutronix.de>
> Cc: Rusty Russell <rusty@rustcorp.com.au>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Oleg Nesterov <oleg@redhat.com>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Paul Turner <pjt@google.com>
> Link: http://lkml.kernel.org/r/20160226182341.870167933@linutronix.de
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

[ . . . ]

> diff --git a/kernel/cpu.c b/kernel/cpu.c
> index 0e8c07f..ff8059b 100644
> --- a/kernel/cpu.c
> +++ b/kernel/cpu.c
> @@ -762,6 +762,7 @@ void cpuhp_report_idle_dead(void)
>  	BUG_ON(st->state != CPUHP_AP_OFFLINE);
>  	st->state = CPUHP_AP_IDLE_DEAD;
>  	complete(&st->done);

Not to be repetitive or anything, but if we delay here, it can break
RCU on a number of architectures.  Either the CPU can be killed holding
one of RCU's locks or RCU can wrongly see the CPU as still being alive.
Either can prevent future RCU grace periods from ever completing, thus
OOMing the system.

							Thanx, Paul

> +	rcu_report_dead(smp_processor_id());
>  }
> 
>  #else
> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> index e41dd41..85b4134 100644
> --- a/kernel/rcu/tree.c
> +++ b/kernel/rcu/tree.c
> @@ -2607,28 +2607,6 @@ static void rcu_cleanup_dead_rnp(struct rcu_node *rnp_leaf)
>  }
> 
>  /*
> - * The CPU is exiting the idle loop into the arch_cpu_idle_dead()
> - * function.  We now remove it from the rcu_node tree's ->qsmaskinit
> - * bit masks.
> - */
> -static void rcu_cleanup_dying_idle_cpu(int cpu, struct rcu_state *rsp)
> -{
> -	unsigned long flags;
> -	unsigned long mask;
> -	struct rcu_data *rdp = per_cpu_ptr(rsp->rda, cpu);
> -	struct rcu_node *rnp = rdp->mynode;  /* Outgoing CPU's rdp & rnp. */
> -
> -	if (!IS_ENABLED(CONFIG_HOTPLUG_CPU))
> -		return;
> -
> -	/* Remove outgoing CPU from mask in the leaf rcu_node structure. */
> -	mask = rdp->grpmask;
> -	raw_spin_lock_irqsave_rcu_node(rnp, flags); /* Enforce GP memory-order guarantee. */
> -	rnp->qsmaskinitnext &= ~mask;
> -	raw_spin_unlock_irqrestore(&rnp->lock, flags);
> -}
> -
> -/*
>   * The CPU has been completely removed, and some other CPU is reporting
>   * this fact from process context.  Do the remainder of the cleanup,
>   * including orphaning the outgoing CPU's RCU callbacks, and also
> @@ -4247,6 +4225,43 @@ static void rcu_prepare_cpu(int cpu)
>  		rcu_init_percpu_data(cpu, rsp);
>  }
> 
> +#ifdef CONFIG_HOTPLUG_CPU
> +/*
> + * The CPU is exiting the idle loop into the arch_cpu_idle_dead()
> + * function.  We now remove it from the rcu_node tree's ->qsmaskinit
> + * bit masks.
> + */
> +static void rcu_cleanup_dying_idle_cpu(int cpu, struct rcu_state *rsp)
> +{
> +	unsigned long flags;
> +	unsigned long mask;
> +	struct rcu_data *rdp = per_cpu_ptr(rsp->rda, cpu);
> +	struct rcu_node *rnp = rdp->mynode;  /* Outgoing CPU's rdp & rnp. */
> +
> +	if (!IS_ENABLED(CONFIG_HOTPLUG_CPU))
> +		return;
> +
> +	/* Remove outgoing CPU from mask in the leaf rcu_node structure. */
> +	mask = rdp->grpmask;
> +	raw_spin_lock_irqsave_rcu_node(rnp, flags); /* Enforce GP memory-order guarantee. */
> +	rnp->qsmaskinitnext &= ~mask;
> +	raw_spin_unlock_irqrestore(&rnp->lock, flags);
> +}
> +
> +void rcu_report_dead(unsigned int cpu)
> +{
> +	struct rcu_state *rsp;
> +
> +	/* QS for any half-done expedited RCU-sched GP. */
> +	preempt_disable();
> +	rcu_report_exp_rdp(&rcu_sched_state,
> +			   this_cpu_ptr(rcu_sched_state.rda), true);
> +	preempt_enable();
> +	for_each_rcu_flavor(rsp)
> +		rcu_cleanup_dying_idle_cpu(cpu, rsp);
> +}
> +#endif
> +
>  /*
>   * Handle CPU online/offline notification events.
>   */
> @@ -4278,17 +4293,6 @@ int rcu_cpu_notify(struct notifier_block *self,
>  		for_each_rcu_flavor(rsp)
>  			rcu_cleanup_dying_cpu(rsp);
>  		break;
> -	case CPU_DYING_IDLE:
> -		/* QS for any half-done expedited RCU-sched GP. */
> -		preempt_disable();
> -		rcu_report_exp_rdp(&rcu_sched_state,
> -				   this_cpu_ptr(rcu_sched_state.rda), true);
> -		preempt_enable();
> -
> -		for_each_rcu_flavor(rsp) {
> -			rcu_cleanup_dying_idle_cpu(cpu, rsp);
> -		}
> -		break;
>  	case CPU_DEAD:
>  	case CPU_DEAD_FROZEN:
>  	case CPU_UP_CANCELED:
> diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
> index 8abbe89..bd12c6c 100644
> --- a/kernel/sched/idle.c
> +++ b/kernel/sched/idle.c
> @@ -220,8 +220,6 @@ static void cpu_idle_loop(void)
>  			rmb();
> 
>  			if (cpu_is_offline(smp_processor_id())) {
> -				rcu_cpu_notify(NULL, CPU_DYING_IDLE,
> -					       (void *)(long)smp_processor_id());
>  				cpuhp_report_idle_dead();
>  				arch_cpu_idle_dead();
>  			}
> 

[toc] | [prev] | [next] | [standalone]


#1348831 — Re: [tip:smp/hotplug] rcu: Make CPU_DYING_IDLE an explicit call

FromThomas Gleixner <tglx@linutronix.de>
Date2016-03-03 08:40 +0100
SubjectRe: [tip:smp/hotplug] rcu: Make CPU_DYING_IDLE an explicit call
Message-ID<r8w1z-3Ix-13@gated-at.bofh.it>
In reply to#1348454
On Wed, 2 Mar 2016, Paul E. McKenney wrote:
> > --- a/kernel/cpu.c
> > +++ b/kernel/cpu.c
> > @@ -762,6 +762,7 @@ void cpuhp_report_idle_dead(void)
> >  	BUG_ON(st->state != CPUHP_AP_OFFLINE);
> >  	st->state = CPUHP_AP_IDLE_DEAD;
> >  	complete(&st->done);
> 
> Not to be repetitive or anything, but if we delay here, it can break
> RCU on a number of architectures.  Either the CPU can be killed holding
> one of RCU's locks or RCU can wrongly see the CPU as still being alive.
> Either can prevent future RCU grace periods from ever completing, thus
> OOMing the system.

Thanks for the reminder. I wanted to fix that, but then forgot again. Fix is
on the way.

Thanks,

	tglx

[toc] | [prev] | [next] | [standalone]


#1348943 — [tip:smp/hotplug] cpu/hotplug: Plug death reporting race

Fromtip-bot for Thomas Gleixner <tipbot@zytor.com>
Date2016-03-03 11:10 +0100
Subject[tip:smp/hotplug] cpu/hotplug: Plug death reporting race
Message-ID<r8ymJ-5pr-1@gated-at.bofh.it>
In reply to#1348454
Commit-ID:  71f87b2fc64c2e9b6d53cb817f28711b959d3dfe
Gitweb:     http://git.kernel.org/tip/71f87b2fc64c2e9b6d53cb817f28711b959d3dfe
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 3 Mar 2016 10:52:10 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 3 Mar 2016 10:52:10 +0100

cpu/hotplug: Plug death reporting race

Paul noticed that the conversion of the death reporting introduced a race
where the outgoing cpu might be delayed after waking the controll processor,
so it might not be able to call rcu_report_dead() before being physically
removed, leading to RCU stalls.

We cant call complete after rcu_report_dead(), so instead of going back to
busy polling, simply issue a function call to do the completion.

Fixes: 27d50c7eeb0f "rcu: Make CPU_DYING_IDLE an explicit call"
Reported-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/20160302201127.GA23440@linux.vnet.ibm.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra <peterz@infradead.org>
---
 kernel/cpu.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index ff8059b..93e9d89 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -755,14 +755,26 @@ static int notify_dead(unsigned int cpu)
 	return 0;
 }
 
+static void cpuhp_complete_idle_dead(void *arg)
+{
+	struct cpuhp_cpu_state *st = arg;
+
+	complete(&st->done);
+}
+
 void cpuhp_report_idle_dead(void)
 {
 	struct cpuhp_cpu_state *st = this_cpu_ptr(&cpuhp_state);
 
 	BUG_ON(st->state != CPUHP_AP_OFFLINE);
-	st->state = CPUHP_AP_IDLE_DEAD;
-	complete(&st->done);
 	rcu_report_dead(smp_processor_id());
+	st->state = CPUHP_AP_IDLE_DEAD;
+	/*
+	 * We cannot call complete after rcu_report_dead() so we delegate it
+	 * to an online cpu.
+	 */
+	smp_call_function_single(cpumask_first(cpu_online_mask),
+				 cpuhp_complete_idle_dead, st, 0);
 }
 
 #else

[toc] | [prev] | [next] | [standalone]


#1349194 — Re: [tip:smp/hotplug] cpu/hotplug: Plug death reporting race

From"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Date2016-03-03 15:20 +0100
SubjectRe: [tip:smp/hotplug] cpu/hotplug: Plug death reporting race
Message-ID<r8CgG-8cy-5@gated-at.bofh.it>
In reply to#1348943
On Thu, Mar 03, 2016 at 02:03:35AM -0800, tip-bot for Thomas Gleixner wrote:
> Commit-ID:  71f87b2fc64c2e9b6d53cb817f28711b959d3dfe
> Gitweb:     http://git.kernel.org/tip/71f87b2fc64c2e9b6d53cb817f28711b959d3dfe
> Author:     Thomas Gleixner <tglx@linutronix.de>
> AuthorDate: Thu, 3 Mar 2016 10:52:10 +0100
> Committer:  Thomas Gleixner <tglx@linutronix.de>
> CommitDate: Thu, 3 Mar 2016 10:52:10 +0100
> 
> cpu/hotplug: Plug death reporting race
> 
> Paul noticed that the conversion of the death reporting introduced a race
> where the outgoing cpu might be delayed after waking the controll processor,
> so it might not be able to call rcu_report_dead() before being physically
> removed, leading to RCU stalls.
> 
> We cant call complete after rcu_report_dead(), so instead of going back to
> busy polling, simply issue a function call to do the completion.
> 
> Fixes: 27d50c7eeb0f "rcu: Make CPU_DYING_IDLE an explicit call"
> Reported-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Link: http://lkml.kernel.org/r/20160302201127.GA23440@linux.vnet.ibm.com
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Acked-by: Peter Zijlstra <peterz@infradead.org>

There are some possible issues with printk()s from WARN_ON() calls
using RCU from within smp_call_function_single(), but in normal
execution this should be OK.  Besides, the WARN_ON() contains a
cpu_online(this_cpu), so it simply won't fire in this case.

So nice fix!!!

Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

> ---
>  kernel/cpu.c | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/cpu.c b/kernel/cpu.c
> index ff8059b..93e9d89 100644
> --- a/kernel/cpu.c
> +++ b/kernel/cpu.c
> @@ -755,14 +755,26 @@ static int notify_dead(unsigned int cpu)
>  	return 0;
>  }
> 
> +static void cpuhp_complete_idle_dead(void *arg)
> +{
> +	struct cpuhp_cpu_state *st = arg;
> +
> +	complete(&st->done);
> +}
> +
>  void cpuhp_report_idle_dead(void)
>  {
>  	struct cpuhp_cpu_state *st = this_cpu_ptr(&cpuhp_state);
> 
>  	BUG_ON(st->state != CPUHP_AP_OFFLINE);
> -	st->state = CPUHP_AP_IDLE_DEAD;
> -	complete(&st->done);
>  	rcu_report_dead(smp_processor_id());
> +	st->state = CPUHP_AP_IDLE_DEAD;
> +	/*
> +	 * We cannot call complete after rcu_report_dead() so we delegate it
> +	 * to an online cpu.
> +	 */
> +	smp_call_function_single(cpumask_first(cpu_online_mask),
> +				 cpuhp_complete_idle_dead, st, 0);
>  }
> 
>  #else
> 

[toc] | [prev] | [next] | [standalone]


#1344576 — [patch 08/20] cpu/hotplug: Hand in target state to _cpu_up/down

FromThomas Gleixner <tglx@linutronix.de>
Date2016-02-26 19:50 +0100
Subject[patch 08/20] cpu/hotplug: Hand in target state to _cpu_up/down
Message-ID<r6vCH-7sv-43@gated-at.bofh.it>
In reply to#1344561
We want to be able to bringup/teardown the cpu to a particular state. Add a
target argument to _cpu_up/down.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/cpu.c |   31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

Index: b/kernel/cpu.c
===================================================================
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -547,7 +547,8 @@ static void undo_cpu_down(unsigned int c
 }
 
 /* Requires cpu_add_remove_lock to be held */
-static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
+static int __ref _cpu_down(unsigned int cpu, int tasks_frozen,
+			   enum cpuhp_state target)
 {
 	struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
 	int prev_state, ret = 0;
@@ -564,7 +565,7 @@ static int __ref _cpu_down(unsigned int
 	cpuhp_tasks_frozen = tasks_frozen;
 
 	prev_state = st->state;
-	st->target = CPUHP_OFFLINE;
+	st->target = target;
 	for (; st->state > st->target; st->state--) {
 		struct cpuhp_step *step = cpuhp_bp_states + st->state;
 
@@ -584,7 +585,7 @@ static int __ref _cpu_down(unsigned int
 	return ret;
 }
 
-int cpu_down(unsigned int cpu)
+static int do_cpu_down(unsigned int cpu, enum cpuhp_state target)
 {
 	int err;
 
@@ -595,12 +596,16 @@ int cpu_down(unsigned int cpu)
 		goto out;
 	}
 
-	err = _cpu_down(cpu, 0);
+	err = _cpu_down(cpu, 0, target);
 
 out:
 	cpu_maps_update_done();
 	return err;
 }
+int cpu_down(unsigned int cpu)
+{
+	return do_cpu_down(cpu, CPUHP_OFFLINE);
+}
 EXPORT_SYMBOL(cpu_down);
 #endif /*CONFIG_HOTPLUG_CPU*/
 
@@ -669,7 +674,7 @@ static void undo_cpu_up(unsigned int cpu
 }
 
 /* Requires cpu_add_remove_lock to be held */
-static int _cpu_up(unsigned int cpu, int tasks_frozen)
+static int _cpu_up(unsigned int cpu, int tasks_frozen, enum cpuhp_state target)
 {
 	struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
 	struct task_struct *idle;
@@ -692,7 +697,7 @@ static int _cpu_up(unsigned int cpu, int
 	cpuhp_tasks_frozen = tasks_frozen;
 
 	prev_state = st->state;
-	st->target = CPUHP_ONLINE;
+	st->target = target;
 	while (st->state < st->target) {
 		struct cpuhp_step *step;
 
@@ -710,7 +715,7 @@ static int _cpu_up(unsigned int cpu, int
 	return ret;
 }
 
-int cpu_up(unsigned int cpu)
+static int do_cpu_up(unsigned int cpu, enum cpuhp_state target)
 {
 	int err = 0;
 
@@ -734,12 +739,16 @@ int cpu_up(unsigned int cpu)
 		goto out;
 	}
 
-	err = _cpu_up(cpu, 0);
-
+	err = _cpu_up(cpu, 0, target);
 out:
 	cpu_maps_update_done();
 	return err;
 }
+
+int cpu_up(unsigned int cpu)
+{
+	return do_cpu_up(cpu, CPUHP_ONLINE);
+}
 EXPORT_SYMBOL_GPL(cpu_up);
 
 #ifdef CONFIG_PM_SLEEP_SMP
@@ -762,7 +771,7 @@ int disable_nonboot_cpus(void)
 		if (cpu == first_cpu)
 			continue;
 		trace_suspend_resume(TPS("CPU_OFF"), cpu, true);
-		error = _cpu_down(cpu, 1);
+		error = _cpu_down(cpu, 1, CPUHP_OFFLINE);
 		trace_suspend_resume(TPS("CPU_OFF"), cpu, false);
 		if (!error)
 			cpumask_set_cpu(cpu, frozen_cpus);
@@ -812,7 +821,7 @@ void enable_nonboot_cpus(void)
 
 	for_each_cpu(cpu, frozen_cpus) {
 		trace_suspend_resume(TPS("CPU_ON"), cpu, true);
-		error = _cpu_up(cpu, 1);
+		error = _cpu_up(cpu, 1, CPUHP_ONLINE);
 		trace_suspend_resume(TPS("CPU_ON"), cpu, false);
 		if (!error) {
 			pr_info("CPU%d is up\n", cpu);

[toc] | [prev] | [next] | [standalone]


#1346990 — [tip:smp/hotplug] cpu/hotplug: Hand in target state to _cpu_up/down

Fromtip-bot for Thomas Gleixner <tipbot@zytor.com>
Date2016-03-01 21:00 +0100
Subject[tip:smp/hotplug] cpu/hotplug: Hand in target state to _cpu_up/down
Message-ID<r7YCF-5hG-63@gated-at.bofh.it>
In reply to#1344576
Commit-ID:  af1f40457da6f79b6a1d7e1198b32f671572abd2
Gitweb:     http://git.kernel.org/tip/af1f40457da6f79b6a1d7e1198b32f671572abd2
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Fri, 26 Feb 2016 18:43:30 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 1 Mar 2016 20:36:54 +0100

cpu/hotplug: Hand in target state to _cpu_up/down

We want to be able to bringup/teardown the cpu to a particular state. Add a
target argument to _cpu_up/down.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-arch@vger.kernel.org
Cc: Rik van Riel <riel@redhat.com>
Cc: Rafael Wysocki <rafael.j.wysocki@intel.com>
Cc: "Srivatsa S. Bhat" <srivatsa@mit.edu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Sebastian Siewior <bigeasy@linutronix.de>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul Turner <pjt@google.com>
Link: http://lkml.kernel.org/r/20160226182340.862113133@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/cpu.c | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index 797723e..a00f8f6 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -547,7 +547,8 @@ static void undo_cpu_down(unsigned int cpu, struct cpuhp_cpu_state *st)
 }
 
 /* Requires cpu_add_remove_lock to be held */
-static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
+static int __ref _cpu_down(unsigned int cpu, int tasks_frozen,
+			   enum cpuhp_state target)
 {
 	struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
 	int prev_state, ret = 0;
@@ -564,7 +565,7 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
 	cpuhp_tasks_frozen = tasks_frozen;
 
 	prev_state = st->state;
-	st->target = CPUHP_OFFLINE;
+	st->target = target;
 	for (; st->state > st->target; st->state--) {
 		struct cpuhp_step *step = cpuhp_bp_states + st->state;
 
@@ -584,7 +585,7 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
 	return ret;
 }
 
-int cpu_down(unsigned int cpu)
+static int do_cpu_down(unsigned int cpu, enum cpuhp_state target)
 {
 	int err;
 
@@ -595,12 +596,16 @@ int cpu_down(unsigned int cpu)
 		goto out;
 	}
 
-	err = _cpu_down(cpu, 0);
+	err = _cpu_down(cpu, 0, target);
 
 out:
 	cpu_maps_update_done();
 	return err;
 }
+int cpu_down(unsigned int cpu)
+{
+	return do_cpu_down(cpu, CPUHP_OFFLINE);
+}
 EXPORT_SYMBOL(cpu_down);
 #endif /*CONFIG_HOTPLUG_CPU*/
 
@@ -669,7 +674,7 @@ static void undo_cpu_up(unsigned int cpu, struct cpuhp_cpu_state *st)
 }
 
 /* Requires cpu_add_remove_lock to be held */
-static int _cpu_up(unsigned int cpu, int tasks_frozen)
+static int _cpu_up(unsigned int cpu, int tasks_frozen, enum cpuhp_state target)
 {
 	struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
 	struct task_struct *idle;
@@ -692,7 +697,7 @@ static int _cpu_up(unsigned int cpu, int tasks_frozen)
 	cpuhp_tasks_frozen = tasks_frozen;
 
 	prev_state = st->state;
-	st->target = CPUHP_ONLINE;
+	st->target = target;
 	while (st->state < st->target) {
 		struct cpuhp_step *step;
 
@@ -710,7 +715,7 @@ out:
 	return ret;
 }
 
-int cpu_up(unsigned int cpu)
+static int do_cpu_up(unsigned int cpu, enum cpuhp_state target)
 {
 	int err = 0;
 
@@ -734,12 +739,16 @@ int cpu_up(unsigned int cpu)
 		goto out;
 	}
 
-	err = _cpu_up(cpu, 0);
-
+	err = _cpu_up(cpu, 0, target);
 out:
 	cpu_maps_update_done();
 	return err;
 }
+
+int cpu_up(unsigned int cpu)
+{
+	return do_cpu_up(cpu, CPUHP_ONLINE);
+}
 EXPORT_SYMBOL_GPL(cpu_up);
 
 #ifdef CONFIG_PM_SLEEP_SMP
@@ -762,7 +771,7 @@ int disable_nonboot_cpus(void)
 		if (cpu == first_cpu)
 			continue;
 		trace_suspend_resume(TPS("CPU_OFF"), cpu, true);
-		error = _cpu_down(cpu, 1);
+		error = _cpu_down(cpu, 1, CPUHP_OFFLINE);
 		trace_suspend_resume(TPS("CPU_OFF"), cpu, false);
 		if (!error)
 			cpumask_set_cpu(cpu, frozen_cpus);
@@ -812,7 +821,7 @@ void enable_nonboot_cpus(void)
 
 	for_each_cpu(cpu, frozen_cpus) {
 		trace_suspend_resume(TPS("CPU_ON"), cpu, true);
-		error = _cpu_up(cpu, 1);
+		error = _cpu_up(cpu, 1, CPUHP_ONLINE);
 		trace_suspend_resume(TPS("CPU_ON"), cpu, false);
 		if (!error) {
 			pr_info("CPU%d is up\n", cpu);

[toc] | [prev] | [next] | [standalone]


#1344577 — [patch 19/20] cpu/hotplug: Make wait for dead cpu completion based

FromThomas Gleixner <tglx@linutronix.de>
Date2016-02-26 19:50 +0100
Subject[patch 19/20] cpu/hotplug: Make wait for dead cpu completion based
Message-ID<r6vCI-7sv-51@gated-at.bofh.it>
In reply to#1344561
Kill the busy spinning on the control side and just wait for the hotplugged
cpu to tell that it reached the dead state.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/cpu.h        |    5 +++--
 include/linux/cpuhotplug.h |    1 +
 kernel/cpu.c               |   16 ++++++++++++----
 kernel/sched/idle.c        |    5 +----
 4 files changed, 17 insertions(+), 10 deletions(-)

Index: b/include/linux/cpu.h
===================================================================
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -276,14 +276,15 @@ void arch_cpu_idle_enter(void);
 void arch_cpu_idle_exit(void);
 void arch_cpu_idle_dead(void);
 
-DECLARE_PER_CPU(bool, cpu_dead_idle);
-
 int cpu_report_state(int cpu);
 int cpu_check_up_prepare(int cpu);
 void cpu_set_state_online(int cpu);
 #ifdef CONFIG_HOTPLUG_CPU
 bool cpu_wait_death(unsigned int cpu, int seconds);
 bool cpu_report_death(void);
+void cpuhp_report_idle_dead(void);
+#else
+static inline void cpuhp_report_idle_dead(void) { }
 #endif /* #ifdef CONFIG_HOTPLUG_CPU */
 
 #endif /* _LINUX_CPU_H_ */
Index: b/include/linux/cpuhotplug.h
===================================================================
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -6,6 +6,7 @@ enum cpuhp_state {
 	CPUHP_CREATE_THREADS,
 	CPUHP_NOTIFY_PREPARE,
 	CPUHP_BRINGUP_CPU,
+	CPUHP_AP_IDLE_DEAD,
 	CPUHP_AP_OFFLINE,
 	CPUHP_AP_NOTIFY_STARTING,
 	CPUHP_AP_ONLINE,
Index: b/kernel/cpu.c
===================================================================
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -688,6 +688,7 @@ static int take_cpu_down(void *_param)
 
 static int takedown_cpu(unsigned int cpu)
 {
+	struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
 	int err;
 
 	/*
@@ -733,10 +734,8 @@ static int takedown_cpu(unsigned int cpu
 	 *
 	 * Wait for the stop thread to go away.
 	 */
-	while (!per_cpu(cpu_dead_idle, cpu))
-		cpu_relax();
-	smp_mb(); /* Read from cpu_dead_idle before __cpu_die(). */
-	per_cpu(cpu_dead_idle, cpu) = false;
+	wait_for_completion(&st->done);
+	BUG_ON(st->state != CPUHP_AP_IDLE_DEAD);
 
 	/* Interrupts are moved away from the dying cpu, reenable alloc/free */
 	irq_unlock_sparse();
@@ -756,6 +755,15 @@ static int notify_dead(unsigned int cpu)
 	return 0;
 }
 
+void cpuhp_report_idle_dead(void)
+{
+	struct cpuhp_cpu_state *st = this_cpu_ptr(&cpuhp_state);
+
+	BUG_ON(st->state != CPUHP_AP_OFFLINE);
+	st->state = CPUHP_AP_IDLE_DEAD;
+	complete(&st->done);
+}
+
 #else
 #define notify_down_prepare	NULL
 #define takedown_cpu		NULL
Index: b/kernel/sched/idle.c
===================================================================
--- a/kernel/sched/idle.c
+++ b/kernel/sched/idle.c
@@ -194,8 +194,6 @@ static void cpuidle_idle_call(void)
 	rcu_idle_exit();
 }
 
-DEFINE_PER_CPU(bool, cpu_dead_idle);
-
 /*
  * Generic idle loop implementation
  *
@@ -224,8 +222,7 @@ static void cpu_idle_loop(void)
 			if (cpu_is_offline(smp_processor_id())) {
 				rcu_cpu_notify(NULL, CPU_DYING_IDLE,
 					       (void *)(long)smp_processor_id());
-				smp_mb(); /* all activity before dead. */
-				this_cpu_write(cpu_dead_idle, true);
+				cpuhp_report_idle_dead();
 				arch_cpu_idle_dead();
 			}
 

[toc] | [prev] | [next] | [standalone]


#1346994 — [tip:smp/hotplug] cpu/hotplug: Make wait for dead cpu completion based

Fromtip-bot for Thomas Gleixner <tipbot@zytor.com>
Date2016-03-01 21:00 +0100
Subject[tip:smp/hotplug] cpu/hotplug: Make wait for dead cpu completion based
Message-ID<r7YCF-5hG-67@gated-at.bofh.it>
In reply to#1344577
Commit-ID:  e69aab13117efc1987620090e539b4ebeb33a04c
Gitweb:     http://git.kernel.org/tip/e69aab13117efc1987620090e539b4ebeb33a04c
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Fri, 26 Feb 2016 18:43:43 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 1 Mar 2016 20:36:58 +0100

cpu/hotplug: Make wait for dead cpu completion based

Kill the busy spinning on the control side and just wait for the hotplugged
cpu to tell that it reached the dead state.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-arch@vger.kernel.org
Cc: Rik van Riel <riel@redhat.com>
Cc: Rafael Wysocki <rafael.j.wysocki@intel.com>
Cc: "Srivatsa S. Bhat" <srivatsa@mit.edu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Sebastian Siewior <bigeasy@linutronix.de>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul Turner <pjt@google.com>
Link: http://lkml.kernel.org/r/20160226182341.776157858@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/cpu.h        |  5 +++--
 include/linux/cpuhotplug.h |  1 +
 kernel/cpu.c               | 16 ++++++++++++----
 kernel/sched/idle.c        |  5 +----
 4 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 83f3576..91a48d1 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -276,14 +276,15 @@ void arch_cpu_idle_enter(void);
 void arch_cpu_idle_exit(void);
 void arch_cpu_idle_dead(void);
 
-DECLARE_PER_CPU(bool, cpu_dead_idle);
-
 int cpu_report_state(int cpu);
 int cpu_check_up_prepare(int cpu);
 void cpu_set_state_online(int cpu);
 #ifdef CONFIG_HOTPLUG_CPU
 bool cpu_wait_death(unsigned int cpu, int seconds);
 bool cpu_report_death(void);
+void cpuhp_report_idle_dead(void);
+#else
+static inline void cpuhp_report_idle_dead(void) { }
 #endif /* #ifdef CONFIG_HOTPLUG_CPU */
 
 #endif /* _LINUX_CPU_H_ */
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index ad5d7fc..5d68e15 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -6,6 +6,7 @@ enum cpuhp_state {
 	CPUHP_CREATE_THREADS,
 	CPUHP_NOTIFY_PREPARE,
 	CPUHP_BRINGUP_CPU,
+	CPUHP_AP_IDLE_DEAD,
 	CPUHP_AP_OFFLINE,
 	CPUHP_AP_NOTIFY_STARTING,
 	CPUHP_AP_ONLINE,
diff --git a/kernel/cpu.c b/kernel/cpu.c
index f1f880f..0e8c07f 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -688,6 +688,7 @@ static int take_cpu_down(void *_param)
 
 static int takedown_cpu(unsigned int cpu)
 {
+	struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
 	int err;
 
 	/*
@@ -733,10 +734,8 @@ static int takedown_cpu(unsigned int cpu)
 	 *
 	 * Wait for the stop thread to go away.
 	 */
-	while (!per_cpu(cpu_dead_idle, cpu))
-		cpu_relax();
-	smp_mb(); /* Read from cpu_dead_idle before __cpu_die(). */
-	per_cpu(cpu_dead_idle, cpu) = false;
+	wait_for_completion(&st->done);
+	BUG_ON(st->state != CPUHP_AP_IDLE_DEAD);
 
 	/* Interrupts are moved away from the dying cpu, reenable alloc/free */
 	irq_unlock_sparse();
@@ -756,6 +755,15 @@ static int notify_dead(unsigned int cpu)
 	return 0;
 }
 
+void cpuhp_report_idle_dead(void)
+{
+	struct cpuhp_cpu_state *st = this_cpu_ptr(&cpuhp_state);
+
+	BUG_ON(st->state != CPUHP_AP_OFFLINE);
+	st->state = CPUHP_AP_IDLE_DEAD;
+	complete(&st->done);
+}
+
 #else
 #define notify_down_prepare	NULL
 #define takedown_cpu		NULL
diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
index a4b9813..8abbe89 100644
--- a/kernel/sched/idle.c
+++ b/kernel/sched/idle.c
@@ -194,8 +194,6 @@ exit_idle:
 	rcu_idle_exit();
 }
 
-DEFINE_PER_CPU(bool, cpu_dead_idle);
-
 /*
  * Generic idle loop implementation
  *
@@ -224,8 +222,7 @@ static void cpu_idle_loop(void)
 			if (cpu_is_offline(smp_processor_id())) {
 				rcu_cpu_notify(NULL, CPU_DYING_IDLE,
 					       (void *)(long)smp_processor_id());
-				smp_mb(); /* all activity before dead. */
-				this_cpu_write(cpu_dead_idle, true);
+				cpuhp_report_idle_dead();
 				arch_cpu_idle_dead();
 			}
 

[toc] | [prev] | [next] | [standalone]


#1344588 — [patch 07/20] cpu/hotplug: Convert the hotplugged cpu work to a state machine

FromThomas Gleixner <tglx@linutronix.de>
Date2016-02-26 20:00 +0100
Subject[patch 07/20] cpu/hotplug: Convert the hotplugged cpu work to a state machine
Message-ID<r6vMm-7w1-27@gated-at.bofh.it>
In reply to#1344561
Move the functions which need to run on the hotplugged processor into
a state machine array and let the code iterate through these functions.

In a later state, this will grow synchronization points between the
control processor and the hotplugged processor, so we can move the
various architecture implementations of the synchronizations to the
core.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/cpuhotplug.h |    4 ++
 kernel/cpu.c               |   81 ++++++++++++++++++++++++++++++++++++---------
 2 files changed, 70 insertions(+), 15 deletions(-)

Index: b/include/linux/cpuhotplug.h
===================================================================
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -6,6 +6,10 @@ enum cpuhp_state {
 	CPUHP_CREATE_THREADS,
 	CPUHP_NOTIFY_PREPARE,
 	CPUHP_BRINGUP_CPU,
+	CPUHP_AP_OFFLINE,
+	CPUHP_AP_NOTIFY_STARTING,
+	CPUHP_AP_ONLINE,
+	CPUHP_TEARDOWN_CPU,
 	CPUHP_NOTIFY_ONLINE,
 	CPUHP_ONLINE,
 };
Index: b/kernel/cpu.c
===================================================================
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -57,6 +57,7 @@ struct cpuhp_step {
 };
 
 static struct cpuhp_step cpuhp_bp_states[];
+static struct cpuhp_step cpuhp_ap_states[];
 
 /**
  * cpuhp_invoke_callback _ Invoke the callbacks for a given state
@@ -304,6 +305,12 @@ static int notify_online(unsigned int cp
 	return 0;
 }
 
+static int notify_starting(unsigned int cpu)
+{
+	cpu_notify(CPU_STARTING, cpu);
+	return 0;
+}
+
 static int bringup_cpu(unsigned int cpu)
 {
 	struct task_struct *idle = idle_thread_get(cpu);
@@ -421,9 +428,17 @@ static int notify_down_prepare(unsigned
 	return err;
 }
 
+static int notify_dying(unsigned int cpu)
+{
+	cpu_notify(CPU_DYING, cpu);
+	return 0;
+}
+
 /* Take this CPU down. */
 static int take_cpu_down(void *_param)
 {
+	struct cpuhp_cpu_state *st = this_cpu_ptr(&cpuhp_state);
+	enum cpuhp_state target = max((int)st->target, CPUHP_AP_OFFLINE);
 	int err, cpu = smp_processor_id();
 
 	/* Ensure this CPU doesn't handle any more interrupts. */
@@ -431,7 +446,12 @@ static int take_cpu_down(void *_param)
 	if (err < 0)
 		return err;
 
-	cpu_notify(CPU_DYING, cpu);
+	/* Invoke the former CPU_DYING callbacks */
+	for (; st->state > target; st->state--) {
+		struct cpuhp_step *step = cpuhp_ap_states + st->state;
+
+		cpuhp_invoke_callback(cpu, st->state, step->teardown);
+	}
 	/* Give up timekeeping duties */
 	tick_handover_do_timer();
 	/* Park the stopper thread */
@@ -512,6 +532,7 @@ static int notify_dead(unsigned int cpu)
 #define notify_down_prepare	NULL
 #define takedown_cpu		NULL
 #define notify_dead		NULL
+#define notify_dying		NULL
 #endif
 
 #ifdef CONFIG_HOTPLUG_CPU
@@ -615,6 +636,28 @@ void smpboot_thread_init(void)
 	register_cpu_notifier(&smpboot_thread_notifier);
 }
 
+/**
+ * notify_cpu_starting(cpu) - call the CPU_STARTING notifiers
+ * @cpu: cpu that just started
+ *
+ * This function calls the cpu_chain notifiers with CPU_STARTING.
+ * It must be called by the arch code on the new cpu, before the new cpu
+ * enables interrupts and before the "boot" cpu returns from __cpu_up().
+ */
+void notify_cpu_starting(unsigned int cpu)
+{
+	struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
+	enum cpuhp_state target = min((int)st->target, CPUHP_AP_ONLINE);
+
+	while (st->state < target) {
+		struct cpuhp_step *step;
+
+		st->state++;
+		step = cpuhp_ap_states + st->state;
+		cpuhp_invoke_callback(cpu, st->state, step->startup);
+	}
+}
+
 static void undo_cpu_up(unsigned int cpu, struct cpuhp_cpu_state *st)
 {
 	for (st->state--; st->state > st->target; st->state--) {
@@ -842,19 +885,6 @@ core_initcall(cpu_hotplug_pm_sync_init);
 
 #endif /* CONFIG_PM_SLEEP_SMP */
 
-/**
- * notify_cpu_starting(cpu) - call the CPU_STARTING notifiers
- * @cpu: cpu that just started
- *
- * This function calls the cpu_chain notifiers with CPU_STARTING.
- * It must be called by the arch code on the new cpu, before the new cpu
- * enables interrupts and before the "boot" cpu returns from __cpu_up().
- */
-void notify_cpu_starting(unsigned int cpu)
-{
-	cpu_notify(CPU_STARTING, cpu);
-}
-
 #endif /* CONFIG_SMP */
 
 /* Boot processor state steps */
@@ -879,8 +909,12 @@ static struct cpuhp_step cpuhp_bp_states
 	[CPUHP_BRINGUP_CPU] = {
 		.name			= "cpu:bringup",
 		.startup		= bringup_cpu,
+		.teardown		= NULL,
+	},
+	[CPUHP_TEARDOWN_CPU] = {
+		.name			= "cpu:teardown",
+		.startup		= NULL,
 		.teardown		= takedown_cpu,
-		.skip_onerr		= true,
 	},
 	[CPUHP_NOTIFY_ONLINE] = {
 		.name			= "notify:online",
@@ -889,6 +923,23 @@ static struct cpuhp_step cpuhp_bp_states
 	},
 #endif
 	[CPUHP_ONLINE] = {
+		.name			= "online",
+		.startup		= NULL,
+		.teardown		= NULL,
+	},
+};
+
+/* Application processor state steps */
+static struct cpuhp_step cpuhp_ap_states[] = {
+#ifdef CONFIG_SMP
+	[CPUHP_AP_NOTIFY_STARTING] = {
+		.name			= "notify:starting",
+		.startup		= notify_starting,
+		.teardown		= notify_dying,
+		.skip_onerr		= true,
+	},
+#endif
+	[CPUHP_ONLINE] = {
 		.name			= "online",
 		.startup		= NULL,
 		.teardown		= NULL,

[toc] | [prev] | [next] | [standalone]


#1346973 — [tip:smp/hotplug] cpu/hotplug: Convert the hotplugged cpu work to a state machine

Fromtip-bot for Thomas Gleixner <tipbot@zytor.com>
Date2016-03-01 21:00 +0100
Subject[tip:smp/hotplug] cpu/hotplug: Convert the hotplugged cpu work to a state machine
Message-ID<r7YCC-5hG-9@gated-at.bofh.it>
In reply to#1344588
Commit-ID:  4baa0afc6719cbf36a1e08551484a641926b3fd1
Gitweb:     http://git.kernel.org/tip/4baa0afc6719cbf36a1e08551484a641926b3fd1
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Fri, 26 Feb 2016 18:43:29 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 1 Mar 2016 20:36:54 +0100

cpu/hotplug: Convert the hotplugged cpu work to a state machine

Move the functions which need to run on the hotplugged processor into
a state machine array and let the code iterate through these functions.

In a later state, this will grow synchronization points between the
control processor and the hotplugged processor, so we can move the
various architecture implementations of the synchronizations to the
core.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-arch@vger.kernel.org
Cc: Rik van Riel <riel@redhat.com>
Cc: Rafael Wysocki <rafael.j.wysocki@intel.com>
Cc: "Srivatsa S. Bhat" <srivatsa@mit.edu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Sebastian Siewior <bigeasy@linutronix.de>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul Turner <pjt@google.com>
Link: http://lkml.kernel.org/r/20160226182340.770651526@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/cpuhotplug.h |  4 +++
 kernel/cpu.c               | 81 +++++++++++++++++++++++++++++++++++++---------
 2 files changed, 70 insertions(+), 15 deletions(-)

diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index d55c9e6..d9303cc 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -6,6 +6,10 @@ enum cpuhp_state {
 	CPUHP_CREATE_THREADS,
 	CPUHP_NOTIFY_PREPARE,
 	CPUHP_BRINGUP_CPU,
+	CPUHP_AP_OFFLINE,
+	CPUHP_AP_NOTIFY_STARTING,
+	CPUHP_AP_ONLINE,
+	CPUHP_TEARDOWN_CPU,
 	CPUHP_NOTIFY_ONLINE,
 	CPUHP_ONLINE,
 };
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 3018519..797723e 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -57,6 +57,7 @@ struct cpuhp_step {
 };
 
 static struct cpuhp_step cpuhp_bp_states[];
+static struct cpuhp_step cpuhp_ap_states[];
 
 /**
  * cpuhp_invoke_callback _ Invoke the callbacks for a given state
@@ -304,6 +305,12 @@ static int notify_online(unsigned int cpu)
 	return 0;
 }
 
+static int notify_starting(unsigned int cpu)
+{
+	cpu_notify(CPU_STARTING, cpu);
+	return 0;
+}
+
 static int bringup_cpu(unsigned int cpu)
 {
 	struct task_struct *idle = idle_thread_get(cpu);
@@ -421,9 +428,17 @@ static int notify_down_prepare(unsigned int cpu)
 	return err;
 }
 
+static int notify_dying(unsigned int cpu)
+{
+	cpu_notify(CPU_DYING, cpu);
+	return 0;
+}
+
 /* Take this CPU down. */
 static int take_cpu_down(void *_param)
 {
+	struct cpuhp_cpu_state *st = this_cpu_ptr(&cpuhp_state);
+	enum cpuhp_state target = max((int)st->target, CPUHP_AP_OFFLINE);
 	int err, cpu = smp_processor_id();
 
 	/* Ensure this CPU doesn't handle any more interrupts. */
@@ -431,7 +446,12 @@ static int take_cpu_down(void *_param)
 	if (err < 0)
 		return err;
 
-	cpu_notify(CPU_DYING, cpu);
+	/* Invoke the former CPU_DYING callbacks */
+	for (; st->state > target; st->state--) {
+		struct cpuhp_step *step = cpuhp_ap_states + st->state;
+
+		cpuhp_invoke_callback(cpu, st->state, step->teardown);
+	}
 	/* Give up timekeeping duties */
 	tick_handover_do_timer();
 	/* Park the stopper thread */
@@ -512,6 +532,7 @@ static int notify_dead(unsigned int cpu)
 #define notify_down_prepare	NULL
 #define takedown_cpu		NULL
 #define notify_dead		NULL
+#define notify_dying		NULL
 #endif
 
 #ifdef CONFIG_HOTPLUG_CPU
@@ -615,6 +636,28 @@ void smpboot_thread_init(void)
 	register_cpu_notifier(&smpboot_thread_notifier);
 }
 
+/**
+ * notify_cpu_starting(cpu) - call the CPU_STARTING notifiers
+ * @cpu: cpu that just started
+ *
+ * This function calls the cpu_chain notifiers with CPU_STARTING.
+ * It must be called by the arch code on the new cpu, before the new cpu
+ * enables interrupts and before the "boot" cpu returns from __cpu_up().
+ */
+void notify_cpu_starting(unsigned int cpu)
+{
+	struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
+	enum cpuhp_state target = min((int)st->target, CPUHP_AP_ONLINE);
+
+	while (st->state < target) {
+		struct cpuhp_step *step;
+
+		st->state++;
+		step = cpuhp_ap_states + st->state;
+		cpuhp_invoke_callback(cpu, st->state, step->startup);
+	}
+}
+
 static void undo_cpu_up(unsigned int cpu, struct cpuhp_cpu_state *st)
 {
 	for (st->state--; st->state > st->target; st->state--) {
@@ -842,19 +885,6 @@ core_initcall(cpu_hotplug_pm_sync_init);
 
 #endif /* CONFIG_PM_SLEEP_SMP */
 
-/**
- * notify_cpu_starting(cpu) - call the CPU_STARTING notifiers
- * @cpu: cpu that just started
- *
- * This function calls the cpu_chain notifiers with CPU_STARTING.
- * It must be called by the arch code on the new cpu, before the new cpu
- * enables interrupts and before the "boot" cpu returns from __cpu_up().
- */
-void notify_cpu_starting(unsigned int cpu)
-{
-	cpu_notify(CPU_STARTING, cpu);
-}
-
 #endif /* CONFIG_SMP */
 
 /* Boot processor state steps */
@@ -879,8 +909,12 @@ static struct cpuhp_step cpuhp_bp_states[] = {
 	[CPUHP_BRINGUP_CPU] = {
 		.name			= "cpu:bringup",
 		.startup		= bringup_cpu,
+		.teardown		= NULL,
+	},
+	[CPUHP_TEARDOWN_CPU] = {
+		.name			= "cpu:teardown",
+		.startup		= NULL,
 		.teardown		= takedown_cpu,
-		.skip_onerr		= true,
 	},
 	[CPUHP_NOTIFY_ONLINE] = {
 		.name			= "notify:online",
@@ -895,6 +929,23 @@ static struct cpuhp_step cpuhp_bp_states[] = {
 	},
 };
 
+/* Application processor state steps */
+static struct cpuhp_step cpuhp_ap_states[] = {
+#ifdef CONFIG_SMP
+	[CPUHP_AP_NOTIFY_STARTING] = {
+		.name			= "notify:starting",
+		.startup		= notify_starting,
+		.teardown		= notify_dying,
+		.skip_onerr		= true,
+	},
+#endif
+	[CPUHP_ONLINE] = {
+		.name			= "online",
+		.startup		= NULL,
+		.teardown		= NULL,
+	},
+};
+
 /*
  * cpu_bit_bitmap[] is a special, "compressed" data structure that
  * represents all NR_CPUS bits binary values of 1<<nr.

[toc] | [prev] | [next] | [standalone]


#1344589 — [patch 01/20] idle: Move x86ism out of generic code

FromThomas Gleixner <tglx@linutronix.de>
Date2016-02-26 20:00 +0100
Subject[patch 01/20] idle: Move x86ism out of generic code
Message-ID<r6vMn-7w1-31@gated-at.bofh.it>
In reply to#1344561
We have an arch specific callback here already.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/kernel/process.c |   12 ++++++++++++
 kernel/sched/idle.c       |   15 ---------------
 2 files changed, 12 insertions(+), 15 deletions(-)

Index: b/arch/x86/kernel/process.c
===================================================================
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -271,6 +271,18 @@ void exit_idle(void)
 }
 #endif
 
+void arch_cpu_idle_prepare(void)
+{
+	/*
+	 * If we're the non-boot CPU, nothing set the stack canary up
+	 * for us. The boot CPU already has it initialized but no harm
+	 * in doing it again. This is a good place for updating it, as
+	 * we wont ever return from this function (so the invalid
+	 * canaries already on the stack wont ever trigger).
+	 */
+	boot_init_stack_canary();
+}
+
 void arch_cpu_idle_enter(void)
 {
 	local_touch_nmi();
Index: b/kernel/sched/idle.c
===================================================================
--- a/kernel/sched/idle.c
+++ b/kernel/sched/idle.c
@@ -275,21 +275,6 @@ static void cpu_idle_loop(void)
 
 void cpu_startup_entry(enum cpuhp_state state)
 {
-	/*
-	 * This #ifdef needs to die, but it's too late in the cycle to
-	 * make this generic (arm and sh have never invoked the canary
-	 * init for the non boot cpus!). Will be fixed in 3.11
-	 */
-#ifdef CONFIG_X86
-	/*
-	 * If we're the non-boot CPU, nothing set the stack canary up
-	 * for us. The boot CPU already has it initialized but no harm
-	 * in doing it again. This is a good place for updating it, as
-	 * we wont ever return from this function (so the invalid
-	 * canaries already on the stack wont ever trigger).
-	 */
-	boot_init_stack_canary();
-#endif
 	arch_cpu_idle_prepare();
 	cpu_idle_loop();
 }

[toc] | [prev] | [next] | [standalone]


#1345088 — Re: [patch 01/20] idle: Move x86ism out of generic code

FromBrian Gerst <brgerst@gmail.com>
Date2016-02-27 21:30 +0100
SubjectRe: [patch 01/20] idle: Move x86ism out of generic code
Message-ID<r6TEZ-8jB-13@gated-at.bofh.it>
In reply to#1344589
On Fri, Feb 26, 2016 at 1:43 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
> We have an arch specific callback here already.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
>  arch/x86/kernel/process.c |   12 ++++++++++++
>  kernel/sched/idle.c       |   15 ---------------
>  2 files changed, 12 insertions(+), 15 deletions(-)
>
> Index: b/arch/x86/kernel/process.c
> ===================================================================
> --- a/arch/x86/kernel/process.c
> +++ b/arch/x86/kernel/process.c
> @@ -271,6 +271,18 @@ void exit_idle(void)
>  }
>  #endif
>
> +void arch_cpu_idle_prepare(void)
> +{
> +       /*
> +        * If we're the non-boot CPU, nothing set the stack canary up
> +        * for us. The boot CPU already has it initialized but no harm
> +        * in doing it again. This is a good place for updating it, as
> +        * we wont ever return from this function (so the invalid
> +        * canaries already on the stack wont ever trigger).
> +        */
> +       boot_init_stack_canary();
> +}
> +
>  void arch_cpu_idle_enter(void)
>  {
>         local_touch_nmi();
> Index: b/kernel/sched/idle.c
> ===================================================================
> --- a/kernel/sched/idle.c
> +++ b/kernel/sched/idle.c
> @@ -275,21 +275,6 @@ static void cpu_idle_loop(void)
>
>  void cpu_startup_entry(enum cpuhp_state state)
>  {
> -       /*
> -        * This #ifdef needs to die, but it's too late in the cycle to
> -        * make this generic (arm and sh have never invoked the canary
> -        * init for the non boot cpus!). Will be fixed in 3.11
> -        */
> -#ifdef CONFIG_X86
> -       /*
> -        * If we're the non-boot CPU, nothing set the stack canary up
> -        * for us. The boot CPU already has it initialized but no harm
> -        * in doing it again. This is a good place for updating it, as
> -        * we wont ever return from this function (so the invalid
> -        * canaries already on the stack wont ever trigger).
> -        */
> -       boot_init_stack_canary();
> -#endif
>         arch_cpu_idle_prepare();
>         cpu_idle_loop();
>  }

Does this actually work with stack protector enabled?
boot_init_stack_canary() is inlined while arch_cpu_idle_prepare() is
not.

--
Brian Gerst

[toc] | [prev] | [next] | [standalone]


#1346124 — Re: [patch 01/20] idle: Move x86ism out of generic code

FromThomas Gleixner <tglx@linutronix.de>
Date2016-02-29 20:40 +0100
SubjectRe: [patch 01/20] idle: Move x86ism out of generic code
Message-ID<r7BPI-7hF-19@gated-at.bofh.it>
In reply to#1345088
On Sat, 27 Feb 2016, Brian Gerst wrote:
> >         arch_cpu_idle_prepare();
> >         cpu_idle_loop();
> >  }
> 
> Does this actually work with stack protector enabled?
> boot_init_stack_canary() is inlined while arch_cpu_idle_prepare() is
> not.

Stupid me. No it does of course not. I could have sworn that I tested that,
but obvioulsy not.

I drop that patch, but actually the real question is whether we can drop that
'#ifdef x86' around that boot_init_stack_canary() invocation.

AFAICT, neither arm, arm64 nor mips and sh call it on anything else than the
boot cpu. I can't see why that would be an issue on those architectures and
why it would be a problem if the boot cpu calls it again here.

CC'ed the relevant maintainers. Is there any issue with the patch below?

Thanks,

	tglx

8<------------------

--- a/kernel/sched/idle.c
+++ b/kernel/sched/idle.c
@@ -276,12 +276,6 @@ static void cpu_idle_loop(void)
 void cpu_startup_entry(enum cpuhp_state state)
 {
 	/*
-	 * This #ifdef needs to die, but it's too late in the cycle to
-	 * make this generic (arm and sh have never invoked the canary
-	 * init for the non boot cpus!). Will be fixed in 3.11
-	 */
-#ifdef CONFIG_X86
-	/*
 	 * If we're the non-boot CPU, nothing set the stack canary up
 	 * for us. The boot CPU already has it initialized but no harm
 	 * in doing it again. This is a good place for updating it, as
@@ -289,7 +283,7 @@ void cpu_startup_entry(enum cpuhp_state
 	 * canaries already on the stack wont ever trigger).
 	 */
 	boot_init_stack_canary();
-#endif
+
 	arch_cpu_idle_prepare();
 	cpu_idle_loop();
 }

[toc] | [prev] | [next] | [standalone]


#1346129 — Re: [patch 01/20] idle: Move x86ism out of generic code

FromWill Deacon <will.deacon@arm.com>
Date2016-02-29 20:50 +0100
SubjectRe: [patch 01/20] idle: Move x86ism out of generic code
Message-ID<r7BZo-7lz-27@gated-at.bofh.it>
In reply to#1346124
On Mon, Feb 29, 2016 at 08:35:41PM +0100, Thomas Gleixner wrote:
> On Sat, 27 Feb 2016, Brian Gerst wrote:
> > >         arch_cpu_idle_prepare();
> > >         cpu_idle_loop();
> > >  }
> > 
> > Does this actually work with stack protector enabled?
> > boot_init_stack_canary() is inlined while arch_cpu_idle_prepare() is
> > not.
> 
> Stupid me. No it does of course not. I could have sworn that I tested that,
> but obvioulsy not.
> 
> I drop that patch, but actually the real question is whether we can drop that
> '#ifdef x86' around that boot_init_stack_canary() invocation.
> 
> AFAICT, neither arm, arm64 nor mips and sh call it on anything else than the
> boot cpu. I can't see why that would be an issue on those architectures and
> why it would be a problem if the boot cpu calls it again here.
> 
> CC'ed the relevant maintainers. Is there any issue with the patch below?

On arm[64], the canary is unfortunately global, so I don't think it would
be safe to update it live like this without effectively stopping the
machine and forcing everybody into idle.

Will

[toc] | [prev] | [next] | [standalone]


#1346133 — Re: [patch 01/20] idle: Move x86ism out of generic code

FromThomas Gleixner <tglx@linutronix.de>
Date2016-02-29 21:10 +0100
SubjectRe: [patch 01/20] idle: Move x86ism out of generic code
Message-ID<r7CiK-7H6-5@gated-at.bofh.it>
In reply to#1346129
On Mon, 29 Feb 2016, Will Deacon wrote:

> On Mon, Feb 29, 2016 at 08:35:41PM +0100, Thomas Gleixner wrote:
> > On Sat, 27 Feb 2016, Brian Gerst wrote:
> > > >         arch_cpu_idle_prepare();
> > > >         cpu_idle_loop();
> > > >  }
> > > 
> > > Does this actually work with stack protector enabled?
> > > boot_init_stack_canary() is inlined while arch_cpu_idle_prepare() is
> > > not.
> > 
> > Stupid me. No it does of course not. I could have sworn that I tested that,
> > but obvioulsy not.
> > 
> > I drop that patch, but actually the real question is whether we can drop that
> > '#ifdef x86' around that boot_init_stack_canary() invocation.
> > 
> > AFAICT, neither arm, arm64 nor mips and sh call it on anything else than the
> > boot cpu. I can't see why that would be an issue on those architectures and
> > why it would be a problem if the boot cpu calls it again here.
> > 
> > CC'ed the relevant maintainers. Is there any issue with the patch below?
> 
> On arm[64], the canary is unfortunately global, so I don't think it would
> be safe to update it live like this without effectively stopping the
> machine and forcing everybody into idle.

Thanks for clarification.

       Thomas

[toc] | [prev] | [standalone]


Page 3 of 3 — ← Prev page 1 2 [3]

Back to top | Article view | linux.kernel


csiph-web