Re: [PATCH 3/6] sched_ext: idle: Accept an arbitrary cpumask in scx_select_cpu_dfl()

From: Tejun Heo
Date: Mon Mar 31 2025 - 17:56:43 EST


On Fri, Mar 21, 2025 at 11:10:49PM +0100, Andrea Righi wrote:
...
> + /*
> + * If @prev_cpu is not in the allowed domain, try to assign a new
> + * arbitrary CPU usable by the task in the allowed domain.
> + */
> + if (!cpumask_test_cpu(prev_cpu, allowed)) {
> + cpu = cpumask_any_and_distribute(p->cpus_ptr, allowed);
> + if (cpu < nr_cpu_ids) {
> + prev_cpu = cpu;
> + } else {
> + cpu = -EBUSY;
> + goto out_enable;
> + }
> + }

Would it be better to clear it to -1 and disable @prev_cpu optimizations if
negative? Not a big deal, so please feel free to push back but things like
wake_sync optimization become a bit weird with @prev_cpu set to some random
CPU and down the line if we want to allow e.g. preferring previous idle CPU
even when the sibling CPU isn't idle which seems to help with some
workloads, this can become tricky.

Thanks.

--
tejun