Commit bd61c98f authored by Vincent Guittot's avatar Vincent Guittot Committed by Ingo Molnar

sched: Test the CPU's capacity in wake_affine()

Currently the task always wakes affine on this_cpu if the latter is idle.
Before waking up the task on this_cpu, we check that this_cpu capacity is not
significantly reduced because of RT tasks or irq activity.

Use case where the number of irq and/or the time spent under irq is important
will take benefit of this because the task that is woken up by irq or softirq
will not use the same CPU than irq (and softirq) but a idle one.
Signed-off-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: preeti@linux.vnet.ibm.com
Cc: riel@redhat.com
Cc: Morten.Rasmussen@arm.com
Cc: efault@gmx.de
Cc: nicolas.pitre@linaro.org
Cc: daniel.lezcano@linaro.org
Cc: dietmar.eggemann@arm.com
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/1409051215-16788-8-git-send-email-vincent.guittot@linaro.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent d3bfca1a
...@@ -4284,6 +4284,7 @@ static int wake_wide(struct task_struct *p) ...@@ -4284,6 +4284,7 @@ static int wake_wide(struct task_struct *p)
static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync) static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync)
{ {
s64 this_load, load; s64 this_load, load;
s64 this_eff_load, prev_eff_load;
int idx, this_cpu, prev_cpu; int idx, this_cpu, prev_cpu;
struct task_group *tg; struct task_group *tg;
unsigned long weight; unsigned long weight;
...@@ -4327,21 +4328,21 @@ static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync) ...@@ -4327,21 +4328,21 @@ static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync)
* Otherwise check if either cpus are near enough in load to allow this * Otherwise check if either cpus are near enough in load to allow this
* task to be woken on this_cpu. * task to be woken on this_cpu.
*/ */
if (this_load > 0) { this_eff_load = 100;
s64 this_eff_load, prev_eff_load; this_eff_load *= capacity_of(prev_cpu);
prev_eff_load = 100 + (sd->imbalance_pct - 100) / 2;
prev_eff_load *= capacity_of(this_cpu);
this_eff_load = 100; if (this_load > 0) {
this_eff_load *= capacity_of(prev_cpu);
this_eff_load *= this_load + this_eff_load *= this_load +
effective_load(tg, this_cpu, weight, weight); effective_load(tg, this_cpu, weight, weight);
prev_eff_load = 100 + (sd->imbalance_pct - 100) / 2;
prev_eff_load *= capacity_of(this_cpu);
prev_eff_load *= load + effective_load(tg, prev_cpu, 0, weight); prev_eff_load *= load + effective_load(tg, prev_cpu, 0, weight);
}
balanced = this_eff_load <= prev_eff_load;
balanced = this_eff_load <= prev_eff_load;
} else
balanced = true;
schedstat_inc(p, se.statistics.nr_wakeups_affine_attempts); schedstat_inc(p, se.statistics.nr_wakeups_affine_attempts);
if (!balanced) if (!balanced)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment