Prev: [PATCH 4/6] sched: add sched_idle_balance argument to lb functions
Next: [PATCH 0/6] [RFC] Large weight differential leads to inefficient load balancing
From: Nikhil Rao on 30 Jul 2010 01:30 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(a)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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ |