[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220718094937.37360-1-zhangpeng.00@bytedance.com>
Date: Mon, 18 Jul 2022 17:49:37 +0800
From: Peng Zhang <zhangpeng.00@...edance.com>
To: mingo@...hat.com, peterz@...radead.org, vincent.guittot@...aro.org,
dietmar.eggemann@....com, bsegall@...gle.com,
linux-kernel@...r.kernel.org
Cc: "zhangpeng.00" <zhangpeng.00@...edance.com>
Subject: [PATCH] sched/fair: optimize entity_tick()
From: "zhangpeng.00" <zhangpeng.00@...edance.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@...edance.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
Powered by blists - more mailing lists