SCX_PICK_IDLE_CORE requires selecting a CPU whose SMT siblings are all idle. The restricted select_cpu kfunc path now derives its candidate from task state, but it does not check that condition before claiming the CPU. The WAKE_SYNC shortcuts in scx_select_cpu_dfl() can bypass strict-core selection on SMT systems as well. Skip those shortcuts when SCX_PICK_IDLE_CORE is requested, and validate restricted candidates against their idle SMT mask before consuming the idle bit. Preserve individual-idle selection when the flag is not set and on non-SMT systems. Fixes: 683d2d0faba1 ("sched_ext: idle: Introduce scx_bpf_select_cpu_and()") Cc: stable@vger.kernel.org Signed-off-by: Hui Su --- kernel/sched/ext/idle.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/sched/ext/idle.c b/kernel/sched/ext/idle.c index 28ed9e327085..09e40928aef4 100644 --- a/kernel/sched/ext/idle.c +++ b/kernel/sched/ext/idle.c @@ -523,7 +523,7 @@ s32 scx_select_cpu_dfl(struct task_struct *p, s32 prev_cpu, u64 wake_flags, /* * If WAKE_SYNC, try to migrate the wakee to the waker's CPU. */ - if (wake_flags & SCX_WAKE_SYNC) { + if ((wake_flags & SCX_WAKE_SYNC) && !(sched_smt_active() && (flags & SCX_PICK_IDLE_CORE))) { int waker_node; /* @@ -976,6 +976,10 @@ static s32 select_cpu_restricted(struct task_struct *p, s32 prev_cpu, return -EBUSY; } + if ((flags & SCX_PICK_IDLE_CORE) && sched_smt_active() && + !cpumask_test_cpu(cpu, idle_cpumask(scx_cpu_node_if_enabled(cpu))->smt)) + return -EBUSY; + if (!scx_idle_test_and_clear_cpu(cpu)) return -EBUSY; -- 2.55.0