lkml.org 
[lkml]   [2010]   [Jul]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/6] sched: add moving average of time spent servicing SCHED_NORMAL tasks
Date
This patch adds a moving average of time spent servicing SCHED_NORMAL tasks.
This metric is maintained at rq->norm_avg and is similar to rq->rt_avg. This is
metric is used to provide a measure of cpu power available to run SCHED_IDLE
tasks.

Signed-off-by: Nikhil Rao <ncrao@google.com>
---
kernel/sched.c | 12 ++++++++++++
kernel/sched_fair.c | 3 +++
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/kernel/sched.c b/kernel/sched.c
index 26e74e9..d037b6c 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -514,6 +514,7 @@ struct rq {
unsigned long avg_load_per_task;

u64 rt_avg;
+ u64 norm_avg;
u64 age_stamp;
u64 idle_stamp;
u64 avg_idle;
@@ -1263,6 +1264,7 @@ static void sched_avg_update(struct rq *rq)
asm("" : "+rm" (rq->age_stamp));
rq->age_stamp += period;
rq->rt_avg /= 2;
+ rq->norm_avg /= 2;
}
}

@@ -1272,6 +1274,12 @@ static void sched_rt_avg_update(struct rq *rq, u64 rt_delta)
sched_avg_update(rq);
}

+static void sched_norm_avg_update(struct rq *rq, u64 norm_delta)
+{
+ rq->norm_avg += norm_delta;
+ sched_avg_update(rq);
+}
+
#else /* !CONFIG_SMP */
static void resched_task(struct task_struct *p)
{
@@ -1282,6 +1290,10 @@ static void resched_task(struct task_struct *p)
static void sched_rt_avg_update(struct rq *rq, u64 rt_delta)
{
}
+
+static void sched_norm_avg_update(struct rq *rq, u64 norm_delta)
+{
+}
#endif /* CONFIG_SMP */

#if BITS_PER_LONG == 32
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index a878b53..0e25e51 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -543,6 +543,9 @@ static void update_curr(struct cfs_rq *cfs_rq)
trace_sched_stat_runtime(curtask, delta_exec, curr->vruntime);
cpuacct_charge(curtask, delta_exec);
account_group_exec_runtime(curtask, delta_exec);
+
+ if (curtask->policy != SCHED_IDLE)
+ sched_norm_avg_update(task_rq(curtask), delta_exec);
}
}

--
1.7.1


\
 
 \ /
  Last update: 2010-07-30 07:23    [from the cache]
©2003-2011 Jasper Spaans