From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752241AbbCEWAw (ORCPT ); Thu, 5 Mar 2015 17:00:52 -0500 Received: from e31.co.us.ibm.com ([32.97.110.149]:58173 "EHLO e31.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751321AbbCEWAv (ORCPT ); Thu, 5 Mar 2015 17:00:51 -0500 Date: Thu, 5 Mar 2015 14:00:43 -0800 From: "Paul E. McKenney" To: Boris Ostrovsky Cc: linux-kernel@vger.kernel.org, mingo@kernel.org, laijs@cn.fujitsu.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, dvhart@linux.intel.com, fweisbec@gmail.com, oleg@redhat.com, bobby.prani@gmail.com, x86@kernel.org, Konrad Rzeszutek Wilk , David Vrabel , xen-devel@lists.xenproject.org Subject: Re: [PATCH tip/core/rcu 02/20] x86: Use common outgoing-CPU-notification code Message-ID: <20150305220043.GH5448@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com References: <54F608C4.40405@oracle.com> <20150303194223.GR15405@linux.vnet.ibm.com> <54F615D3.2040802@oracle.com> <20150303212647.GZ15405@linux.vnet.ibm.com> <54F6307A.8040003@oracle.com> <20150303223151.GC15405@linux.vnet.ibm.com> <20150304144336.GA8225@linux.vnet.ibm.com> <54F71CCF.9050509@oracle.com> <20150304152515.GL15405@linux.vnet.ibm.com> <54F8C807.5070103@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54F8C807.5070103@oracle.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15030522-8236-0000-0000-000009F92D28 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 05, 2015 at 04:17:59PM -0500, Boris Ostrovsky wrote: > On 03/04/2015 10:25 AM, Paul E. McKenney wrote: > >On Wed, Mar 04, 2015 at 09:55:11AM -0500, Boris Ostrovsky wrote: > > >>The simple solution is to stop calling native_cpu_die() above but > >>I'd like to use common code in native_cpu_die(). I'll see if I can > >>carve it out without too much damage to x86. > > > >Very good, thank you! I look forward to seeing your patch. > > How about something like this, on top of your original 02/20 patch > (this is copy-paste but hopefully it can be applied): Unfortunately, no joy. :-( I was able to fix a couple of whitespace problems, but it still didn't like this hunk: "@@ -766,12 +778,6 @@". Could you please send the patch as an attachment, post it on the web somewhere, or otherwise get me a clean copy it it? Thanx, Paul > arch/x86/include/asm/smp.h | 1 + > arch/x86/kernel/smpboot.c | 12 +++++++++++- > arch/x86/xen/smp.c | 34 ++++++++++++++++++++-------------- > 3 files changed, 32 insertions(+), 15 deletions(-) > > diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h > index 8cd27e0..a5cb4f6 100644 > --- a/arch/x86/include/asm/smp.h > +++ b/arch/x86/include/asm/smp.h > @@ -155,6 +155,7 @@ void native_smp_prepare_cpus(unsigned int max_cpus); > void native_smp_cpus_done(unsigned int max_cpus); > int native_cpu_up(unsigned int cpunum, struct task_struct *tidle); > int native_cpu_disable(void); > +int common_cpu_die(unsigned int cpu); > void native_cpu_die(unsigned int cpu); > void native_play_dead(void); > void play_dead_common(void); > diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c > index ff24fbd..c8fa349 100644 > --- a/arch/x86/kernel/smpboot.c > +++ b/arch/x86/kernel/smpboot.c > @@ -1345,8 +1345,10 @@ int native_cpu_disable(void) > return 0; > } > > -void native_cpu_die(unsigned int cpu) > +int common_cpu_die(unsigned int cpu) > { > + int ret = 0; > + > /* We don't do anything here: idle task is faking death itself. */ > > /* They ack this in play_dead() by setting CPU_DEAD */ > @@ -1355,7 +1357,15 @@ void native_cpu_die(unsigned int cpu) > pr_info("CPU %u is now offline\n", cpu); > } else { > pr_err("CPU %u didn't die...\n", cpu); > + ret = -1; > } > + > + return ret; > +} > + > +void native_cpu_die(unsigned int cpu) > +{ > + common_cpu_die(cpu); > } > > void play_dead_common(void) > diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c > index e2c7389..1c5e760 100644 > --- a/arch/x86/xen/smp.c > +++ b/arch/x86/xen/smp.c > @@ -455,7 +455,10 @@ static int xen_cpu_up(unsigned int cpu, struct > task_struct *idle) > xen_setup_timer(cpu); > xen_init_lock_cpu(cpu); > > - /* Xen outgoing CPUs need help cleaning up, so -EBUSY is an error. */ > + /* > + * PV VCPUs are always successfully taken down (see 'while' loop > + * in xen_cpu_die()), so -EBUSY is an error. > + */ > rc = cpu_check_up_prepare(cpu); > if (rc) > return rc; > @@ -508,12 +511,11 @@ static void xen_cpu_die(unsigned int cpu) > schedule_timeout(HZ/10); > } > > - (void)cpu_wait_death(cpu, 5); > - /* FIXME: Are the below calls really safe in case of timeout? */ > - > - xen_smp_intr_free(cpu); > - xen_uninit_lock_cpu(cpu); > - xen_teardown_timer(cpu); > + if (common_cpu_die(cpu) == 0) { > + xen_smp_intr_free(cpu); > + xen_uninit_lock_cpu(cpu); > + xen_teardown_timer(cpu); > + } > } > > static void xen_play_dead(void) /* used only with HOTPLUG_CPU */ > @@ -745,6 +747,16 @@ static void __init > xen_hvm_smp_prepare_cpus(unsigned int max_cpus) > static int xen_hvm_cpu_up(unsigned int cpu, struct task_struct *tidle) > { > int rc; > + > + /* > + * This can happen if CPU was offlined earlier and > + * offlining timed out in common_cpu_die(). > + */ > + if (cpu_report_state(cpu) == CPU_DEAD_FROZEN) { > + xen_smp_intr_free(cpu); > + xen_uninit_lock_cpu(cpu); > + } > + > /* > * xen_smp_intr_init() needs to run before native_cpu_up() > * so that IPI vectors are set up on the booting CPU before > @@ -766,12 +778,6 @@ static int xen_hvm_cpu_up(unsigned int cpu, > struct task_struct *tidle) > return rc; > } > > -static void xen_hvm_cpu_die(unsigned int cpu) > -{ > - xen_cpu_die(cpu); > - native_cpu_die(cpu); > -} > - > void __init xen_hvm_smp_init(void) > { > if (!xen_have_vector_callback) > @@ -779,7 +785,7 @@ void __init xen_hvm_smp_init(void) > smp_ops.smp_prepare_cpus = xen_hvm_smp_prepare_cpus; > smp_ops.smp_send_reschedule = xen_smp_send_reschedule; > smp_ops.cpu_up = xen_hvm_cpu_up; > - smp_ops.cpu_die = xen_hvm_cpu_die; > + smp_ops.cpu_die = xen_cpu_die; > smp_ops.send_call_func_ipi = xen_smp_send_call_function_ipi; > smp_ops.send_call_func_single_ipi = > xen_smp_send_call_function_single_ipi; > smp_ops.smp_prepare_boot_cpu = xen_smp_prepare_boot_cpu; > -- > 1.7.7.6 > >