All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] sched/deadline: Prevent rt_time growth to infinity
@ 2014-02-19 22:16 Kirill Tkhai
  2014-02-20 21:22 ` Steven Rostedt
  2014-02-21 10:37 ` Peter Zijlstra
  0 siblings, 2 replies; 14+ messages in thread
From: Kirill Tkhai @ 2014-02-19 22:16 UTC (permalink / raw)
  To: linux-kernel@vger.kernel.org
  Cc: Juri Lelli, Peter Zijlstra, Steven Rostedt, Ingo Molnar

Since deadline tasks share rt bandwidth, we must care about
bandwidth timer set. Otherwise rt_time may grow up to infinity
in update_curr_dl(), if there are no other available RT tasks
on top level bandwidth.

I'm going to decide the problem the way below. Almost untested
because of I skipped almost all of recent patches which haveto be applied from lkml.

Please say, if I skipped anything in idea. Maybe better put
start_top_rt_bandwidth() into set_curr_task_dl()?

---
 kernel/sched/deadline.c |  1 +
 kernel/sched/rt.c       | 16 +++++++++++++++-
 kernel/sched/sched.h    |  1 +
 3 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index ed31ef6..f1d2304 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -720,6 +720,7 @@ void inc_dl_tasks(struct sched_dl_entity *dl_se, struct dl_rq *dl_rq)
 
 	inc_dl_deadline(dl_rq, deadline);
 	inc_dl_migration(dl_se, dl_rq);
+	start_top_rt_bandwidth(rq_of_dl_rq(dl_rq));
 }
 
 static inline
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 72f9ec7..a187eb8 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -726,7 +726,7 @@ static inline int balance_runtime(struct rt_rq *rt_rq)
 
 static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun)
 {
-	int i, idle = 1, throttled = 0;
+	int i, idle = 1, throttled = 0, has_dl_tasks = 0;
 	const struct cpumask *span;
 
 	span = sched_rt_period_mask();
@@ -781,9 +781,15 @@ static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun)
 
 		if (enqueue)
 			sched_rt_rq_enqueue(rt_rq);
+
+		if (rt_rq == &rq->rt && rq->dl.dl_nr_running)
+			has_dl_tasks = 1;
 		raw_spin_unlock(&rq->lock);
 	}
 
+	if (has_dl_tasks)
+		return 0;
+
 	if (!throttled && (!rt_bandwidth_enabled() || rt_b->rt_runtime == RUNTIME_INF))
 		return 1;
 
@@ -1005,6 +1011,10 @@ dec_rt_group(struct sched_rt_entity *rt_se, struct rt_rq *rt_rq)
 	WARN_ON(!rt_rq->rt_nr_running && rt_rq->rt_nr_boosted);
 }
 
+void start_top_rt_bandwidth(struct rq *rq)
+{
+	start_rt_bandwidth(&rq->rt.tg->rt_bandwidth);
+}
 #else /* CONFIG_RT_GROUP_SCHED */
 
 static void
@@ -1016,6 +1026,10 @@ inc_rt_group(struct sched_rt_entity *rt_se, struct rt_rq *rt_rq)
 static inline
 void dec_rt_group(struct sched_rt_entity *rt_se, struct rt_rq *rt_rq) {}
 
+void start_top_rt_bandwidth(struct rq *rq)
+{
+	start_rt_bandwidth(&def_rt_bandwidth);
+}
 #endif /* CONFIG_RT_GROUP_SCHED */
 
 static inline
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 1bf34c2..a20f8f7 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1294,6 +1294,7 @@ static inline void sched_avg_update(struct rq *rq) { }
 #endif
 
 extern void start_bandwidth_timer(struct hrtimer *period_timer, ktime_t period);
+extern void start_top_rt_bandwidth(struct rq *rq);
 
 #ifdef CONFIG_SMP
 #ifdef CONFIG_PREEMPT

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

end of thread, other threads:[~2014-02-27 13:32 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-19 22:16 [RFC] sched/deadline: Prevent rt_time growth to infinity Kirill Tkhai
2014-02-20 21:22 ` Steven Rostedt
2014-02-21 10:37 ` Peter Zijlstra
2014-02-21 11:33   ` Kirill Tkhai
2014-02-21 12:09     ` Kirill Tkhai
2014-02-21 12:44       ` Juri Lelli
2014-02-21 14:25         ` Kirill Tkhai
2014-02-21 16:36   ` Juri Lelli
2014-02-21 16:53     ` Juri Lelli
2014-02-21 23:50       ` Kirill Tkhai
2014-02-22  0:56     ` Kirill Tkhai
2014-02-25 14:15       ` Juri Lelli
2014-02-25 14:58         ` Kirill Tkhai
2014-02-27 13:32         ` [tip:sched/urgent] " tip-bot for Juri Lelli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.