Re: [PATCH 1/4] sched/fair: Fix cookie check on __select_idle_cpu()

K Prateek Nayak
2025-09-23T08:42:26Z

Hello Fernand,

On 9/22/2025 6:09 PM, Fernand Sieber wrote:
> @@ -7447,7 +7447,7 @@ static inline int sched_balance_find_dst_cpu(struct sched_domain *sd, struct tas
> static inline int __select_idle_cpu(int cpu, struct task_struct *p)
> {
> if ((available_idle_cpu(cpu) || sched_idle_cpu(cpu)) &&
> - sched_cpu_cookie_match(cpu_rq(cpu), p))
> + sched_core_cookie_match(cpu_rq(cpu), p))

__select_idle_cpu() is only called when "has_idle_core" is false which
means it is highly unlikely we'll find an idle core. In such cases, just
matching the cookie should be sufficient right?

Do you have any benchmark numbers which shows a large difference with
these changes?

> return cpu;
>
> return -1;
> @@ -7546,6 +7546,9 @@ static int select_idle_smt(struct task_struct *p, struct sched_domain *sd, int t
> {
> int cpu;
>
> + if (!sched_core_cookie_match(cpu_rq(target), p))
> + return -1;
> +

select_idle_smt() is again called when "has_idle_core" is false and
sched_cpu_cookie_match() should be sufficient for most part here too.

> for_each_cpu_and(cpu, cpu_smt_mask(target), p->cpus_ptr) {
> if (cpu == target)
> continue;

--
Thanks and Regards,
Prateek