From patchwork Mon Feb 18 12:42:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Srivatsa S. Bhat" X-Patchwork-Id: 2158661 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 8700CDF25A for ; Mon, 18 Feb 2013 12:59:08 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U7QH6-00079A-4B; Mon, 18 Feb 2013 12:56:52 +0000 Received: from e28smtp04.in.ibm.com ([122.248.162.4]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1U7Q5E-0004PL-Ez for linux-arm-kernel@lists.infradead.org; Mon, 18 Feb 2013 12:44:39 +0000 Received: from /spool/local by e28smtp04.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 18 Feb 2013 18:12:08 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp04.in.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 18 Feb 2013 18:12:06 +0530 Received: from d28relay02.in.ibm.com (d28relay02.in.ibm.com [9.184.220.59]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 025E4E004C for ; Mon, 18 Feb 2013 18:15:27 +0530 (IST) Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay02.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r1ICiSuB26542242 for ; Mon, 18 Feb 2013 18:14:28 +0530 Received: from d28av01.in.ibm.com (loopback [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r1ICiSEr029422 for ; Mon, 18 Feb 2013 12:44:30 GMT Received: from srivatsabhat.in.ibm.com (srivatsabhat.in.ibm.com [9.124.35.204] (may be forged)) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r1ICiSkN029419; Mon, 18 Feb 2013 12:44:28 GMT From: "Srivatsa S. Bhat" Subject: [PATCH v6 30/46] x86/xen: Use get/put_online_cpus_atomic() to prevent CPU offline To: 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 Date: Mon, 18 Feb 2013 18:12:31 +0530 Message-ID: <20130218124231.26245.27495.stgit@srivatsabhat.in.ibm.com> In-Reply-To: <20130218123714.26245.61816.stgit@srivatsabhat.in.ibm.com> References: <20130218123714.26245.61816.stgit@srivatsabhat.in.ibm.com> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13021812-5564-0000-0000-000006A63553 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130218_074437_131621_C6655E95 X-CRM114-Status: GOOD ( 16.34 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [122.248.162.4 listed in list.dnswl.org] 3.0 KHOP_BIG_TO_CC Sent to 10+ recipients instaed of Bcc or a list -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linux-arch@vger.kernel.org, linux@arm.linux.org.uk, nikunj@linux.vnet.ibm.com, linux-pm@vger.kernel.org, fweisbec@gmail.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, rostedt@goodmis.org, xiaoguangrong@linux.vnet.ibm.com, rjw@sisk.pl, sbw@mit.edu, wangyun@linux.vnet.ibm.com, srivatsa.bhat@linux.vnet.ibm.com, netdev@vger.kernel.org, vincent.guittot@linaro.org, walken@google.com, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Once stop_machine() is gone from the CPU offline path, we won't be able to depend on preempt_disable() or local_irq_disable() to prevent CPUs from going offline from under us. Use the get/put_online_cpus_atomic() APIs to prevent CPUs from going offline, while invoking from atomic context. Cc: Konrad Rzeszutek Wilk Cc: Jeremy Fitzhardinge Cc: "H. Peter Anvin" Cc: x86@kernel.org Cc: xen-devel@lists.xensource.com Cc: virtualization@lists.linux-foundation.org Signed-off-by: Srivatsa S. Bhat --- arch/x86/xen/mmu.c | 11 +++++++++-- arch/x86/xen/smp.c | 9 +++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index 01de35c..6a95a15 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c @@ -39,6 +39,7 @@ * Jeremy Fitzhardinge , XenSource Inc, 2007 */ #include +#include #include #include #include @@ -1163,9 +1164,13 @@ static void xen_drop_mm_ref(struct mm_struct *mm) */ static void xen_exit_mmap(struct mm_struct *mm) { - get_cpu(); /* make sure we don't move around */ + /* + * Make sure we don't move around, and prevent CPUs from going + * offline. + */ + get_online_cpus_atomic(); xen_drop_mm_ref(mm); - put_cpu(); + put_online_cpus_atomic(); spin_lock(&mm->page_table_lock); @@ -1371,6 +1376,7 @@ static void xen_flush_tlb_others(const struct cpumask *cpus, args->op.arg2.vcpumask = to_cpumask(args->mask); /* Remove us, and any offline CPUS. */ + get_online_cpus_atomic(); cpumask_and(to_cpumask(args->mask), cpus, cpu_online_mask); cpumask_clear_cpu(smp_processor_id(), to_cpumask(args->mask)); @@ -1383,6 +1389,7 @@ static void xen_flush_tlb_others(const struct cpumask *cpus, MULTI_mmuext_op(mcs.mc, &args->op, 1, NULL, DOMID_SELF); xen_mc_issue(PARAVIRT_LAZY_MMU); + put_online_cpus_atomic(); } static unsigned long xen_read_cr3(void) diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c index 34bc4ce..cb82e71 100644 --- a/arch/x86/xen/smp.c +++ b/arch/x86/xen/smp.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -480,8 +481,10 @@ static void __xen_send_IPI_mask(const struct cpumask *mask, { unsigned cpu; + get_online_cpus_atomic(); for_each_cpu_and(cpu, mask, cpu_online_mask) xen_send_IPI_one(cpu, vector); + put_online_cpus_atomic(); } static void xen_smp_send_call_function_ipi(const struct cpumask *mask) @@ -544,8 +547,10 @@ void xen_send_IPI_all(int vector) { int xen_vector = xen_map_vector(vector); + get_online_cpus_atomic(); if (xen_vector >= 0) __xen_send_IPI_mask(cpu_online_mask, xen_vector); + put_online_cpus_atomic(); } void xen_send_IPI_self(int vector) @@ -565,20 +570,24 @@ void xen_send_IPI_mask_allbutself(const struct cpumask *mask, if (!(num_online_cpus() > 1)) return; + get_online_cpus_atomic(); for_each_cpu_and(cpu, mask, cpu_online_mask) { if (this_cpu == cpu) continue; xen_smp_send_call_function_single_ipi(cpu); } + put_online_cpus_atomic(); } void xen_send_IPI_allbutself(int vector) { int xen_vector = xen_map_vector(vector); + get_online_cpus_atomic(); if (xen_vector >= 0) xen_send_IPI_mask_allbutself(cpu_online_mask, xen_vector); + put_online_cpus_atomic(); } static irqreturn_t xen_call_function_interrupt(int irq, void *dev_id)