Skip to content

Commit 7d148be

Browse files
vingu-linaroPeter Zijlstra
authored andcommitted
sched/fair: Optimize enqueue_task_fair()
enqueue_task_fair jumps to enqueue_throttle label when cfs_rq_of(se) is throttled which means that se can't be NULL in such case and we can move the label after the if (!se) statement. Futhermore, the latter can be removed because se is always NULL when reaching this point. Signed-off-by: Vincent Guittot <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Phil Auld <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 9013196 commit 7d148be

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

kernel/sched/fair.c

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5512,28 +5512,27 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
55125512
list_add_leaf_cfs_rq(cfs_rq);
55135513
}
55145514

5515-
enqueue_throttle:
5516-
if (!se) {
5517-
add_nr_running(rq, 1);
5518-
/*
5519-
* Since new tasks are assigned an initial util_avg equal to
5520-
* half of the spare capacity of their CPU, tiny tasks have the
5521-
* ability to cross the overutilized threshold, which will
5522-
* result in the load balancer ruining all the task placement
5523-
* done by EAS. As a way to mitigate that effect, do not account
5524-
* for the first enqueue operation of new tasks during the
5525-
* overutilized flag detection.
5526-
*
5527-
* A better way of solving this problem would be to wait for
5528-
* the PELT signals of tasks to converge before taking them
5529-
* into account, but that is not straightforward to implement,
5530-
* and the following generally works well enough in practice.
5531-
*/
5532-
if (flags & ENQUEUE_WAKEUP)
5533-
update_overutilized_status(rq);
5515+
/* At this point se is NULL and we are at root level*/
5516+
add_nr_running(rq, 1);
55345517

5535-
}
5518+
/*
5519+
* Since new tasks are assigned an initial util_avg equal to
5520+
* half of the spare capacity of their CPU, tiny tasks have the
5521+
* ability to cross the overutilized threshold, which will
5522+
* result in the load balancer ruining all the task placement
5523+
* done by EAS. As a way to mitigate that effect, do not account
5524+
* for the first enqueue operation of new tasks during the
5525+
* overutilized flag detection.
5526+
*
5527+
* A better way of solving this problem would be to wait for
5528+
* the PELT signals of tasks to converge before taking them
5529+
* into account, but that is not straightforward to implement,
5530+
* and the following generally works well enough in practice.
5531+
*/
5532+
if (flags & ENQUEUE_WAKEUP)
5533+
update_overutilized_status(rq);
55365534

5535+
enqueue_throttle:
55375536
if (cfs_bandwidth_used()) {
55385537
/*
55395538
* When bandwidth control is enabled; the cfs_rq_throttled()

0 commit comments

Comments
 (0)