Skip to content

Commit

Permalink
sched/fair: optimize entity_tick()
Browse files Browse the repository at this point in the history
entity_tick() will be called to check preemption by calculating each
sched_entity's time_slice in a task group tree from bottom to top.

If a need_resched_flag is set by a checking of a sched_entity,
there is no necessary to check preemption of the sched_entity's
parent and ancestor entity.

So we can test if the need_resched_flag has been set before calling
check_preempt_tick() to avoid unnecessary calculations.

Signed-off-by: zhangpeng.00 <zhangpeng.00@bytedance.com>
  • Loading branch information
zhangpeng.00 authored and intel-lab-lkp committed Jul 18, 2022
1 parent 401e496 commit 9dec20b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/sched/fair.c
Expand Up @@ -4757,7 +4757,7 @@ entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr, int queued)
return;
#endif

if (cfs_rq->nr_running > 1)
if (cfs_rq->nr_running > 1 && !test_tsk_need_resched(rq_of(cfs_rq)->curr))
check_preempt_tick(cfs_rq, curr);
}

Expand Down

0 comments on commit 9dec20b

Please sign in to comment.