Re: [PATCH 2/4] sched/fair: Still look for the idlest cpu with no matching cookie

K Prateek Nayak
2025-09-23T01:51:39Z

Hello Fernand,

On 9/22/2025 6:09 PM, Fernand Sieber wrote:
> @@ -7391,6 +7393,17 @@ sched_balance_find_dst_group_cpu(struct sched_group *group, struct task_struct *
> return shallowest_idle_cpu != -1 ? shallowest_idle_cpu : least_loaded_cpu;

Based on the above return in __sched_balance_find_dst_group_cpu(), it
should always return a valid CPU since "least_loaded_cpu" is initialized
to "this_cpu".

> }
>
> +/*
> + * sched_balance_find_dst_group_cpu - find the idlest CPU among the CPUs in the group.
> + */
> +static inline int
> +sched_balance_find_dst_group_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
> +{
> + int cpu = __sched_balance_find_dst_group_cpu(group, p, this_cpu, true);
> +
> + return cpu >= 0 ? cpu : __sched_balance_find_dst_group_cpu(group, p, this_cpu, false);

So, under what circumstance does "cpu" here turns out to be < 0?
Am I missing something?

> +}
> +
> static inline int sched_balance_find_dst_cpu(struct sched_domain *sd, struct task_struct *p,
> int cpu, int prev_cpu, int sd_flag)
> {

--
Thanks and Regards,
Prateek