• Vincent Guittot's avatar
    sched/pelt: Avoid underestimation of task utilization · 50181c0c
    Vincent Guittot authored
    
    
    Lukasz Luba reported that a thread's util_est can significantly decrease as
    a result of sharing the CPU with other threads.
    
    The use case can be easily reproduced with a periodic task TA that runs 1ms
    and sleeps 100us. When the task is alone on the CPU, its max utilization and
    its util_est is around 888. If another similar task starts to run on the
    same CPU, TA will have to share the CPU runtime and its maximum utilization
    will decrease around half the CPU capacity (512) then TA's util_est will
    follow this new maximum trend which is only the result of sharing the CPU
    with others tasks.
    
    Such situation can be detected with runnable_avg wich is close or
    equal to util_avg when TA is alone, but increases above util_avg when TA
    shares the CPU with other threads and wait on the runqueue.
    
    [ We prefer an util_est that overestimate rather than under estimate
      because in 1st case we will not provide enough performance to the
      task which will remain under-provisioned, whereas in the other case we
      will create some idle time which will enable to reduce contention and
      as a result reduces the util_est so the overestimate will be transient
      whereas the underestimate will remain. ]
    
    [ mingo: Refined the changelog, added comments from the LKML discussion. ]
    Reported-by: default avatarLukasz Luba <lukasz.luba@arm.com>
    Signed-off-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
    Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
    Link: https://lore.kernel.org/lkml/CAKfTPtDd-HhF-YiNTtL9i5k0PfJbF819Yxu4YquzfXgwi7voyw@mail.gmail.com/#t
    Link: https://lore.kernel.org/r/20231122140119.472110-1-vincent.guittot@linaro.org
    Cc: Hongyan Xia <hongyan.xia2@arm.com>
    50181c0c
fair.c 352 KB