[RFCv3 PATCH 43/48] sched: Introduce energy awareness into detach_tasks
From: Morten Rasmussen
Date: Wed Feb 04 2015 - 13:32:58 EST
From: Dietmar Eggemann <dietmar.eggemann@xxxxxxx>
Energy-aware load balancing does not rely on env->imbalance but instead it
evaluates the system-wide energy difference for each task on the src rq by
potentially moving it to the dst rq. If this energy difference is lesser
than zero the task is actually moved from src to dst rq.
cc: Ingo Molnar <mingo@xxxxxxxxxx>
cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Signed-off-by: Dietmar Eggemann <dietmar.eggemann@xxxxxxx>
---
kernel/sched/fair.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 48cd5b5..6b79603 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6095,12 +6095,12 @@ static int detach_tasks(struct lb_env *env)
{
struct list_head *tasks = &env->src_rq->cfs_tasks;
struct task_struct *p;
- unsigned long load;
+ unsigned long load = 0;
int detached = 0;
lockdep_assert_held(&env->src_rq->lock);
- if (env->imbalance <= 0)
+ if (!env->use_ea && env->imbalance <= 0)
return 0;
while (!list_empty(tasks)) {
@@ -6121,6 +6121,20 @@ static int detach_tasks(struct lb_env *env)
if (!can_migrate_task(p, env))
goto next;
+ if (env->use_ea) {
+ struct energy_env eenv = {
+ .src_cpu = env->src_cpu,
+ .dst_cpu = env->dst_cpu,
+ .usage_delta = task_utilization(p),
+ };
+ int e_diff = energy_diff(&eenv);
+
+ if (e_diff >= 0)
+ goto next;
+
+ goto detach;
+ }
+
load = task_h_load(p);
if (sched_feat(LB_MIN) && load < 16 && !env->sd->nr_balance_failed)
@@ -6129,6 +6143,7 @@ static int detach_tasks(struct lb_env *env)
if ((load / 2) > env->imbalance)
goto next;
+detach:
detach_task(p, env);
list_add(&p->se.group_node, &env->tasks);
@@ -6149,7 +6164,7 @@ static int detach_tasks(struct lb_env *env)
* We only want to steal up to the prescribed amount of
* weighted load.
*/
- if (env->imbalance <= 0)
+ if (!env->use_ea && env->imbalance <= 0)
break;
continue;
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/