Re: [PATCH v7] sched/fair: Consider cpu affinity when allowing NUMA imbalance in find_idlest_group

From: Valentin Schneider
Date: Fri Jun 10 2022 - 12:25:44 EST


On 10/06/22 16:15, Peter Zijlstra wrote:
> On Fri, Jun 10, 2022 at 11:55:37AM +0100, Valentin Schneider wrote:
>>
>> IIUC we want to pay special attention when the task isn't allowed to run on
>> all online CPUs, wouldn't the below do that?
>>
>> !cpumask_subset(cpu_online_mask, p->cpus_ptr)
>
> At that point we might just as well do the whole cpumask_and() thing,
> no? There's not much cost difference between these two operations.
>

Yeah, you got a point there.

>> The task affinity can be a superset of the online mask, obvious case is
>> init_task's CPU_MASK_ALL, and the above test is still false if both masks
>> are equal.
>>
>> (Additionnaly we could add a step in sched_init() to "properly" initialize
>> the init_task mask and remove the NR_CPUS faff).
>
> I'm confused, NR_CPUS is the right value for CPU_MASK_ALL.

Right, I meant to make the mask match cpu_online_mask from the get go, but
now that I allocate a few more neurons thinking about it it looks like a
can of worms; we'd have to do that after smp_init() to see which CPUs we
actually onlined, and by then we have already forked around.