Skip to content

Commit 423d02e

Browse files
Peng WangPeter Zijlstra
authored andcommitted
sched/fair: Optimize dequeue_task_fair()
While looking at enqueue_task_fair and dequeue_task_fair, it occurred to me that dequeue_task_fair can also be optimized as Vincent described in commit 7d148be ("sched/fair: Optimize enqueue_task_fair()"). When encountering throttled cfs_rq, dequeue_throttle label can ensure se not to be NULL, and rq->nr_running remains unchanged, so we can also skip the early balance check. Signed-off-by: Peng Wang <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Vincent Guittot <[email protected]> Link: https://lkml.kernel.org/r/701eef9a40de93dcf5fe7063fd607bca5db38e05.1592287263.git.rocking@linux.alibaba.com
1 parent aa93cd5 commit 423d02e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/sched/fair.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5624,14 +5624,14 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags)
56245624

56255625
}
56265626

5627-
dequeue_throttle:
5628-
if (!se)
5629-
sub_nr_running(rq, 1);
5627+
/* At this point se is NULL and we are at root level*/
5628+
sub_nr_running(rq, 1);
56305629

56315630
/* balance early to pull high priority tasks */
56325631
if (unlikely(!was_sched_idle && sched_idle_rq(rq)))
56335632
rq->next_balance = jiffies;
56345633

5634+
dequeue_throttle:
56355635
util_est_dequeue(&rq->cfs, p, task_sleep);
56365636
hrtick_update(rq);
56375637
}

0 commit comments

Comments
 (0)