From patchwork Mon Feb 18 12:43:28 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: 221364 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 6BFFD2C26D7 for ; Tue, 19 Feb 2013 00:07:35 +1100 (EST) Received: from e28smtp07.in.ibm.com (e28smtp07.in.ibm.com [122.248.162.7]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "e28smtp07.in.ibm.com", Issuer "GeoTrust SSL CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id BEDCE2C04C6 for ; Mon, 18 Feb 2013 23:45:33 +1100 (EST) Received: from /spool/local by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 18 Feb 2013 18:12:47 +0530 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp07.in.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 18 Feb 2013 18:12:44 +0530 Received: from d28relay02.in.ibm.com (d28relay02.in.ibm.com [9.184.220.59]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id A74B8394004F for ; Mon, 18 Feb 2013 18:15:28 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay02.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r1ICjQ5531523070 for ; Mon, 18 Feb 2013 18:15:26 +0530 Received: from d28av02.in.ibm.com (loopback [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r1ICjPl3000344 for ; Mon, 18 Feb 2013 23:45:28 +1100 Received: from srivatsabhat.in.ibm.com (srivatsabhat.in.ibm.com [9.124.35.204] (may be forged)) by d28av02.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r1ICjODJ000314; Mon, 18 Feb 2013 23:45:24 +1100 From: "Srivatsa S. Bhat" Subject: [PATCH v6 37/46] MIPS: 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:13:28 +0530 Message-ID: <20130218124328.26245.69487.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-8878-0000-0000-000005EFBCCB 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: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 fom 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: Ralf Baechle Cc: David Daney Cc: linux-mips@linux-mips.org Signed-off-by: Srivatsa S. Bhat --- arch/mips/kernel/cevt-smtc.c | 8 ++++++++ arch/mips/kernel/smp.c | 16 ++++++++-------- arch/mips/kernel/smtc.c | 3 +++ arch/mips/mm/c-octeon.c | 4 ++-- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/arch/mips/kernel/cevt-smtc.c b/arch/mips/kernel/cevt-smtc.c index 2e72d30..6fb311b 100644 --- a/arch/mips/kernel/cevt-smtc.c +++ b/arch/mips/kernel/cevt-smtc.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -84,6 +85,8 @@ static int mips_next_event(unsigned long delta, unsigned long nextcomp = 0L; int vpe = current_cpu_data.vpe_id; int cpu = smp_processor_id(); + + get_online_cpus_atomic(); local_irq_save(flags); mtflags = dmt(); @@ -164,6 +167,7 @@ static int mips_next_event(unsigned long delta, } emt(mtflags); local_irq_restore(flags); + put_online_cpus_atomic(); return 0; } @@ -180,6 +184,7 @@ void smtc_distribute_timer(int vpe) repeat: nextstamp = 0L; + get_online_cpus_atomic(); for_each_online_cpu(cpu) { /* * Find virtual CPUs within the current VPE who have @@ -221,6 +226,9 @@ repeat: } } + + put_online_cpus_atomic() + /* Reprogram for interrupt at next soonest timestamp for VPE */ if (ISVALID(nextstamp)) { write_c0_compare(nextstamp); diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c index 66bf4e2..3828afa 100644 --- a/arch/mips/kernel/smp.c +++ b/arch/mips/kernel/smp.c @@ -248,12 +248,12 @@ static inline void smp_on_other_tlbs(void (*func) (void *info), void *info) static inline void smp_on_each_tlb(void (*func) (void *info), void *info) { - preempt_disable(); + get_online_cpus_atomic(); smp_on_other_tlbs(func, info); func(info); - preempt_enable(); + put_online_cpus_atomic(); } /* @@ -271,7 +271,7 @@ static inline void smp_on_each_tlb(void (*func) (void *info), void *info) void flush_tlb_mm(struct mm_struct *mm) { - preempt_disable(); + get_online_cpus_atomic(); if ((atomic_read(&mm->mm_users) != 1) || (current->mm != mm)) { smp_on_other_tlbs(flush_tlb_mm_ipi, mm); @@ -285,7 +285,7 @@ void flush_tlb_mm(struct mm_struct *mm) } local_flush_tlb_mm(mm); - preempt_enable(); + put_online_cpus_atomic(); } struct flush_tlb_data { @@ -305,7 +305,7 @@ void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned l { struct mm_struct *mm = vma->vm_mm; - preempt_disable(); + get_online_cpus_atomic(); if ((atomic_read(&mm->mm_users) != 1) || (current->mm != mm)) { struct flush_tlb_data fd = { .vma = vma, @@ -323,7 +323,7 @@ void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned l } } local_flush_tlb_range(vma, start, end); - preempt_enable(); + put_online_cpus_atomic(); } static void flush_tlb_kernel_range_ipi(void *info) @@ -352,7 +352,7 @@ static void flush_tlb_page_ipi(void *info) void flush_tlb_page(struct vm_area_struct *vma, unsigned long page) { - preempt_disable(); + get_online_cpus_atomic(); if ((atomic_read(&vma->vm_mm->mm_users) != 1) || (current->mm != vma->vm_mm)) { struct flush_tlb_data fd = { .vma = vma, @@ -369,7 +369,7 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long page) } } local_flush_tlb_page(vma, page); - preempt_enable(); + put_online_cpus_atomic(); } static void flush_tlb_one_ipi(void *info) diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c index 1d47843..caf081e 100644 --- a/arch/mips/kernel/smtc.c +++ b/arch/mips/kernel/smtc.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -1143,6 +1144,7 @@ static irqreturn_t ipi_interrupt(int irq, void *dev_idm) * for the current TC, so we ought not to have to do it explicitly here. */ + get_online_cpus_atomic(); for_each_online_cpu(cpu) { if (cpu_data[cpu].vpe_id != my_vpe) continue; @@ -1179,6 +1181,7 @@ static irqreturn_t ipi_interrupt(int irq, void *dev_idm) } } } + put_online_cpus_atomic(); return IRQ_HANDLED; } diff --git a/arch/mips/mm/c-octeon.c b/arch/mips/mm/c-octeon.c index 6ec04da..cd2c1ce 100644 --- a/arch/mips/mm/c-octeon.c +++ b/arch/mips/mm/c-octeon.c @@ -73,7 +73,7 @@ static void octeon_flush_icache_all_cores(struct vm_area_struct *vma) mb(); octeon_local_flush_icache(); #ifdef CONFIG_SMP - preempt_disable(); + get_online_cpus_atomic(); cpu = smp_processor_id(); /* @@ -88,7 +88,7 @@ static void octeon_flush_icache_all_cores(struct vm_area_struct *vma) for_each_cpu(cpu, &mask) octeon_send_ipi_single(cpu, SMP_ICACHE_FLUSH); - preempt_enable(); + put_online_cpus_atomic(); #endif }