The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "zhidao su (Xiaomi)" <soolaugust@gmail.com>
To: mingo@redhat.com, peterz@infradead.org
Cc: juri.lelli@redhat.com, vincent.guittot@linaro.org,
	dietmar.eggemann@arm.com, rostedt@goodmis.org,
	bsegall@google.com, mgorman@suse.de, vschneid@redhat.com,
	kprateek.nayak@amd.com, jstultz@google.com,
	linux-kernel@vger.kernel.org,
	"zhidao su (Xiaomi)" <soolaugust@gmail.com>
Subject: [PATCH] sched/fair: align proxy wakeup buddy handling with EEVDF
Date: Mon,  6 Jul 2026 10:34:40 +0800	[thread overview]
Message-ID: <20260706023440.3055519-1-soolaugust@gmail.com> (raw)

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


             reply	other threads:[~2026-07-06  2:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-06  2:34 zhidao su (Xiaomi) [this message]
2026-07-06  8:16 ` [PATCH] sched/fair: align proxy wakeup buddy handling with EEVDF Vincent Guittot
2026-07-06  9:08   ` soolaugust

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260706023440.3055519-1-soolaugust@gmail.com \
    --to=soolaugust@gmail.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=jstultz@google.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox