• Lukasz Luba's avatar
    PM: EM: Optimize em_cpu_energy() and remove division · 1b600da5
    Lukasz Luba authored
    The Energy Model (EM) can be modified at runtime which brings new
    possibilities. The em_cpu_energy() is called by the Energy Aware Scheduler
    (EAS) in its hot path. The energy calculation uses power value for
    a given performance state (ps) and the CPU busy time as percentage for that
    given frequency.
    
    It is possible to avoid the division by 'scale_cpu' at runtime, because
    EM is updated whenever new max capacity CPU is set in the system.
    
    Use that feature and do the needed division during the calculation of the
    coefficient 'ps->cost'. That enhanced 'ps->cost' value can be then just
    multiplied simply by utilization:
    
    pd_nrg = ps->cost * \Sum cpu_util
    
    to get the needed energy for whole Performance Domain (PD).
    
    With this optimization and earlier removal of map_util_freq(), the
    em_cpu_energy() should run faster on the Big CPU by 1.43x and on the Little
    CPU by 1.69x (RockPi 4B board).
    Reviewed-by: default avatarDietmar Eggemann <dietmar.eggemann@arm.com>
    Tested-by: default avatarDietmar Eggemann <dietmar.eggemann@arm.com>
    Signed-off-by: default avatarLukasz Luba <lukasz.luba@arm.com>
    Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    1b600da5
energy_model.c 17.7 KB