From patchwork Thu Jun 27 19:54:59 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: 255179 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 5EEFE2C08EA for ; Fri, 28 Jun 2013 06:09:31 +1000 (EST) Received: from e23smtp07.au.ibm.com (e23smtp07.au.ibm.com [202.81.31.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "e23smtp07.au.ibm.com", Issuer "GeoTrust SSL CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 815512C05B8 for ; Fri, 28 Jun 2013 05:58:30 +1000 (EST) Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 28 Jun 2013 05:46:52 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp07.au.ibm.com (202.81.31.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 28 Jun 2013 05:46:51 +1000 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [9.190.235.21]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id B6E062BB0053 for ; Fri, 28 Jun 2013 05:58:27 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r5RJwIww8520080 for ; Fri, 28 Jun 2013 05:58:18 +1000 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r5RJwPra016248 for ; Fri, 28 Jun 2013 05:58:27 +1000 Received: from srivatsabhat.in.ibm.com ([9.79.209.72]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r5RJwDp6016049; Fri, 28 Jun 2013 05:58:19 +1000 From: "Srivatsa S. Bhat" Subject: [PATCH v3 15/45] sched/rt: 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, walken@google.com, vincent.guittot@linaro.org, laijs@cn.fujitsu.com, David.Laight@aculab.com Date: Fri, 28 Jun 2013 01:24:59 +0530 Message-ID: <20130627195458.29830.25978.stgit@srivatsabhat.in.ibm.com> In-Reply-To: <20130627195136.29830.10445.stgit@srivatsabhat.in.ibm.com> References: <20130627195136.29830.10445.stgit@srivatsabhat.in.ibm.com> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13062719-0260-0000-0000-0000033B2F52 Cc: linux-arch@vger.kernel.org, nikunj@linux.vnet.ibm.com, zhong@linux.vnet.ibm.com, linux-pm@vger.kernel.org, Peter Zijlstra , fweisbec@gmail.com, linux-kernel@vger.kernel.org, rostedt@goodmis.org, xiaoguangrong@linux.vnet.ibm.com, sbw@mit.edu, Ingo Molnar , wangyun@linux.vnet.ibm.com, "Srivatsa S. Bhat" , netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.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 disabling preemption 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: Ingo Molnar Cc: Peter Zijlstra Signed-off-by: Srivatsa S. Bhat --- kernel/sched/rt.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 01970c8..03d9f38 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -6,6 +6,7 @@ #include "sched.h" #include +#include int sched_rr_timeslice = RR_TIMESLICE; @@ -28,7 +29,9 @@ static enum hrtimer_restart sched_rt_period_timer(struct hrtimer *timer) if (!overrun) break; + get_online_cpus_atomic(); idle = do_sched_rt_period_timer(rt_b, overrun); + put_online_cpus_atomic(); } return idle ? HRTIMER_NORESTART : HRTIMER_RESTART; @@ -547,6 +550,7 @@ static int do_balance_runtime(struct rt_rq *rt_rq) int i, weight, more = 0; u64 rt_period; + get_online_cpus_atomic(); weight = cpumask_weight(rd->span); raw_spin_lock(&rt_b->rt_runtime_lock); @@ -588,6 +592,7 @@ next: raw_spin_unlock(&iter->rt_runtime_lock); } raw_spin_unlock(&rt_b->rt_runtime_lock); + put_online_cpus_atomic(); return more; } @@ -1168,6 +1173,10 @@ static void yield_task_rt(struct rq *rq) #ifdef CONFIG_SMP static int find_lowest_rq(struct task_struct *task); +/* + * Must be called within get/put_online_cpus_atomic(), to prevent CPUs + * from going offline from under us. + */ static int select_task_rq_rt(struct task_struct *p, int sd_flag, int flags) { @@ -1561,6 +1570,8 @@ retry: return 0; } + get_online_cpus_atomic(); + /* We might release rq lock */ get_task_struct(next_task); @@ -1611,6 +1622,7 @@ retry: out: put_task_struct(next_task); + put_online_cpus_atomic(); return ret; } @@ -1630,6 +1642,7 @@ static int pull_rt_task(struct rq *this_rq) if (likely(!rt_overloaded(this_rq))) return 0; + get_online_cpus_atomic(); for_each_cpu(cpu, this_rq->rd->rto_mask) { if (this_cpu == cpu) continue; @@ -1695,6 +1708,7 @@ skip: double_unlock_balance(this_rq, src_rq); } + put_online_cpus_atomic(); return ret; }