• Jeffrey Hugo's avatar
    sched/fair: Fix load_balance() affinity redo path · 65a4433a
    Jeffrey Hugo authored
    If load_balance() fails to migrate any tasks because all tasks were
    affined, load_balance() removes the source CPU from consideration and
    attempts to redo and balance among the new subset of CPUs.
    
    There is a bug in this code path where the algorithm considers all active
    CPUs in the system (minus the source that was just masked out).  This is
    not valid for two reasons: some active CPUs may not be in the current
    scheduling domain and one of the active CPUs is dst_cpu. These CPUs should
    not be considered, as we cannot pull load from them.
    
    Instead of failing out of load_balance(), we may end up redoing the search
    with no valid CPUs and incorrectly concluding the domain is balanced.
    Additionally, if the group_imbalance flag was just set, it may also be
    incorrectly unset, thus the flag will not be seen by other CPUs in future
    load_balance() runs as that algorithm intends.
    
    Fix the check by removing CPUs not in the current domain and the dst_cpu
    from considertation, thus limiting the evaluation to valid remaining CPUs
    from which load might be migrated.
    Co-authored-by: default avatarAustin Christ <austinwc@codeaurora.org>
    Co-authored-by: default avatarDietmar Eggemann <dietmar.eggemann@arm.com>
    Tested-by: default avatarTyler Baicar <tbaicar@codeaurora.org>
    Signed-off-by: default avatarJeffrey Hugo <jhugo@codeaurora.org>
    Acked-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
    Cc: Austin Christ <austinwc@codeaurora.org>
    Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Timur Tabi <timur@codeaurora.org>
    Link: http://lkml.kernel.org/r/1496863138-11322-2-git-send-email-jhugo@codeaurora.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
    65a4433a
fair.c 246 KB