• Shrikanth Hegde's avatar
    sched/fair: Add EAS checks before updating root_domain::overutilized · be3a51e6
    Shrikanth Hegde authored
    root_domain::overutilized is only used for EAS(energy aware scheduler)
    to decide whether to do load balance or not. It is not used if EAS
    not possible.
    
    Currently enqueue_task_fair and task_tick_fair accesses, sometime updates
    this field. In update_sd_lb_stats it is updated often. This causes cache
    contention due to true sharing and burns a lot of cycles. ::overload and
    ::overutilized are part of the same cacheline. Updating it often invalidates
    the cacheline. That causes access to ::overload to slow down due to
    false sharing. Hence add EAS check before accessing/updating this field.
    EAS check is optimized at compile time or it is a static branch.
    Hence it shouldn't cost much.
    
    With the patch, both enqueue_task_fair and newidle_balance don't show
    up as hot routines in perf profile.
    
      6.8-rc4:
      7.18%  swapper          [kernel.vmlinux]              [k] enqueue_task_fair
      6.78%  s                [kernel.vmlinux]              [k] newidle_balance
    
      +patch:
      0.14%  swapper          [kernel.vmlinux]              [k] enqueue_task_fair
      0.00%  swapper          [kernel.vmlinux]              [k] newidle_balance
    
    While at it: trace_sched_overutilized_tp expect that second argument to
    be bool. So do a int to bool conversion for that.
    
    Fixes: 2802bf3c ("sched/fair: Add over-utilization/tipping point indicator")
    Signed-off-by: default avatarShrikanth Hegde <sshegde@linux.ibm.com>
    Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
    Reviewed-by: default avatarQais Yousef <qyousef@layalina.io>
    Reviewed-by: default avatarSrikar Dronamraju <srikar@linux.ibm.com>
    Reviewed-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
    Link: https://lore.kernel.org/r/20240307085725.444486-2-sshegde@linux.ibm.com
    be3a51e6
fair.c 355 KB