[RFC PATCH 14/16] sched: Use energy model in select_idle_sibling

From: Morten Rasmussen
Date: Fri May 23 2014 - 14:17:37 EST


Make select_idle_sibling() consider energy when picking an idle cpu.

Only idle cpus are still considered. A more aggressive energy conserving
approach could go further and consider partly utilized cpus.

Signed-off-by: Morten Rasmussen <morten.rasmussen@xxxxxxx>
---
kernel/sched/fair.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 5a52467..542c2b2 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4644,7 +4644,9 @@ static int select_idle_sibling(struct task_struct *p, int target)
struct sched_domain *sd;
struct sched_group *sg;
int i = task_cpu(p);
+ int target_energy;

+#ifndef CONFIG_SCHED_ENERGY
if (idle_cpu(target))
return target;

@@ -4653,6 +4655,8 @@ static int select_idle_sibling(struct task_struct *p, int target)
*/
if (i != target && cpus_share_cache(i, target) && idle_cpu(i))
return i;
+#endif
+ target_energy = energy_diff_task(target, p);

/*
* Otherwise, iterate the domains and find an elegible idle cpu.
@@ -4666,8 +4670,12 @@ static int select_idle_sibling(struct task_struct *p, int target)
goto next;

for_each_cpu(i, sched_group_cpus(sg)) {
+ int diff;
if (i == target || !idle_cpu(i))
goto next;
+ diff = energy_diff_task(i, p);
+ if (diff > target_energy)
+ goto next;
}

target = cpumask_first_and(sched_group_cpus(sg),
--
1.7.9.5


--
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/