diff --git a/scheds/rust/scx_bpfland/src/bpf/main.bpf.c b/scheds/rust/scx_bpfland/src/bpf/main.bpf.c index e5cfbd509..ba86dbb98 100644 --- a/scheds/rust/scx_bpfland/src/bpf/main.bpf.c +++ b/scheds/rust/scx_bpfland/src/bpf/main.bpf.c @@ -627,6 +627,15 @@ static s32 pick_idle_cpu(struct task_struct *p, s32 prev_cpu, u64 wake_flags, bo goto out_put_cpumask; } + /* + * Search for any idle CPU usable by the task. + */ + cpu = scx_bpf_pick_idle_cpu(p->cpus_ptr, 0); + if (cpu >= 0) { + *is_idle = true; + goto out_put_cpumask; + } + /* * We couldn't find any idle CPU, return the previous CPU if it is in * the task's L3 domain. @@ -684,7 +693,7 @@ s32 BPF_STRUCT_OPS(bpfland_select_cpu, struct task_struct *p, */ static void kick_idle_cpu(const struct task_struct *p, const struct task_ctx *tctx) { - const struct cpumask *idle_cpumask, *l3_mask; + const struct cpumask *idle_cpumask; s32 cpu; /* @@ -695,20 +704,14 @@ static void kick_idle_cpu(const struct task_struct *p, const struct task_ctx *tc return; /* - * Look for an idle CPU in the same L3 domain that can immediately + * Look for any idle CPU usable by the task that can immediately * execute the task. * * Note that we do not want to mark the CPU as busy, since we don't * know at this stage if we will actually dispatch any task on it. */ - l3_mask = cast_mask(tctx->l3_cpumask); - if (!l3_mask) { - scx_bpf_error("l3 cpumask not initialized"); - return; - } - idle_cpumask = scx_bpf_get_idle_cpumask(); - cpu = bpf_cpumask_any_and_distribute(l3_mask, idle_cpumask); + cpu = bpf_cpumask_any_and_distribute(p->cpus_ptr, idle_cpumask); scx_bpf_put_cpumask(idle_cpumask); if (cpu < nr_cpu_ids)