mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Peng Wang <peng_wang@linux.alibaba.com>
Cc: vincent.guittot@linaro.org, mingo@redhat.com, mgorman@suse.de,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched/fair: Fix the runtime check in preempt_sync()
Date: Fri, 6 Nov 2026 11:31:40 +0100	[thread overview]
Message-ID: <20261106103140.GE1779021@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20261106085001.36135-1-peng_wang@linux.alibaba.com>

On Fri, Nov 06, 2026 at 04:50:00PM +0800, Peng Wang wrote:
> With NEXT_BUDDY enabled, preempt_sync() only lets a WF_SYNC wakeup
> force a reschedule once the current task has run long enough.  It
> computes the runtime as rq_clock_task() - se->exec_start, but
> wakeup_preempt_fair() has already called update_curr_fair() at that
> point, which sets se->exec_start to rq_clock_task().  The result is
> always 0.
> 
> Use sum_exec_runtime - prev_sum_exec_runtime instead, which is the time
> the task has run since it was picked, and drop the now unused rq
> argument.
> 
> Fixes: e837456fdca8 ("sched/fair: Reimplement NEXT_BUDDY to align with EEVDF goals")
> Signed-off-by: Peng Wang <peng_wang@linux.alibaba.com>
> ---
>  kernel/sched/fair.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index cfc9822..6164cb7 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -10090,8 +10090,8 @@ static inline bool set_short_buddy(struct cfs_rq *cfs_rq, struct sched_entity *p
>   * multiple tasks must be woken up.
>   */
>  static inline enum preempt_wakeup_action
> -preempt_sync(struct rq *rq, int wake_flags,
> -	     struct sched_entity *pse, struct sched_entity *se)
> +preempt_sync(int wake_flags, struct sched_entity *pse,
> +	     struct sched_entity *se)
>  {
>  	u64 threshold, delta;
>  
> @@ -10102,7 +10102,7 @@ preempt_sync(struct rq *rq, int wake_flags,
>  	WARN_ON_ONCE(!(wake_flags & WF_TTWU));
>  
>  	threshold = sysctl_sched_migration_cost;
> -	delta = rq_clock_task(rq) - se->exec_start;
> +	delta = se->sum_exec_runtime - se->prev_sum_exec_runtime;
>  	if ((s64)delta < 0)
>  		delta = 0;
>  
> @@ -10226,7 +10226,7 @@ static void wakeup_preempt_fair(struct rq *rq, struct task_struct *p, int wake_f
>  		 * waker and less likely to be cache hot.
>  		 */
>  		if (wake_flags & WF_SYNC)
> -			preempt_action = preempt_sync(rq, wake_flags, pse, se);
> +			preempt_action = preempt_sync(wake_flags, pse, se);
>  	}
>  
>  	switch (preempt_action) {

Well yes. Would you also happen to have some number on how this fix
affects performance of WF_SYNC workloads?

  reply	other threads:[~2026-11-06 10:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06  8:50 Peng Wang
2026-11-06 10:31 ` Peter Zijlstra [this message]
2026-11-06 12:12   ` Peng Wang

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=20261106103140.GE1779021@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peng_wang@linux.alibaba.com \
    --cc=vincent.guittot@linaro.org \
    /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

all inboxes | Powered by JetHome®