From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Srivatsa S. Bhat" Subject: [RFC PATCH 06/10] yield_to(), cpu-hotplug: Prevent offlining of other CPUs properly Date: Tue, 04 Dec 2012 14:25:23 +0530 Message-ID: <20121204085514.25919.74050.stgit@srivatsabhat.in.ibm.com> References: <20121204085149.25919.29920.stgit@srivatsabhat.in.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20121204085149.25919.29920.stgit@srivatsabhat.in.ibm.com> Sender: linux-kernel-owner@vger.kernel.org To: tglx@linutronix.de, peterz@infradead.org, paulmck@linux.vnet.ibm.com, rusty@rustcorp.com.au, mingo@kernel.org, akpm@linux-foundation.org, namhyung@kernel.org, vincent.guittot@linaro.org Cc: sbw@mit.edu, tj@kernel.org, amit.kucheria@linaro.org, rostedt@goodmis.org, rjw@sisk.pl, srivatsa.bhat@linux.vnet.ibm.com, wangyun@linux.vnet.ibm.com, xiaoguangrong@linux.vnet.ibm.com, nikunj@linux.vnet.ibm.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org List-Id: linux-pm@vger.kernel.org With stop_machine() gone from the CPU offline path, we can't depend on local_irq_save() to prevent CPUs from going offline from under us. Use the get/put_online_cpus_stable_atomic() APIs to prevent CPUs from going offline, while invoking from atomic context. And use the stable online mask while interacting with other CPUs. Signed-off-by: Srivatsa S. Bhat --- kernel/sched/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index c1a5d93..d0b159b 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4312,6 +4312,7 @@ bool __sched yield_to(struct task_struct *p, bool preempt) unsigned long flags; bool yielded = 0; + get_online_cpus_stable_atomic(); local_irq_save(flags); rq = this_rq(); @@ -4339,13 +4340,14 @@ again: * Make p's CPU reschedule; pick_next_entity takes care of * fairness. */ - if (preempt && rq != p_rq) + if (preempt && rq != p_rq && cpu_online_stable(task_cpu(p))) resched_task(p_rq->curr); } out: double_rq_unlock(rq, p_rq); local_irq_restore(flags); + put_online_cpus_stable_atomic(); if (yielded) schedule();