mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sched/fair: Fix the runtime check in preempt_sync()
@ 2026-11-06  8:50 Peng Wang
  2026-11-06 10:31 ` Peter Zijlstra
  0 siblings, 1 reply; 3+ messages in thread
From: Peng Wang @ 2026-11-06  8:50 UTC (permalink / raw)
  To: peterz, vincent.guittot; +Cc: mingo, mgorman, linux-kernel, Peng Wang

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) {
-- 
2.47.0

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4

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

end of thread, other threads:[~2026-11-06 12:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-06  8:50 [PATCH] sched/fair: Fix the runtime check in preempt_sync() Peng Wang
2026-11-06 10:31 ` Peter Zijlstra
2026-11-06 12:12   ` Peng Wang

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®