The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] sched/fair: align proxy wakeup buddy handling with EEVDF
@ 2026-07-06  2:34 zhidao su (Xiaomi)
  2026-07-06  8:16 ` Vincent Guittot
  0 siblings, 1 reply; 3+ messages in thread
From: zhidao su (Xiaomi) @ 2026-07-06  2:34 UTC (permalink / raw)
  To: mingo, peterz
  Cc: juri.lelli, vincent.guittot, dietmar.eggemann, rostedt, bsegall,
	mgorman, vschneid, kprateek.nayak, jstultz, linux-kernel,
	zhidao su (Xiaomi)

Proxy execution still nominates a newly woken task as NEXT_BUDDY
before the wakeup path has passed the same policy and EEVDF
eligibility gates used by the updated fair scheduler wakeup logic.

Move the NEXT_BUDDY nomination later in check_preempt_wakeup_fair()
so throttled, already-rescheduled, disabled-preemption, idle-class,
and non-normal wakeups return before updating cfs_rq->next.

Also clear stale buddy state when PREEMPT_SHORT overrides slice
protection.

Signed-off-by: zhidao su (Xiaomi) <soolaugust@gmail.com>
---
 kernel/sched/fair.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 1f1c53c7deb2b..6a6cf8019be90 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8755,10 +8755,6 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, int
 	if (task_is_throttled(p))
 		return;
 
-	if (sched_feat(NEXT_BUDDY) && !(wake_flags & WF_FORK) && !pse->sched_delayed) {
-		set_next_buddy(pse);
-	}
-
 	/*
 	 * We can come here with TIF_NEED_RESCHED already set from new task
 	 * wake up path.
@@ -8811,6 +8807,9 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, int
 	 */
 	do_preempt_short = sched_feat(PREEMPT_SHORT) && (pse->slice < se->slice);
 
+	if (sched_feat(NEXT_BUDDY) && !(wake_flags & WF_FORK) && !pse->sched_delayed)
+		set_next_buddy(pse);
+
 	/*
 	 * If @p has become the most eligible task, force preemption.
 	 */
@@ -8823,8 +8822,10 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, int
 	return;
 
 preempt:
-	if (do_preempt_short)
+	if (do_preempt_short) {
 		cancel_protect_slice(se);
+		clear_buddies(cfs_rq, se);
+	}
 
 	resched_curr_lazy(rq);
 }
-- 
2.43.0


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

end of thread, other threads:[~2026-07-06  9:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-06  2:34 [PATCH] sched/fair: align proxy wakeup buddy handling with EEVDF zhidao su (Xiaomi)
2026-07-06  8:16 ` Vincent Guittot
2026-07-06  9:08   ` soolaugust

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