Skip to content

Commit aa3ee4f

Browse files
Xuewen YanPeter Zijlstra
authored andcommitted
sched/fair: Fixup wake_up_sync() vs DELAYED_DEQUEUE
Delayed dequeued feature keeps a sleeping task enqueued until its lag has elapsed. As a result, it stays also visible in rq->nr_running. So when in wake_affine_idle(), we should use the real running-tasks in rq to check whether we should place the wake-up task to current cpu. On the other hand, add a helper function to return the nr-delayed. Fixes: 152e11f ("sched/fair: Implement delayed dequeue") Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com> Reviewed-and-tested-by: Tianchen Ding <dtcccc@linux.alibaba.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org> Link: https://lore.kernel.org/r/20250303105241.17251-2-xuewen.yan@unisoc.com
1 parent 676e8cf commit aa3ee4f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

kernel/sched/fair.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7193,6 +7193,11 @@ static bool dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags)
71937193
return true;
71947194
}
71957195

7196+
static inline unsigned int cfs_h_nr_delayed(struct rq *rq)
7197+
{
7198+
return (rq->cfs.h_nr_queued - rq->cfs.h_nr_runnable);
7199+
}
7200+
71967201
#ifdef CONFIG_SMP
71977202

71987203
/* Working cpumask for: sched_balance_rq(), sched_balance_newidle(). */
@@ -7354,8 +7359,12 @@ wake_affine_idle(int this_cpu, int prev_cpu, int sync)
73547359
if (available_idle_cpu(this_cpu) && cpus_share_cache(this_cpu, prev_cpu))
73557360
return available_idle_cpu(prev_cpu) ? prev_cpu : this_cpu;
73567361

7357-
if (sync && cpu_rq(this_cpu)->nr_running == 1)
7358-
return this_cpu;
7362+
if (sync) {
7363+
struct rq *rq = cpu_rq(this_cpu);
7364+
7365+
if ((rq->nr_running - cfs_h_nr_delayed(rq)) == 1)
7366+
return this_cpu;
7367+
}
73597368

73607369
if (available_idle_cpu(prev_cpu))
73617370
return prev_cpu;

0 commit comments

Comments
 (0)