linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sched/rt: fix SCHED_RR across cgroups
@ 2012-05-17  4:34 Colin Cross
  2012-05-18  8:56 ` Peter Zijlstra
  2012-05-30 13:40 ` [tip:sched/urgent] sched/rt: Fix " tip-bot for Colin Cross
  0 siblings, 2 replies; 12+ messages in thread
From: Colin Cross @ 2012-05-17  4:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: Colin Cross, Ingo Molnar, Peter Zijlstra, Steven Rostedt,
	Thomas Gleixner, Hillf Danton

task_tick_rt has an optimization to only reschedule SCHED_RR tasks
if they were the only element on their rq.  However, with cgroups
a SCHED_RR task could be the only element on its per-cgroup rq but
still be competing with other SCHED_RR tasks in its parent's
cgroup.  In this case, the SCHED_RR task in the child cgroup would
never yield at the end of its timeslice.  If the child cgroup
rt_runtime_us was the same as the parent cgroup rt_runtime_us,
the task in the parent cgroup would starve completely.

Modify task_tick_rt to check that the task is the only task on its
rq, and that the each of the scheduling entities of its ancestors
is also the only entity on its rq.

Signed-off-by: Colin Cross <ccross@android.com>
---
 kernel/sched/rt.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 44af55e..8f32475 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -1983,6 +1983,8 @@ static void watchdog(struct rq *rq, struct task_struct *p)
 
 static void task_tick_rt(struct rq *rq, struct task_struct *p, int queued)
 {
+	struct sched_rt_entity *rt_se = &p->rt;
+
 	update_curr_rt(rq);
 
 	watchdog(rq, p);
@@ -2000,12 +2002,15 @@ static void task_tick_rt(struct rq *rq, struct task_struct *p, int queued)
 	p->rt.time_slice = RR_TIMESLICE;
 
 	/*
-	 * Requeue to the end of queue if we are not the only element
-	 * on the queue:
+	 * Requeue to the end of queue if we (and all of our ancestors) are the
+	 * only element on the queue
 	 */
-	if (p->rt.run_list.prev != p->rt.run_list.next) {
-		requeue_task_rt(rq, p, 0);
-		set_tsk_need_resched(p);
+	for_each_sched_rt_entity(rt_se) {
+		if (rt_se->run_list.prev != rt_se->run_list.next) {
+			requeue_task_rt(rq, p, 0);
+			set_tsk_need_resched(p);
+			return;
+		}
 	}
 }
 
-- 
1.7.7.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-05-30 13:40 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-17  4:34 [PATCH] sched/rt: fix SCHED_RR across cgroups Colin Cross
2012-05-18  8:56 ` Peter Zijlstra
2012-05-18 17:52   ` Colin Cross
2012-05-18 18:37     ` Peter Zijlstra
2012-05-19  0:13       ` Colin Cross
2012-05-19 13:11         ` Dario Faggioli
2012-05-19 20:37           ` Colin Cross
2012-05-23 13:32             ` Dario Faggioli
2012-05-25 11:52               ` Peter Zijlstra
2012-05-25 13:12                 ` Steven Rostedt
2012-05-25 17:55                   ` Paul E. McKenney
2012-05-30 13:40 ` [tip:sched/urgent] sched/rt: Fix " tip-bot for Colin Cross

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).