mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sched/fair: optimize entity_tick()
@ 2022-07-18  9:49 Peng Zhang
  2022-07-18 10:10 ` Peter Zijlstra
  2022-07-18 18:53 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Peng Zhang @ 2022-07-18  9:49 UTC (permalink / raw)
  To: mingo, peterz, vincent.guittot, dietmar.eggemann, bsegall, linux-kernel
  Cc: zhangpeng.00

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-18 18:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-18  9:49 [PATCH] sched/fair: optimize entity_tick() Peng Zhang
2022-07-18 10:10 ` Peter Zijlstra
2022-07-18 18:53 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®