From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754921AbcCBW52 (ORCPT ); Wed, 2 Mar 2016 17:57:28 -0500 Received: from outgoing.csail.mit.edu ([128.30.2.149]:35682 "EHLO outgoing.csail.mit.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751652AbcCBW5Y (ORCPT ); Wed, 2 Mar 2016 17:57:24 -0500 X-Greylist: delayed 1310 seconds by postgrey-1.27 at vger.kernel.org; Wed, 02 Mar 2016 17:57:24 EST Subject: Re: [tip:smp/hotplug] cpu/hotplug: Restructure cpu_up code To: tj@kernel.org, rafael.j.wysocki@intel.com, pjt@google.com, bigeasy@linutronix.de, arjan@linux.intel.com, rostedt@goodmis.org, riel@redhat.com, paulmck@linux.vnet.ibm.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, mingo@kernel.org, akpm@linux-foundation.org, srivatsa@mit.edu, peterz@infradead.org, torvalds@linux-foundation.org, oleg@redhat.com, hpa@zytor.com, rusty@rustcorp.com.au, linux-tip-commits@vger.kernel.org References: <20160226182340.429389195@linutronix.de> From: "Srivatsa S. Bhat" Message-ID: <56D76AE7.6020003@csail.mit.edu> Date: Wed, 2 Mar 2016 17:36:23 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/1/16 2:52 PM, tip-bot for Thomas Gleixner wrote: > Commit-ID: ba997462435f48ad1501320e9da8770fd40c59b1 > Gitweb: http://git.kernel.org/tip/ba997462435f48ad1501320e9da8770fd40c59b1 > Author: Thomas Gleixner > AuthorDate: Fri, 26 Feb 2016 18:43:24 +0000 > Committer: Thomas Gleixner > CommitDate: Tue, 1 Mar 2016 20:36:53 +0100 > > cpu/hotplug: Restructure cpu_up code > > Split out into separate functions, so we can convert it to a state machine. > > Signed-off-by: Thomas Gleixner > Cc: linux-arch@vger.kernel.org > Cc: Rik van Riel > Cc: Rafael Wysocki > Cc: "Srivatsa S. Bhat" > Cc: Peter Zijlstra > Cc: Arjan van de Ven > Cc: Sebastian Siewior > Cc: Rusty Russell > Cc: Steven Rostedt > Cc: Oleg Nesterov > Cc: Tejun Heo > Cc: Andrew Morton > Cc: Paul McKenney > Cc: Linus Torvalds > Cc: Paul Turner > Link: http://lkml.kernel.org/r/20160226182340.429389195@linutronix.de > Signed-off-by: Thomas Gleixner > --- Reviewed-by: Srivatsa S. Bhat Regards, Srivatsa S. Bhat > kernel/cpu.c | 69 +++++++++++++++++++++++++++++++++++++++++------------------- > 1 file changed, 47 insertions(+), 22 deletions(-) > > diff --git a/kernel/cpu.c b/kernel/cpu.c > index 41a6cb8..15a4136 100644 > --- a/kernel/cpu.c > +++ b/kernel/cpu.c > @@ -228,6 +228,43 @@ static int cpu_notify(unsigned long val, unsigned int cpu) > return __cpu_notify(val, cpu, -1, NULL); > } > > +/* Notifier wrappers for transitioning to state machine */ > +static int notify_prepare(unsigned int cpu) > +{ > + int nr_calls = 0; > + int ret; > + > + ret = __cpu_notify(CPU_UP_PREPARE, cpu, -1, &nr_calls); > + if (ret) { > + nr_calls--; > + printk(KERN_WARNING "%s: attempt to bring up CPU %u failed\n", > + __func__, cpu); > + __cpu_notify(CPU_UP_CANCELED, cpu, nr_calls, NULL); > + } > + return ret; > +} > + > +static int notify_online(unsigned int cpu) > +{ > + cpu_notify(CPU_ONLINE, cpu); > + return 0; > +} > + > +static int bringup_cpu(unsigned int cpu) > +{ > + struct task_struct *idle = idle_thread_get(cpu); > + int ret; > + > + /* Arch-specific enabling code. */ > + ret = __cpu_up(cpu, idle); > + if (ret) { > + cpu_notify(CPU_UP_CANCELED, cpu); > + return ret; > + } > + BUG_ON(!cpu_online(cpu)); > + return 0; > +} > + > #ifdef CONFIG_HOTPLUG_CPU > > static void cpu_notify_nofail(unsigned long val, unsigned int cpu) > @@ -481,7 +518,7 @@ void smpboot_thread_init(void) > static int _cpu_up(unsigned int cpu, int tasks_frozen) > { > struct task_struct *idle; > - int ret, nr_calls = 0; > + int ret; > > cpu_hotplug_begin(); > > @@ -496,33 +533,21 @@ static int _cpu_up(unsigned int cpu, int tasks_frozen) > goto out; > } > > + cpuhp_tasks_frozen = tasks_frozen; > + > ret = smpboot_create_threads(cpu); > if (ret) > goto out; > > - cpuhp_tasks_frozen = tasks_frozen; > - > - ret = __cpu_notify(CPU_UP_PREPARE, cpu, -1, &nr_calls); > - if (ret) { > - nr_calls--; > - pr_warn("%s: attempt to bring up CPU %u failed\n", > - __func__, cpu); > - goto out_notify; > - } > - > - /* Arch-specific enabling code. */ > - ret = __cpu_up(cpu, idle); > - > - if (ret != 0) > - goto out_notify; > - BUG_ON(!cpu_online(cpu)); > + ret = notify_prepare(cpu); > + if (ret) > + goto out; > > - /* Now call notifier in preparation. */ > - cpu_notify(CPU_ONLINE, cpu); > + ret = bringup_cpu(cpu); > + if (ret) > + goto out; > > -out_notify: > - if (ret != 0) > - __cpu_notify(CPU_UP_CANCELED, cpu, nr_calls, NULL); > + notify_online(cpu); > out: > cpu_hotplug_done(); > >