From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail177-1.suw61.mandrillapp.com ([198.2.177.1]:5072 "EHLO mail177-1.suw61.mandrillapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752703AbcCAIQN (ORCPT ); Tue, 1 Mar 2016 03:16:13 -0500 Received: from pmta06.mandrill.prod.suw01.rsglab.com (127.0.0.1) by mail177-1.suw61.mandrillapp.com id hql7sq22rtkd for ; Tue, 1 Mar 2016 08:15:53 +0000 (envelope-from ) From: Subject: Patch "sched: Allow balance callbacks for check_class_changed()" has been added to the 3.14-stable tree To: , , , , Cc: , Message-Id: <14568152459357@kroah.com> Date: Tue, 01 Mar 2016 08:15:53 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org List-ID: This is a note to let you know that I've just added the patch titled sched: Allow balance callbacks for check_class_changed() to the 3.14-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: sched-allow-balance-callbacks-for-check_class_changed.patch and it can be found in the queue-3.14 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >>From 4c9a4bc89a9cca8128bce67d6bc8870d6b7ee0b2 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 11 Jun 2015 14:46:39 +0200 Subject: sched: Allow balance callbacks for check_class_changed() From: Peter Zijlstra commit 4c9a4bc89a9cca8128bce67d6bc8870d6b7ee0b2 upstream. In order to remove dropping rq->lock from the switched_{to,from}()/prio_changed() sched_class methods, run the balance callbacks after it. We need to remove dropping rq->lock because its buggy, suppose using sched_setattr()/sched_setscheduler() to change a running task from FIFO to OTHER. By the time we get to switched_from_rt() the task is already enqueued on the cfs runqueues. If switched_from_rt() does pull_rt_task() and drops rq->lock, load-balancing can come in and move our task @p to another rq. The subsequent switched_to_fair() still assumes @p is on @rq and bad things will happen. By using balance callbacks we delay the load-balancing operations {rt,dl}x{push,pull} until we've done all the important work and the task is fully set up. Furthermore, the balance callbacks do not know about @p, therefore they cannot get confused like this. Reported-by: Mike Galbraith Signed-off-by: Peter Zijlstra (Intel) Cc: ktkhai@parallels.com Cc: rostedt@goodmis.org Cc: juri.lelli@gmail.com Cc: pang.xunlei@linaro.org Cc: oleg@redhat.com Cc: wanpeng.li@linux.intel.com Link: http://lkml.kernel.org/r/20150611124742.615343911@infradead.org Signed-off-by: Thomas Gleixner Signed-off-by: Byungchul Park Signed-off-by: Greg Kroah-Hartman --- kernel/sched/core.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -937,6 +937,13 @@ inline int task_curr(const struct task_s return cpu_curr(task_cpu(p)) == p; } +/* + * switched_from, switched_to and prio_changed must _NOT_ drop rq->lock, + * use the balance_callback list if you want balancing. + * + * this means any call to check_class_changed() must be followed by a call to + * balance_callback(). + */ static inline void check_class_changed(struct rq *rq, struct task_struct *p, const struct sched_class *prev_class, int oldprio) @@ -1423,8 +1430,12 @@ ttwu_do_wakeup(struct rq *rq, struct tas p->state = TASK_RUNNING; #ifdef CONFIG_SMP - if (p->sched_class->task_woken) + if (p->sched_class->task_woken) { + /* + * XXX can drop rq->lock; most likely ok. + */ p->sched_class->task_woken(rq, p); + } if (rq->idle_stamp) { u64 delta = rq_clock(rq) - rq->idle_stamp; @@ -3006,7 +3017,11 @@ void rt_mutex_setprio(struct task_struct check_class_changed(rq, p, prev_class, oldprio); out_unlock: + preempt_disable(); /* avoid rq from going away on us */ __task_rq_unlock(rq); + + balance_callback(rq); + preempt_enable(); } #endif @@ -3512,10 +3527,17 @@ change: enqueue_task(rq, p, 0); check_class_changed(rq, p, prev_class, oldprio); + preempt_disable(); /* avoid rq from going away on us */ task_rq_unlock(rq, p, &flags); rt_mutex_adjust_pi(p); + /* + * Run balance callbacks after we've adjusted the PI chain. + */ + balance_callback(rq); + preempt_enable(); + return 0; } Patches currently in stable-queue which might be from peterz@infradead.org are queue-3.14/sched-rt-remove-return-value-from-pull_rt_task.patch queue-3.14/sched-replace-post_schedule-with-a-balance-callback-list.patch queue-3.14/sched-clean-up-idle-task-smp-logic.patch queue-3.14/sched-dl-convert-switched_-from-to-_dl-prio_changed_dl-to-balance-callbacks.patch queue-3.14/sched-dl-remove-return-value-from-pull_dl_task.patch queue-3.14/sched-allow-balance-callbacks-for-check_class_changed.patch queue-3.14/sched-rt-convert-switched_-from-to-_rt-prio_changed_rt-to-balance-callbacks.patch