From e0479c90b469f074c550d11f5946f2d30f74f653 Mon Sep 17 00:00:00 2001 From: I Hsin Cheng Date: Thu, 13 Jun 2024 20:54:43 +0800 Subject: [PATCH] scx: Pick an idle cpu when select runqueue with WF_EXEC If the caller of select_task_rq_scx() calls with WF_EXEC, it's a valuable balancing opportunity to perform task migration. Although runqueue can't dictate where the task is going to run, we can still take advantage of this good opportunity by selecting an idle core, rather than doing nothing. Signed-off-by: I Hsin Cheng --- kernel/sched/ext.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c index 93e041e2f8d7..8a20d6974647 100644 --- a/kernel/sched/ext.c +++ b/kernel/sched/ext.c @@ -3107,8 +3107,10 @@ static int select_task_rq_scx(struct task_struct *p, int prev_cpu, int wake_flag * which can decide to preempt self to force it through the regular * scheduling path. */ - if (unlikely(wake_flags & WF_EXEC)) - return prev_cpu; + if (unlikely(wake_flags & WF_EXEC)) { + int idle_cpu = scx_pick_idle_cpu(p->cpus_ptr, SCX_PICK_IDLE_CORE); + return idle_cpu; + } if (SCX_HAS_OP(select_cpu)) { s32 cpu;