sched: Move CFS tasks to CPUs with higher capacity
sched: Move CFS tasks to CPUs with higher capacity

When a CPU is used to handle a lot of IRQs or some RT tasks, the remaining
capacity for CFS tasks can be significantly reduced. Once we detect such
situation by comparing cpu_capacity_orig and cpu_capacity, we trig an idle
load balance to check if it's worth moving its tasks on an idle CPU.

It's worth trying to move the task before the CPU is fully utilized to
minimize the preemption by irq or RT tasks.

Once the idle load_balance has selected the busiest CPU, it will look for an
active load balance for only two cases:

  - There is only 1 task on the busiest CPU.

  - We haven't been able to move a task of the busiest rq.

A CPU with a reduced capacity is included in the 1st case, and it's worth to
actively migrate its task if the idle CPU has got more available capacity for
CFS tasks. This test has been added in need_active_balance.

As a sidenote, this will not generate more spurious ilb because we already
trig an ilb if there is more than 1 busy cpu. If this cpu is the only one that
has a task, we will trig the ilb once for migrating the task.

The nohz_kick_needed function has been cleaned up a bit while adding the new
test

env.src_cpu and env.src_rq must be set unconditionnally because they are used
in need_active_balance which is called even if busiest->nr_running equals 1

Signed-off-by: Vincent Guittot <eb7d4bc75c19026be4afbcab4b7b388cf01677ff@linaro.org>
Signed-off-by: Peter Zijlstra (Intel) <3fddac958924aef220f202ca567388ddab3f14a8@infradead.org>
Cc: 9730d0eb1fe159ba45e897dd28bea4a61e12c1ef@arm.com
Cc: b09ca079358248c3ff5bd91ea3781c6808cc6cf2@arm.com
Cc: 3cfa3897b7f55b5396b7a47c83b66325184bc9b4@gmx.de
Cc: 30b3129b1a1b0120e30fdc2f7d8e6560be5d0735@linux.vnet.ibm.com
Cc: 7634f41eea4b949832a0b36548e64a5bd259e2b9@lists.linaro.org
Cc: 408789a210b05fb3b46935e815320d62ba00a06e@linaro.org
Cc: 437f8f4633f3d09bf55bbcfb98d29bc10a99c7d0@linux.vnet.ibm.com
Cc: a21938f5d463ddf41aa718934c205ca2cce8ebbc@redhat.com
Link: http://lkml.kernel.org/r/1425052454-25797-12-git-send-email-eb7d4bc75c19026be4afbcab4b7b388cf01677ff@linaro.org
Signed-off-by: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@kernel.org>

KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs