sched/fair: enqueue_task_fair optimization
Vincent Guittot
maintainerPATCH v3 1/1 sched/fair: enqueue_task_fair optimization
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.
---
v3 changes:
- updated commit message
- removed an extra }
kernel/sched/fair.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-)
kernel/sched/fair.c +19 -20
@@ -5512,28 +5512,27 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)list_add_leaf_cfs_rq (cfs_rq); } -enqueue_throttle: -if (!se) { -add_nr_running (rq,1 ); -/* -* Since new tasks are assigned an initial util_avg equal to -* half of the spare capacity of their CPU, tiny tasks have the -* ability to cross the overutilized threshold, which will -* result in the load balancer ruining all the task placement -* done by EAS. As a way to mitigate that effect, do not account -* for the first enqueue operation of new tasks during the -* overutilized flag detection. -* -* A better way of solving this problem would be to wait for -* the PELT signals of tasks to converge before taking them -* into account, but that is not straightforward to implement, -* and the following generally works well enough in practice. -*/ -if (flags &ENQUEUE_WAKEUP ) -update_overutilized_status (rq); +/* At this point se is NULL and we are at root level*/ +add_nr_running (rq,1 ); - } +/* +* Since new tasks are assigned an initial util_avg equal to +* half of the spare capacity of their CPU, tiny tasks have the +* ability to cross the overutilized threshold, which will +* result in the load balancer ruining all the task placement +* done by EAS. As a way to mitigate that effect, do not account +* for the first enqueue operation of new tasks during the +* overutilized flag detection. +* +* A better way of solving this problem would be to wait for +* the PELT signals of tasks to converge before taking them +* into account, but that is not straightforward to implement, +* and the following generally works well enough in practice. +*/ +if (flags &ENQUEUE_WAKEUP ) +update_overutilized_status (rq); +enqueue_throttle:if (cfs_bandwidth_used ()) {/* * When bandwidth control is enabled; the cfs_rq_throttled()
Signature · 1 line
2.17.1
A message that is not in the archive (sent off-list or not yet received): BL0PR14MB3779D98D96FA0D30B968B4519ABF0@BL0PR14MB3779.namprd14.prod.outlook.com
Vincent Guittot
maintainerQuoted 53 lines · Tao Zhou
Hi Vincent,
Sorry for the duplicate.
Quoted 34 lines · Vincent Guittot
enqueue_task_fairjumps toenqueue_throttlelabel whencfs_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.Reviewed-by Phil Auld <[email protected]>Signed-off-by Vincent Guittot <[email protected]>---
v3 changes:
- updated commit message
- removed an extra }kernel/sched/fair.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-)kernel/sched/fair.c +0
-10@@ -5512,28 +5512,27 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)list_add_leaf_cfs_rq (cfs_rq); } -enqueue_throttle: -if (!se) { -add_nr_running (rq,1 ); -/* -* Since new tasks are assigned an initial util_avg equal to -* half of the spare capacity of their CPU, tiny tasks have the -* ability to cross the overutilized threshold, which will -* result in the load balancer ruining all the task placement -* done by EAS. As a way to mitigate that effect, do not account -* for the first enqueue operation of new tasks during the kernel/sched/fair.c enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) · line 5515
Quoted 10 lines
kernel/sched/fair.c +1
-9-* overutilized flag detection. -* -* A better way of solving this problem would be to wait for -* the PELT signals of tasks to converge before taking them -* into account, but that is not straightforward to implement, -* and the following generally works well enough in practice. -*/ -if (flags &ENQUEUE_WAKEUP ) -update_overutilized_status (rq); +/* At this point se is NULL and we are at root level*/ The same as another patch, lack one blank at the end of above comment.
Quoted 3 lines
When apply v3 of 'sched/fair: Fix
enqueue_task_fairwarning some more' We need to edit to align to, I don't know why. When I tried to pull some thing to a function not done yet.
I forgot to mention that this patch has been done on top of Phil's one [email protected] and apply on top of it
Quoted 30 lines
Thanks,
TaoQuoted 26 lines
kernel/sched/fair.c +18
-2+add_nr_running (rq,1 ); - } +/* +* Since new tasks are assigned an initial util_avg equal to +* half of the spare capacity of their CPU, tiny tasks have the +* ability to cross the overutilized threshold, which will +* result in the load balancer ruining all the task placement +* done by EAS. As a way to mitigate that effect, do not account +* for the first enqueue operation of new tasks during the +* overutilized flag detection. +* +* A better way of solving this problem would be to wait for +* the PELT signals of tasks to converge before taking them +* into account, but that is not straightforward to implement, +* and the following generally works well enough in practice. +*/ +if (flags &ENQUEUE_WAKEUP ) +update_overutilized_status (rq); +enqueue_throttle:if (cfs_bandwidth_used ()) {/* * When bandwidth control is enabled; the cfs_rq_throttled() -- 2.17.1
[tip: sched/core] sched/fair: Optimize enqueue_task_fair()
In reply to Vincent GuittotThe following commit has been merged into the sched/core branch of tip:
The following commit has been merged into the sched/core branch of tip:
Commit-ID: 7d148be69e3a0eaa9d029a3c51b545e322116a99 Gitweb: https://git.kernel.org/tip/7d148be69e3a0eaa9d029a3c51b545e322116a99 Author: Vincent Guittot <[email protected]> AuthorDate: Wed, 13 May 2020 15:55:02 +02:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Tue, 19 May 2020 20:34:13 +02:00
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.
--- kernel/sched/fair.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-)
kernel/sched/fair.c +19 -20
@@ -5512,28 +5512,27 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)list_add_leaf_cfs_rq (cfs_rq); } -enqueue_throttle: -if (!se) { -add_nr_running (rq,1 ); -/* -* Since new tasks are assigned an initial util_avg equal to -* half of the spare capacity of their CPU, tiny tasks have the -* ability to cross the overutilized threshold, which will -* result in the load balancer ruining all the task placement -* done by EAS. As a way to mitigate that effect, do not account -* for the first enqueue operation of new tasks during the -* overutilized flag detection. -* -* A better way of solving this problem would be to wait for -* the PELT signals of tasks to converge before taking them -* into account, but that is not straightforward to implement, -* and the following generally works well enough in practice. -*/ -if (flags &ENQUEUE_WAKEUP ) -update_overutilized_status (rq); +/* At this point se is NULL and we are at root level*/ +add_nr_running (rq,1 ); - } +/* +* Since new tasks are assigned an initial util_avg equal to +* half of the spare capacity of their CPU, tiny tasks have the +* ability to cross the overutilized threshold, which will +* result in the load balancer ruining all the task placement +* done by EAS. As a way to mitigate that effect, do not account +* for the first enqueue operation of new tasks during the +* overutilized flag detection. +* +* A better way of solving this problem would be to wait for +* the PELT signals of tasks to converge before taking them +* into account, but that is not straightforward to implement, +* and the following generally works well enough in practice. +*/ +if (flags &ENQUEUE_WAKEUP ) +update_overutilized_status (rq); +enqueue_throttle:if (cfs_bandwidth_used ()) {/* * When bandwidth control is enabled; the cfs_rq_throttled()