sched: Make sched entity usage tracking scale-invariant
sched: Make sched entity usage tracking scale-invariant

Apply frequency scale-invariance correction factor to usage tracking.

Each segment of the running_avg_sum geometric series is now scaled by the
current frequency so the utilization_avg_contrib of each entity will be
invariant with frequency scaling.

As a result, utilization_load_avg which is the sum of utilization_avg_contrib,
becomes invariant too. So the usage level that is returned by get_cpu_usage(),
stays relative to the max frequency as the cpu_capacity which is is compared against.

Then, we want the keep the load tracking values in a 32-bit type, which implies
that the max value of {runnable|running}_avg_sum must be lower than
2^32/88761=48388 (88761 is the max weigth of a task). As LOAD_AVG_MAX = 47742,
arch_scale_freq_capacity() must return a value less than
(48388/47742) << SCHED_CAPACITY_SHIFT = 1037 (SCHED_SCALE_CAPACITY = 1024).
So we define the range to [0..SCHED_SCALE_CAPACITY] in order to avoid overflow.

Signed-off-by: Morten Rasmussen <4cb630890d50903d357308bfb549e0e4022cee38@arm.com>
Signed-off-by: Vincent Guittot <eb7d4bc75c19026be4afbcab4b7b388cf01677ff@linaro.org>
Signed-off-by: Peter Zijlstra (Intel) <3fddac958924aef220f202ca567388ddab3f14a8@infradead.org>
Cc: Paul Turner <56b59ac50e86208fd62726b53c1d890b9a8ff058@google.com>
Cc: Ben Segall <7dc6b67dc6a1a2319718815cbe6519298041ac95@google.com>
Cc: Ben Segall <7dc6b67dc6a1a2319718815cbe6519298041ac95@google.com>
Cc: 9730d0eb1fe159ba45e897dd28bea4a61e12c1ef@arm.com
Cc: Paul Turner <56b59ac50e86208fd62726b53c1d890b9a8ff058@google.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/1425455186-13451-1-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