• Vincent Donnefort's avatar
    sched/fair: Remove task_util from effective utilization in feec() · 3e8c6c9a
    Vincent Donnefort authored
    The energy estimation in find_energy_efficient_cpu() (feec()) relies on
    the computation of the effective utilization for each CPU of a perf domain
    (PD). This effective utilization is then used as an estimation of the busy
    time for this pd. The function effective_cpu_util() which gives this value,
    scales the utilization relative to IRQ pressure on the CPU to take into
    account that the IRQ time is hidden from the task clock. The IRQ scaling is
    as follow:
    
       effective_cpu_util = irq + (cpu_cap - irq)/cpu_cap * util
    
    Where util is the sum of CFS/RT/DL utilization, cpu_cap the capacity of
    the CPU and irq the IRQ avg time.
    
    If now we take as an example a task placement which doesn't raise the OPP
    on the candidate CPU, we can write the energy delta as:
    
      delta = OPPcost/cpu_cap * (effective_cpu_util(cpu_util + task_util) -
                                 effective_cpu_util(cpu_util))
            = OPPcost/cpu_cap * (cpu_cap - irq)/cpu_cap * task_util
    
    We end-up with an energy delta depending on the IRQ avg time, which is a
    problem: first the time spent on IRQs by a CPU has no effect on the
    additional energy that would be consumed by a task. Second, we don't want
    to favour a CPU with a higher IRQ avg time value.
    
    Nonetheless, we need to take the IRQ avg time into account. If a task
    placement raises the PD's frequency, it will increase the energy cost for
    the entire time where the CPU is busy. A solution is to only use
    effective_cpu_util() with the CPU contribution part. The task contribution
    is added separately and scaled according to prev_cpu's IRQ time.
    
    No change for the FREQUENCY_UTIL component of the energy estimation. We
    still want to get the actual frequency that would be selected after the
    task placement.
    Signed-off-by: default avatarVincent Donnefort <vincent.donnefort@arm.com>
    Signed-off-by: default avatarVincent Donnefort <vdonnefort@google.com>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Reviewed-by: default avatarDietmar Eggemann <dietmar.eggemann@arm.com>
    Tested-by: default avatarLukasz Luba <lukasz.luba@arm.com>
    Link: https://lkml.kernel.org/r/20220621090414.433602-7-vdonnefort@google.com
    3e8c6c9a
fair.c 316 KB