• V
    sched/fair: Fix insertion in rq->leaf_cfs_rq_list · 5a1c0abd
    Vincent Guittot 提交于
    mainline inclusion
    from mainline-5.1-rc1
    commit f6783319737f28e4436a69611853a5a098cbe974
    category: bugfix
    bugzilla: 10996
    CVE: NA
    
    ----------------------------------------
    
    Sargun reported a crash:
    
      "I picked up c40f7d74c741a907cfaeb73a7697081881c497d0 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: NSargun Dhillon <sargun@sargun.me>
    Signed-off-by: NVincent Guittot <vincent.guittot@linaro.org>
    Signed-off-by: NPeter 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: NIngo Molnar <mingo@kernel.org>
    Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
    Reviewed-by: NXie XiuQi <xiexiuqi@huawei.com>
    Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
    5a1c0abd
fair.c 269.7 KB