Re: [PATCH v3 00/20] sched: Introduce cpu_preferred_mask and steal-driven vCPU backoff

From: Shrikanth Hegde

Date: Tue Jun 09 2026 - 15:57:34 EST




On 5/14/26 8:51 PM, Shrikanth Hegde wrote:

TODO/OPEN Questions:

- SCHED_EXT is still pending. I tried adding few checks in
scx_idle_test_and_clear_cpu, pick_idle_cpu_in_node and push the
sched_ext task in tick. But it hasn't still worked with scx_simple.
I will try to figure it out. But i may need help since
I am yet wade deeper waters in sched_ext.


In addition to pushing the task out at sched_tick,
Did some hacking around wake up path scx_select_cpu_dfl to make
it aware of cpu_preferred state. That didn't make it work.
then tried to Push the task out in enqueue_task_scx.
That makes it somewhat work, but still has warning with scx_simple.

Given there are many different scx_ flavours, it might make sense add a new one
which is aware of preferred state and can manage it without any change to the
default implementations using custom select_cpu/enqueue/dequeue etc.

So I am thinking sched_ext bit will have to be pursued later as i don't have
much knowledge there still.

Hacked Code that was tried for scx_simple.

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 9a92a479720d..4009ca1ec027 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -11361,7 +11361,8 @@ void sched_push_current_non_preferred_cpu(struct rq *rq)
/* Push only if it is FAIR/RT class */
if (push_task->sched_class != &fair_sched_class &&
- push_task->sched_class != &rt_sched_class)
+ push_task->sched_class != &rt_sched_class &&
+ push_task->sched_class != &ext_sched_class)
return;
if (kthread_is_per_cpu(push_task) ||
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index f5a3233ead1a..a7a87f849e03 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -2043,6 +2043,11 @@ static void enqueue_task_scx(struct rq *rq, struct task_struct *p, int core_enq_
goto out;
}
+ if (!cpu_preferred(rq->cpu)) {
+ sched_push_current_non_preferred_cpu(rq);
+ return;
+ }
+
set_task_runnable(rq, p);
p->scx.flags |= SCX_TASK_QUEUED;
rq->scx.nr_running++;