sched: Fix imbalance flag reset
sched: Fix imbalance flag reset

The imbalance flag can stay set whereas there is no imbalance.

Let assume that we have 3 tasks that run on a dual cores /dual cluster system.
We will have some idle load balance which are triggered during tick.
Unfortunately, the tick is also used to queue background work so we can reach
the situation where short work has been queued on a CPU which already runs a
task. The load balance will detect this imbalance (2 tasks on 1 CPU and an idle
CPU) and will try to pull the waiting task on the idle CPU. The waiting task is
a worker thread that is pinned on a CPU so an imbalance due to pinned task is
detected and the imbalance flag is set.

Then, we will not be able to clear the flag because we have at most 1 task on
each CPU but the imbalance flag will trig to useless active load balance
between the idle CPU and the busy CPU.

We need to reset of the imbalance flag as soon as we have reached a balanced
state. If all tasks are pinned, we don't consider that as a balanced state and
let the imbalance flag set.

Signed-off-by: Vincent Guittot <eb7d4bc75c19026be4afbcab4b7b388cf01677ff@linaro.org>
Reviewed-by: Preeti U Murthy <437f8f4633f3d09bf55bbcfb98d29bc10a99c7d0@linux.vnet.ibm.com>
Signed-off-by: Peter Zijlstra (Intel) <3fddac958924aef220f202ca567388ddab3f14a8@infradead.org>
Cc: a21938f5d463ddf41aa718934c205ca2cce8ebbc@redhat.com
Cc: 9730d0eb1fe159ba45e897dd28bea4a61e12c1ef@arm.com
Cc: 3cfa3897b7f55b5396b7a47c83b66325184bc9b4@gmx.de
Cc: 408789a210b05fb3b46935e815320d62ba00a06e@linaro.org
Cc: e9fa45941f2ebe89c1b9d6c5f339ab42eadb8567@linaro.org
Cc: b09ca079358248c3ff5bd91ea3781c6808cc6cf2@arm.com
Cc: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>
Link: http://lkml.kernel.org/r/1409051215-16788-2-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