From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Wang Subject: Re: [PATCH v3 10/45] smp: Use get/put_online_cpus_atomic() to prevent CPU offline Date: Tue, 02 Jul 2013 13:32:58 +0800 Message-ID: <51D2660A.8000401@linux.vnet.ibm.com> References: <20130627195136.29830.10445.stgit@srivatsabhat.in.ibm.com> <20130627195418.29830.34958.stgit@srivatsabhat.in.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Return-path: Received: from e23smtp06.au.ibm.com ([202.81.31.148]:60378 "EHLO e23smtp06.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932102Ab3GBFdP (ORCPT ); Tue, 2 Jul 2013 01:33:15 -0400 Received: from /spool/local by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 2 Jul 2013 15:25:51 +1000 In-Reply-To: <20130627195418.29830.34958.stgit@srivatsabhat.in.ibm.com> Sender: linux-pm-owner@vger.kernel.org List-Id: linux-pm@vger.kernel.org To: "Srivatsa S. Bhat" Cc: tglx@linutronix.de, peterz@infradead.org, tj@kernel.org, oleg@redhat.com, paulmck@linux.vnet.ibm.com, rusty@rustcorp.com.au, mingo@kernel.org, akpm@linux-foundation.org, namhyung@kernel.org, walken@google.com, vincent.guittot@linaro.org, laijs@cn.fujitsu.com, David.Laight@aculab.com, rostedt@goodmis.org, xiaoguangrong@linux.vnet.ibm.com, sbw@mit.edu, fweisbec@gmail.com, zhong@linux.vnet.ibm.com, nikunj@linux.vnet.ibm.com, linux-pm@vger.kernel.org, linux-arch@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Wang YanQing , Shaohua Li , Jan Beulich , liguang Hi, Srivatsa On 06/28/2013 03:54 AM, Srivatsa S. Bhat wrote: [snip] > @@ -625,8 +632,9 @@ EXPORT_SYMBOL(on_each_cpu_mask); > * The function might sleep if the GFP flags indicates a non > * atomic allocation is allowed. > * > - * Preemption is disabled to protect against CPUs going offline but not online. > - * CPUs going online during the call will not be seen or sent an IPI. > + * We use get/put_online_cpus_atomic() to protect against CPUs going > + * offline but not online. CPUs going online during the call will > + * not be seen or sent an IPI. I was a little confused about this comment, if the offline-cpu still have chances to become online, then there is chances that we will pick it from for_each_online_cpu(), isn't it? Did I miss some point? Regards, Michael Wang > * > * You must not call this function with disabled interrupts or > * from a hardware interrupt handler or from a bottom half handler. > @@ -641,26 +649,26 @@ void on_each_cpu_cond(bool (*cond_func)(int cpu, void *info), > might_sleep_if(gfp_flags & __GFP_WAIT); > > if (likely(zalloc_cpumask_var(&cpus, (gfp_flags|__GFP_NOWARN)))) { > - preempt_disable(); > + get_online_cpus_atomic(); > for_each_online_cpu(cpu) > if (cond_func(cpu, info)) > cpumask_set_cpu(cpu, cpus); > on_each_cpu_mask(cpus, func, info, wait); > - preempt_enable(); > + put_online_cpus_atomic(); > free_cpumask_var(cpus); > } else { > /* > * No free cpumask, bother. No matter, we'll > * just have to IPI them one by one. > */ > - preempt_disable(); > + get_online_cpus_atomic(); > for_each_online_cpu(cpu) > if (cond_func(cpu, info)) { > ret = smp_call_function_single(cpu, func, > info, wait); > WARN_ON_ONCE(!ret); > } > - preempt_enable(); > + put_online_cpus_atomic(); > } > } > EXPORT_SYMBOL(on_each_cpu_cond); >