Skip to content
  • Morten Rasmussen's avatar
    sched: Make sched entity usage tracking frequency-invariant · 9c209ef7
    Morten Rasmussen authored
    
    
    Apply frequency scale-invariance correction factor to usage tracking.
    Each segment of the running_load_avg 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 32bits 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.
    
    cc: Paul Turner <pjt@google.com>
    cc: Ben Segall <bsegall@google.com>
    
    Signed-off-by: default avatarMorten Rasmussen <morten.rasmussen@arm.com>
    Signed-off-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
    9c209ef7