sched: save to call pick_eevdf when TIF_NEED_RESCHED is set

Message ID 20240105040159.5026-1-zegao@tencent.com
State New
Headers
Series sched: save to call pick_eevdf when TIF_NEED_RESCHED is set |

Commit Message

Ze Gao Jan. 5, 2024, 4:01 a.m. UTC
  We now can have TIF_NEED_RESCHED set from update_curr()
in check_preempt_wakeup_fair(), so check to save to call
pick_eevdf once it's set and defer the possible picking
to where schedule() is called.

Signed-off-by: Ze Gao <zegao@tencent.com>
---
 kernel/sched/fair.c | 6 ++++++
 1 file changed, 6 insertions(+)
  

Patch

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index d7a3c63a2171..28b2860e1f09 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8273,6 +8273,12 @@  static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, int
 	cfs_rq = cfs_rq_of(se);
 	update_curr(cfs_rq);
 
+	/*
+	 * We can come here with TIF_NEED_RESCHED already set from update_curr,
+	 * check to save one call to pick_eevdf if it's set.
+	 */
+	if (test_tsk_need_resched(curr))
+		return;
 	/*
 	 * XXX pick_eevdf(cfs_rq) != se ?
 	 */