Re: [PATCH] sched/topology: optimize sched_numa_find_nth_cpu()

From: Valentin Schneider

Date: Fri Mar 27 2026 - 12:03:33 EST


On 27/03/26 19:08, Shrikanth Hegde wrote:
> Hi Valentin.
>
> On 3/27/26 1:15 AM, Valentin Schneider wrote:
>> On 26/03/26 20:09, Valentin Schneider wrote:
>>> On 19/03/26 13:26, Yury Norov wrote:
>> @@ -2284,16 +2289,16 @@ static int hop_cmp(const void *a, const void *b)
>> }
>>
>> /**
>> - * sched_numa_find_nth_cpu() - given the NUMA topology, find the Nth closest CPU
>> - * from @cpus to @cpu, taking into account distance
>> - * from a given @node.
>> + * sched_numa_find_nth_cpu() - given the NUMA topology, find the @nth_cpu in
>> + * @cpus reachable from @node in the least amount
>> + * of hops.
>> * @cpus: cpumask to find a cpu from
>> - * @cpu: CPU to start searching
>> - * @node: NUMA node to order CPUs by distance
>> + * @nth_cpu: CPU offset to search for
>> + * @node: NUMA node to start the search from
>> *
>> * Return: cpu, or nr_cpu_ids when nothing found.
>> */
>> -int sched_numa_find_nth_cpu(const struct cpumask *cpus, int cpu, int node)
>> +int sched_numa_find_nth_cpu(const struct cpumask *cpus, int nth_cpu, int node)
>> {
>> struct __cmp_key k = { .cpus = cpus, .cpu = cpu };
>
> nit: it should .cpu = nth_cpu? and one more place below should change to nth_cpu.
>

Yeah, and the cpumask_nth*() family should get the same treatment.