Messages in this thread | | | From | Valentin Schneider <> | Subject | Re: [PATCH v7] sched/fair: Consider cpu affinity when allowing NUMA imbalance in find_idlest_group | Date | Fri, 10 Jun 2022 11:55:37 +0100 |
| |
On 09/06/22 13:54, Peter Zijlstra wrote: > Now, I can (and have) fixed up the conflict, but it did make me look at > this in a little more detail; and the thing I noticed is that your: > > 'p->nr_cpus_allowed != num_online_cpus()' > > test makes no sense. That's basically 'true'. The thing is, > nr_cpus_allowed is initialized to NR_CPUS, and unless someone somewhere > did set_cpus_allowed() on it, it'll still be NR_CPUS. > > Also, CPU hotplug doesn't change nr_cpus_allowed, so num_online_cpus() > is just plain wrong. > > Now, something that might work is: > > 'p->nr_cpus_allowed < num_online_cpus()' > > And even that is no guarantee. You can construct a situation where this > is still false even though you actually have a constrained set. > Consider a machine with 8 CPUs. Then set the mask to: 0x55, which has 4 > CPUs set. Then offline the last 4 so that the online mask becomes 0x0f. > > Then the effective mask is 0x05, and the number we're looking for above > is 2, but the suggested test would still be false, because > nr_cpus_allowed would be 4, as would num_online_cpus(). >
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)
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).
| |