• Vincent Guittot's avatar
    sched/fair: Fix insertion in rq->leaf_cfs_rq_list · 2d935df7
    Vincent Guittot authored
    commit f6783319 upstream.
    
    Sargun reported a crash:
    
      "I picked up c40f7d74 sched/fair: Fix
       infinite loop in update_blocked_averages() by reverting a9e7f654
       and put it on top of 4.19.13. In addition to this, I uninlined
       list_add_leaf_cfs_rq for debugging.
    
       This revealed a new bug that we didn't get to because we kept getting
       crashes from the previous issue. When we are running with cgroups that
       are rapidly changing, with CFS bandwidth control, and in addition
       using the cpusets cgroup, we see this crash. Specifically, it seems to
       occur with cgroups that are throttled and we change the allowed
       cpuset."
    
    The algorithm used to order cfs_rq in rq->leaf_cfs_rq_list assumes that
    it will walk down to root the 1st time a cfs_rq is used and we will finish
    to add either a cfs_rq without parent or a cfs_rq with a parent that is
    already on the list. But this is not always true in presence of throttling.
    Because a cfs_rq can be throttled even if it has never been used but other CPUs
    of the cgroup have already used all the bandwdith, we are not sure to go down to
    the root and add all cfs_rq in the list.
    
    Ensure that all cfs_rq will be added in the list even if they are throttled.
    
    [ mingo: Fix !CGROUPS build. ]
    Reported-by: default avatarSargun Dhillon <sargun@sargun.me>
    Signed-off-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Mike Galbraith <efault@gmx.de>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: tj@kernel.org
    Fixes: 9c2791f9 ("Fix hierarchical order in rq->leaf_cfs_rq_list")
    Link: https://lkml.kernel.org/r/1548825767-10799-1-git-send-email-vincent.guittot@linaro.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
    Cc: Janne Huttunen <janne.huttunen@nokia.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    2d935df7
fair.c 271 KB