[PATCH 1/1] sched/fair:Reduce unnecessary check preempt in the sched tick
From: qianjun . kernel
Date: Tue Apr 13 2021 - 09:19:12 EST
From: jun qian <qianjun.kernel@xxxxxxxxx>
If it has been determined that the current cpu need resched in the
early stage of for_each_sched_entity, then there is no need to check
preempt in the subsequent se->parent entity_tick.
Signed-off-by: jun qian <qianjun.kernel@xxxxxxxxx>
---
kernel/sched/fair.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 1a68a0536add..c0d135100d54 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4352,8 +4352,13 @@ check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr)
{
unsigned long ideal_runtime, delta_exec;
struct sched_entity *se;
+ struct rq *rq = rq_of(cfs_rq);
s64 delta;
+ /* If the TIF_NEED_RESCHED has been set, it is no need to check again */
+ if (test_tsk_need_resched(rq->curr))
+ return;
+
ideal_runtime = sched_slice(cfs_rq, curr);
delta_exec = curr->sum_exec_runtime - curr->prev_sum_exec_runtime;
if (delta_exec > ideal_runtime) {
--
2.18.2