• Shrikanth Hegde's avatar
    sched/fair: Check root_domain::overload value before update · c628db0a
    Shrikanth Hegde authored
    The root_domain::overload flag is 1 when there's any rq
    in the root domain that has 2 or more running tasks. (Ie. it's overloaded.)
    
    The root_domain structure itself is a global structure per cpuset island.
    
    The ::overload flag is maintained the following way:
    
      - Set when adding a second task to the runqueue.
    
      - It is cleared in update_sd_lb_stats() during load balance,
        if none of the rqs have 2 or more running tasks.
    
    This flag is used during newidle balance to see if its worth doing a full
    load balance pass, which can be an expensive operation. If it is set,
    then newidle balance will try to aggressively pull a task.
    
    Since commit:
    
      630246a0 ("sched/fair: Clean-up update_sg_lb_stats parameters")
    
    ::overload is being written unconditionally, even if it has the same
    value. The change in value of this depends on the workload, but on
    typical workloads, it doesn't change all that often: a system is
    either dominantly overloaded for substantial amounts of time, or not.
    
    Extra writes to this semi-global structure cause unnecessary overhead, extra
    bus traffic, etc. - so avoid it as much as possible.
    
    Perf probe stats show that it's worth making this change (numbers are
    with patch applied):
    
    	1M    probe:sched_balance_newidle_L38
    	139   probe:update_sd_lb_stats_L53     <====== 1->0 writes
    	129K  probe:add_nr_running_L12
    	74    probe:add_nr_running_L13         <====== 0->1 writes
    	54K   probe:update_sd_lb_stats_L50     <====== reads
    
    These numbers prove that actual change in the ::overload value is (much) less
    frequent: L50 is much larger at ~54,000 accesses vs L53+L13 of 139+74.
    
    [ mingo: Rewrote the changelog. ]
    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 avatarVincent Guittot <vincent.guittot@linaro.org>
    Cc: Mel Gorman <mgorman@suse.de>
    Link: https://lore.kernel.org/r/20240325054505.201995-2-sshegde@linux.ibm.com
    c628db0a
fair.c 355 KB