Skip to content

Commit fdaba61

Browse files
rikvanrielIngo Molnar
authored andcommitted
sched/fair: Ensure that the CFS parent is added after unthrottling
Ensure that a CFS parent will be in the list whenever one of its children is also in the list. A warning on rq->tmp_alone_branch != &rq->leaf_cfs_rq_list has been reported while running LTP test cfs_bandwidth01. Odin Ugedal found the root cause: $ tree /sys/fs/cgroup/ltp/ -d --charset=ascii /sys/fs/cgroup/ltp/ |-- drain `-- test-6851 `-- level2 |-- level3a | |-- worker1 | `-- worker2 `-- level3b `-- worker3 Timeline (ish): - worker3 gets throttled - level3b is decayed, since it has no more load - level2 get throttled - worker3 get unthrottled - level2 get unthrottled - worker3 is added to list - level3b is not added to list, since nr_running==0 and is decayed [ Vincent Guittot: Rebased and updated to fix for the reported warning. ] Fixes: a7b359f ("sched/fair: Correctly insert cfs_rq's to list on unthrottle") Reported-by: Sachin Sant <[email protected]> Suggested-by: Vincent Guittot <[email protected]> Signed-off-by: Rik van Riel <[email protected]> Signed-off-by: Vincent Guittot <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Tested-by: Sachin Sant <[email protected]> Acked-by: Odin Ugedal <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent a96bfed commit fdaba61

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

kernel/sched/fair.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3298,6 +3298,31 @@ static inline void cfs_rq_util_change(struct cfs_rq *cfs_rq, int flags)
32983298

32993299
#ifdef CONFIG_SMP
33003300
#ifdef CONFIG_FAIR_GROUP_SCHED
3301+
/*
3302+
* Because list_add_leaf_cfs_rq always places a child cfs_rq on the list
3303+
* immediately before a parent cfs_rq, and cfs_rqs are removed from the list
3304+
* bottom-up, we only have to test whether the cfs_rq before us on the list
3305+
* is our child.
3306+
* If cfs_rq is not on the list, test whether a child needs its to be added to
3307+
* connect a branch to the tree * (see list_add_leaf_cfs_rq() for details).
3308+
*/
3309+
static inline bool child_cfs_rq_on_list(struct cfs_rq *cfs_rq)
3310+
{
3311+
struct cfs_rq *prev_cfs_rq;
3312+
struct list_head *prev;
3313+
3314+
if (cfs_rq->on_list) {
3315+
prev = cfs_rq->leaf_cfs_rq_list.prev;
3316+
} else {
3317+
struct rq *rq = rq_of(cfs_rq);
3318+
3319+
prev = rq->tmp_alone_branch;
3320+
}
3321+
3322+
prev_cfs_rq = container_of(prev, struct cfs_rq, leaf_cfs_rq_list);
3323+
3324+
return (prev_cfs_rq->tg->parent == cfs_rq->tg);
3325+
}
33013326

33023327
static inline bool cfs_rq_is_decayed(struct cfs_rq *cfs_rq)
33033328
{
@@ -3313,6 +3338,9 @@ static inline bool cfs_rq_is_decayed(struct cfs_rq *cfs_rq)
33133338
if (cfs_rq->avg.runnable_sum)
33143339
return false;
33153340

3341+
if (child_cfs_rq_on_list(cfs_rq))
3342+
return false;
3343+
33163344
return true;
33173345
}
33183346

0 commit comments

Comments
 (0)