From patchwork Mon Feb 18 12:43:17 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: 2158761 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 BD3B7DF25A for ; Mon, 18 Feb 2013 13:02:05 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U7QJL-0001Vk-NI; Mon, 18 Feb 2013 12:59:11 +0000 Received: from e28smtp01.in.ibm.com ([122.248.162.1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1U7Q5y-0004wQ-V9 for linux-arm-kernel@lists.infradead.org; Mon, 18 Feb 2013 12:45:26 +0000 Received: from /spool/local by e28smtp01.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 18 Feb 2013 18:12:37 +0530 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp01.in.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 18 Feb 2013 18:12:34 +0530 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id 6AAAE3940053 for ; Mon, 18 Feb 2013 18:15:16 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r1ICjE6S31260784 for ; Mon, 18 Feb 2013 18:15:14 +0530 Received: from d28av03.in.ibm.com (loopback [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r1ICjE1N025935 for ; Mon, 18 Feb 2013 23:45:16 +1100 Received: from srivatsabhat.in.ibm.com (srivatsabhat.in.ibm.com [9.124.35.204] (may be forged)) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r1ICjEnW025909; Mon, 18 Feb 2013 23:45:14 +1100 From: "Srivatsa S. Bhat" Subject: [PATCH v6 35/46] ia64: 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:17 +0530 Message-ID: <20130218124317.26245.67004.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-4790-0000-0000-000006F5F471 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130218_074523_868773_CCB7AAE8 X-CRM114-Status: GOOD ( 17.49 ) 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.1 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: Tony Luck Cc: Fenghua Yu Cc: linux-ia64@vger.kernel.org Signed-off-by: Srivatsa S. Bhat --- arch/ia64/kernel/irq_ia64.c | 13 +++++++++++++ arch/ia64/kernel/perfmon.c | 6 ++++++ arch/ia64/kernel/smp.c | 23 ++++++++++++++++------- arch/ia64/mm/tlb.c | 6 ++++-- 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/arch/ia64/kernel/irq_ia64.c b/arch/ia64/kernel/irq_ia64.c index 1034884..d0b4478 100644 --- a/arch/ia64/kernel/irq_ia64.c +++ b/arch/ia64/kernel/irq_ia64.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -190,9 +191,11 @@ static void clear_irq_vector(int irq) { unsigned long flags; + get_online_cpus_atomic(); spin_lock_irqsave(&vector_lock, flags); __clear_irq_vector(irq); spin_unlock_irqrestore(&vector_lock, flags); + put_online_cpus_atomic(); } int @@ -204,6 +207,7 @@ ia64_native_assign_irq_vector (int irq) vector = -ENOSPC; + get_online_cpus_atomic(); spin_lock_irqsave(&vector_lock, flags); for_each_online_cpu(cpu) { domain = vector_allocation_domain(cpu); @@ -218,6 +222,7 @@ ia64_native_assign_irq_vector (int irq) BUG_ON(__bind_irq_vector(irq, vector, domain)); out: spin_unlock_irqrestore(&vector_lock, flags); + put_online_cpus_atomic(); return vector; } @@ -302,9 +307,11 @@ int irq_prepare_move(int irq, int cpu) unsigned long flags; int ret; + get_online_cpus_atomic(); spin_lock_irqsave(&vector_lock, flags); ret = __irq_prepare_move(irq, cpu); spin_unlock_irqrestore(&vector_lock, flags); + put_online_cpus_atomic(); return ret; } @@ -320,11 +327,13 @@ void irq_complete_move(unsigned irq) if (unlikely(cpu_isset(smp_processor_id(), cfg->old_domain))) return; + get_online_cpus_atomic(); cpumask_and(&cleanup_mask, &cfg->old_domain, cpu_online_mask); cfg->move_cleanup_count = cpus_weight(cleanup_mask); for_each_cpu_mask(i, cleanup_mask) platform_send_ipi(i, IA64_IRQ_MOVE_VECTOR, IA64_IPI_DM_INT, 0); cfg->move_in_progress = 0; + put_online_cpus_atomic(); } static irqreturn_t smp_irq_move_cleanup_interrupt(int irq, void *dev_id) @@ -409,6 +418,8 @@ int create_irq(void) cpumask_t domain = CPU_MASK_NONE; irq = vector = -ENOSPC; + + get_online_cpus_atomic(); spin_lock_irqsave(&vector_lock, flags); for_each_online_cpu(cpu) { domain = vector_allocation_domain(cpu); @@ -424,6 +435,8 @@ int create_irq(void) BUG_ON(__bind_irq_vector(irq, vector, domain)); out: spin_unlock_irqrestore(&vector_lock, flags); + put_online_cpus_atomic(); + if (irq >= 0) dynamic_irq_init(irq); return irq; diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c index ea39eba..6c6a029 100644 --- a/arch/ia64/kernel/perfmon.c +++ b/arch/ia64/kernel/perfmon.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -6485,6 +6486,7 @@ pfm_install_alt_pmu_interrupt(pfm_intr_handler_desc_t *hdl) } /* reserve our session */ + get_online_cpus_atomic(); for_each_online_cpu(reserve_cpu) { ret = pfm_reserve_session(NULL, 1, reserve_cpu); if (ret) goto cleanup_reserve; @@ -6500,6 +6502,7 @@ pfm_install_alt_pmu_interrupt(pfm_intr_handler_desc_t *hdl) /* officially change to the alternate interrupt handler */ pfm_alt_intr_handler = hdl; + put_online_cpus_atomic(); spin_unlock(&pfm_alt_install_check); return 0; @@ -6512,6 +6515,7 @@ cleanup_reserve: pfm_unreserve_session(NULL, 1, i); } + put_online_cpus_atomic(); spin_unlock(&pfm_alt_install_check); return ret; @@ -6536,6 +6540,7 @@ pfm_remove_alt_pmu_interrupt(pfm_intr_handler_desc_t *hdl) pfm_alt_intr_handler = NULL; + get_online_cpus_atomic(); ret = on_each_cpu(pfm_alt_restore_pmu_state, NULL, 1); if (ret) { DPRINT(("on_each_cpu() failed: %d\n", ret)); @@ -6545,6 +6550,7 @@ pfm_remove_alt_pmu_interrupt(pfm_intr_handler_desc_t *hdl) pfm_unreserve_session(NULL, 1, i); } + put_online_cpus_atomic(); spin_unlock(&pfm_alt_install_check); return 0; diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c index 9fcd4e6..d9a4636 100644 --- a/arch/ia64/kernel/smp.c +++ b/arch/ia64/kernel/smp.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -154,12 +155,15 @@ send_IPI_single (int dest_cpu, int op) static inline void send_IPI_allbutself (int op) { - unsigned int i; + unsigned int i, cpu; + get_online_cpus_atomic(); + cpu = smp_processor_id(); for_each_online_cpu(i) { - if (i != smp_processor_id()) + if (i != cpu) send_IPI_single(i, op); } + put_online_cpus_atomic(); } /* @@ -170,9 +174,11 @@ send_IPI_mask(const struct cpumask *mask, int op) { unsigned int cpu; + get_online_cpus_atomic(); for_each_cpu(cpu, mask) { send_IPI_single(cpu, op); } + put_online_cpus_atomic(); } /* @@ -183,9 +189,11 @@ send_IPI_all (int op) { int i; + get_online_cpus_atomic(); for_each_online_cpu(i) { send_IPI_single(i, op); } + put_online_cpus_atomic(); } /* @@ -259,7 +267,7 @@ smp_flush_tlb_cpumask(cpumask_t xcpumask) cpumask_t cpumask = xcpumask; int mycpu, cpu, flush_mycpu = 0; - preempt_disable(); + get_online_cpus_atomic(); mycpu = smp_processor_id(); for_each_cpu_mask(cpu, cpumask) @@ -280,7 +288,7 @@ smp_flush_tlb_cpumask(cpumask_t xcpumask) while(counts[cpu] == (local_tlb_flush_counts[cpu].count & 0xffff)) udelay(FLUSH_DELAY); - preempt_enable(); + put_online_cpus_atomic(); } void @@ -293,12 +301,13 @@ void smp_flush_tlb_mm (struct mm_struct *mm) { cpumask_var_t cpus; - preempt_disable(); + + get_online_cpus_atomic(); /* this happens for the common case of a single-threaded fork(): */ if (likely(mm == current->active_mm && atomic_read(&mm->mm_users) == 1)) { local_finish_flush_tlb_mm(mm); - preempt_enable(); + put_online_cpus_atomic(); return; } if (!alloc_cpumask_var(&cpus, GFP_ATOMIC)) { @@ -313,7 +322,7 @@ smp_flush_tlb_mm (struct mm_struct *mm) local_irq_disable(); local_finish_flush_tlb_mm(mm); local_irq_enable(); - preempt_enable(); + put_online_cpus_atomic(); } void arch_send_call_function_single_ipi(int cpu) diff --git a/arch/ia64/mm/tlb.c b/arch/ia64/mm/tlb.c index ed61297..8f03b58 100644 --- a/arch/ia64/mm/tlb.c +++ b/arch/ia64/mm/tlb.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -87,11 +88,12 @@ wrap_mmu_context (struct mm_struct *mm) * can't call flush_tlb_all() here because of race condition * with O(1) scheduler [EF] */ - cpu = get_cpu(); /* prevent preemption/migration */ + get_online_cpus_atomic(); /* prevent preemption/migration */ + cpu = smp_processor_id(); for_each_online_cpu(i) if (i != cpu) per_cpu(ia64_need_tlb_flush, i) = 1; - put_cpu(); + put_online_cpus_atomic(); local_flush_tlb_all(); }