From patchwork Tue Jan 22 07:42:50 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: 2016931 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id E52D23FCDE for ; Tue, 22 Jan 2013 07:55:30 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TxYew-0006ns-Ro; Tue, 22 Jan 2013 07:52:43 +0000 Received: from e23smtp04.au.ibm.com ([202.81.31.146]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TxYXU-00080E-Fh for linux-arm-kernel@lists.infradead.org; Tue, 22 Jan 2013 07:45:02 +0000 Received: from /spool/local by e23smtp04.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 22 Jan 2013 17:37:00 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp04.au.ibm.com (202.81.31.210) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 22 Jan 2013 17:36:57 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 441BB2BB004A for ; Tue, 22 Jan 2013 18:44:53 +1100 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r0M7WxUe59179078 for ; Tue, 22 Jan 2013 18:32:59 +1100 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r0M7ipkf018702 for ; Tue, 22 Jan 2013 18:44:52 +1100 Received: from srivatsabhat.in.ibm.com (srivatsabhat.in.ibm.com [9.124.35.112]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r0M7iZIp018395; Tue, 22 Jan 2013 18:44:37 +1100 From: "Srivatsa S. Bhat" Subject: [PATCH v5 36/45] 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: Tue, 22 Jan 2013 13:12:50 +0530 Message-ID: <20130122074245.13822.71786.stgit@srivatsabhat.in.ibm.com> In-Reply-To: <20130122073210.13822.50434.stgit@srivatsabhat.in.ibm.com> References: <20130122073210.13822.50434.stgit@srivatsabhat.in.ibm.com> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13012207-9264-0000-0000-0000030B2687 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130122_024501_630581_69E333D2 X-CRM114-Status: GOOD ( 19.52 ) 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 [202.81.31.146 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, 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 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 }