lkml.org 
[lkml]   [2022]   [Jun]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v7] sched/fair: Consider cpu affinity when allowing NUMA imbalance in find_idlest_group
On Fri, Jun 10, 2022 at 11:55:37AM +0100, Valentin Schneider wrote:
> 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)

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.

> 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.

\
 
 \ /
  Last update: 2022-06-10 16:17    [W:0.095 / U:0.968 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site