lkml.org 
[lkml]   [2010]   [Oct]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[RFC][PATCH 12/22] sched: add runtime reporting for -deadline tasks
From
Date

Make it available for the user-space the total amount of runtime
time it has used from since it became a -deadline task.

This is something that is typically useful for monitoring from
user-space the task CPU usage, and maybe implementing at that level
some more sophisticated scheduling behaviour.

One example is feedback scheduling, where you try to adapt the
scheduling parameters of a task by looking at its behaviour in
a certain interval of time, applying concepts coming from control
engineering.

Signed-off-by: Dario Faggioli <raistlin@linux.it>
---
include/linux/sched.h | 7 +++----
kernel/sched.c | 3 +++
kernel/sched_debug.c | 1 +
kernel/sched_dl.c | 1 +
4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 8ae947b..b6f0635 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1242,14 +1242,15 @@ struct sched_rt_entity {
#endif
};

-#ifdef CONFIG_SCHEDSTATS
struct sched_stats_dl {
+#ifdef CONFIG_SCHEDSTATS
u64 last_dmiss;
u64 last_rorun;
u64 dmiss_max;
u64 rorun_max;
-};
#endif
+ u64 tot_rtime;
+};

struct sched_dl_entity {
struct rb_node rb_node;
@@ -1292,9 +1293,7 @@ struct sched_dl_entity {
*/
struct hrtimer dl_timer;

-#ifdef CONFIG_SCHEDSTATS
struct sched_stats_dl stats;
-#endif
};

struct rcu_node;
diff --git a/kernel/sched.c b/kernel/sched.c
index 63a33f6..19c8c25 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4799,6 +4799,8 @@ __setparam_dl(struct task_struct *p, const struct sched_param_ex *param_ex)
dl_se->flags = param_ex->sched_flags;
dl_se->dl_throttled = 0;
dl_se->dl_new = 1;
+
+ dl_se->stats.tot_rtime = 0;
}

static void
@@ -4812,6 +4814,7 @@ __getparam_dl(struct task_struct *p, struct sched_param_ex *param_ex)
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->used_runtime = ns_to_timespec(dl_se->stats.tot_rtime);
param_ex->curr_deadline = ns_to_timespec(dl_se->deadline);
}

diff --git a/kernel/sched_debug.c b/kernel/sched_debug.c
index f685f18..9bec524 100644
--- a/kernel/sched_debug.c
+++ b/kernel/sched_debug.c
@@ -472,6 +472,7 @@ void proc_sched_show_task(struct task_struct *p, struct seq_file *m)
PN(dl.stats.dmiss_max);
PN(dl.stats.last_rorun);
PN(dl.stats.rorun_max);
+ PN(dl.stats.tot_rtime);
}

{
diff --git a/kernel/sched_dl.c b/kernel/sched_dl.c
index b01aa2a..c4091c9 100644
--- a/kernel/sched_dl.c
+++ b/kernel/sched_dl.c
@@ -535,6 +535,7 @@ static void update_curr_dl(struct rq *rq)

sched_dl_avg_update(rq, delta_exec);

+ dl_se->stats.tot_rtime += delta_exec;
dl_se->runtime -= delta_exec;
if (dl_runtime_exceeded(rq, dl_se)) {
__dequeue_task_dl(rq, curr, 0);
--
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@ekiga.net /
dario.faggioli@jabber.org
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2010-10-29 08:39    [W:0.486 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site