lkml.org 
[lkml]   [2022]   [Jul]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] sched/fair: optimize entity_tick()
Date
From: "zhangpeng.00" <zhangpeng.00@bytedance.com>

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>
---
kernel/sched/fair.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index a78d2e3b9d49..ee23afe22ac7 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -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);
}

--
2.20.1
\
 
 \ /
  Last update: 2022-07-18 11:50    [W:0.031 / U:0.292 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site