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

* Re: [PATCH] sched/fair: align proxy wakeup buddy handling with EEVDF
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Vincent Guittot @ 2026-07-06  8:16 UTC (permalink / raw)
  To: zhidao su (Xiaomi)
  Cc: mingo, peterz, juri.lelli, dietmar.eggemann, rostedt, bsegall,
	mgorman, vschneid, kprateek.nayak, jstultz, linux-kernel

On Mon, 6 Jul 2026 at 04:34, zhidao su (Xiaomi) <soolaugust@gmail.com> wrote:
>
> 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

Which version are you using ? there is nothing like
check_preempt_wakeup_fair() in mainline or tip/sched/core

And does the issue still apply with the latest scheduler changes?


>         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	[flat|nested] 3+ messages in thread

* Re: [PATCH] sched/fair: align proxy wakeup buddy handling with EEVDF
  2026-07-06  8:16 ` Vincent Guittot
@ 2026-07-06  9:08   ` soolaugust
  0 siblings, 0 replies; 3+ messages in thread
From: soolaugust @ 2026-07-06  9:08 UTC (permalink / raw)
  To: Vincent Guittot
  Cc: zhidao su (Xiaomi), mingo, peterz, juri.lelli, dietmar.eggemann,
	rostedt, bsegall, mgorman, vschneid, kprateek.nayak, jstultz,
	linux-kernel

From: "zhidao su (Xiaomi)" <soolaugust@gmail.com>

On Mon, Jul 06, 2026 at 10:16:47AM +0200, Vincent Guittot wrote:
> Which version are you using ? there is nothing like
> check_preempt_wakeup_fair() in mainline or tip/sched/core
>
> And does the issue still apply with the latest scheduler changes?

Thanks for checking, and sorry for the noise.

You are right. I based this on an old local proxy-exec work branch and
failed to state the base tree/commit in the submission. That branch still
had check_preempt_wakeup_fair(), but current mainline/tip and the newer
proxy-exec branches have moved to wakeup_preempt_fair().

I rechecked the newer code and the wakeup path has already been reworked
around preempt_action/set_preempt_buddy(), including the
PREEMPT_WAKEUP_SHORT buddy cleanup path. So this patch does not apply to
the current scheduler code and should be ignored.

I'll fix my local pre-send checks so patches like this have to apply to
the intended target baseline before I send them.

Thanks,
zhidao

^ permalink raw reply	[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