[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1288334050.8661.150.camel@Palantir>
Date: Fri, 29 Oct 2010 08:34:10 +0200
From: Raistlin <raistlin@...ux.it>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Ingo Molnar <mingo@...e.hu>, Thomas Gleixner <tglx@...utronix.de>,
Steven Rostedt <rostedt@...dmis.org>,
Chris Friesen <cfriesen@...tel.com>, oleg@...hat.com,
Frederic Weisbecker <fweisbec@...il.com>,
Darren Hart <darren@...art.com>,
Johan Eker <johan.eker@...csson.com>,
"p.faure" <p.faure@...tech.ch>,
linux-kernel <linux-kernel@...r.kernel.org>,
Claudio Scordino <claudio@...dence.eu.com>,
michael trimarchi <trimarchi@...is.sssup.it>,
Fabio Checconi <fabio@...dalf.sssup.it>,
Tommaso Cucinotta <cucinotta@...up.it>,
Juri Lelli <juri.lelli@...il.com>,
Nicola Manica <nicola.manica@...i.unitn.it>,
Luca Abeni <luca.abeni@...tn.it>,
Dhaval Giani <dhaval@...is.sssup.it>,
Harald Gustafsson <hgu1972@...il.com>,
paulmck <paulmck@...ux.vnet.ibm.com>
Subject: [RFC][PATCH 09/22] sched: add period support for -deadline tasks
Make it possible to specify a period (different or equal than
deadline) for -deadline tasks.
Signed-off-by: Harald Gustafsson <harald.gustafsson@...csson.com>
Signed-off-by: Dario Faggioli <raistlin@...ux.it>
---
include/linux/sched.h | 1 +
kernel/sched.c | 12 +++++++++++-
kernel/sched_dl.c | 8 ++++++--
3 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index f25d3a6..83fa2b5 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1251,6 +1251,7 @@ struct sched_dl_entity {
*/
u64 dl_runtime; /* maximum runtime for each instance */
u64 dl_deadline; /* relative deadline of each instance */
+ u64 dl_period; /* separation of two instances (period) */
/*
* Actual scheduling parameters. Initialized with the values above,
diff --git a/kernel/sched.c b/kernel/sched.c
index 7f0780c..4491f7d 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2708,6 +2708,7 @@ static void __sched_fork(struct task_struct *p)
hrtimer_init(&p->dl.dl_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
p->dl.dl_runtime = p->dl.runtime = 0;
p->dl.dl_deadline = p->dl.deadline = 0;
+ p->dl.dl_period = 0;
p->dl.flags = 0;
INIT_LIST_HEAD(&p->rt.run_list);
@@ -4789,6 +4790,10 @@ __setparam_dl(struct task_struct *p, const struct sched_param_ex *param_ex)
init_dl_task_timer(dl_se);
dl_se->dl_runtime = timespec_to_ns(¶m_ex->sched_runtime);
dl_se->dl_deadline = timespec_to_ns(¶m_ex->sched_deadline);
+ if (timespec_to_ns(¶m_ex->sched_period) != 0)
+ dl_se->dl_period = timespec_to_ns(¶m_ex->sched_period);
+ else
+ dl_se->dl_period = dl_se->dl_deadline;
dl_se->flags = param_ex->sched_flags;
dl_se->dl_throttled = 0;
dl_se->dl_new = 1;
@@ -4802,6 +4807,7 @@ __getparam_dl(struct task_struct *p, struct sched_param_ex *param_ex)
param_ex->sched_priority = p->rt_priority;
param_ex->sched_runtime = ns_to_timespec(dl_se->dl_runtime);
param_ex->sched_deadline = ns_to_timespec(dl_se->dl_deadline);
+ param_ex->sched_period = ns_to_timespec(dl_se->dl_period);
param_ex->sched_flags = dl_se->flags;
param_ex->curr_runtime = ns_to_timespec(dl_se->runtime);
param_ex->curr_deadline = ns_to_timespec(dl_se->deadline);
@@ -4810,7 +4816,8 @@ __getparam_dl(struct task_struct *p, struct sched_param_ex *param_ex)
/*
* This function validates the new parameters of a -deadline task.
* We ask for the deadline not being zero, and greater or equal
- * than the runtime.
+ * than the runtime, as well as the period of being zero or
+ * not greater than deadline.
*/
static bool
__checkparam_dl(const struct sched_param_ex *prm, bool kthread)
@@ -4822,6 +4829,9 @@ __checkparam_dl(const struct sched_param_ex *prm, bool kthread)
return kthread;
return timespec_to_ns(&prm->sched_deadline) != 0 &&
+ (timespec_to_ns(&prm->sched_period) == 0 ||
+ timespec_compare(&prm->sched_period,
+ &prm->sched_deadline) >= 0) &&
timespec_compare(&prm->sched_deadline,
&prm->sched_runtime) >= 0;
}
diff --git a/kernel/sched_dl.c b/kernel/sched_dl.c
index 1bb4308..31fb771 100644
--- a/kernel/sched_dl.c
+++ b/kernel/sched_dl.c
@@ -263,7 +263,7 @@ static void replenish_dl_entity(struct sched_dl_entity *dl_se)
* arbitrary large.
*/
while (dl_se->runtime <= 0) {
- dl_se->deadline += dl_se->dl_deadline;
+ dl_se->deadline += dl_se->dl_period;
dl_se->runtime += dl_se->dl_runtime;
}
@@ -290,7 +290,11 @@ static void replenish_dl_entity(struct sched_dl_entity *dl_se)
* assigned (function returns true if it can).
*
* For this to hold, we must check if:
- * runtime / (deadline - t) < dl_runtime / dl_deadline .
+ * runtime / (deadline - t) < dl_runtime / dl_period .
+ *
+ * Notice that the bandwidth check is done against the period. For
+ * task with deadline equal to period this is the same of using
+ * dl_deadline instead of dl_period in the equation above.
*/
static bool dl_entity_overflow(struct sched_dl_entity *dl_se, u64 t)
{
--
1.7.2.3
--
<<This happens because I choose it to happen!>> (Raistlin Majere)
----------------------------------------------------------------------
Dario Faggioli, ReTiS Lab, Scuola Superiore Sant'Anna, Pisa (Italy)
http://blog.linux.it/raistlin / raistlin@...ga.net /
dario.faggioli@...ber.org
Download attachment "signature.asc" of type "application/pgp-signature" (199 bytes)
Powered by blists - more mailing lists