Re: [RFC PATCH] kernel: sched: Provide a pointer to the valid CPU mask

From: Peter Zijlstra
Date: Thu Apr 06 2017 - 05:42:25 EST


On Thu, Apr 06, 2017 at 11:35:45AM +0200, Peter Zijlstra wrote:
> On Thu, Apr 06, 2017 at 10:01:39AM +0200, Ingo Molnar wrote:
> > I.e. just have a counter and these two APIs:
> >
> > static inline void migrate_disable(void)
> > {
> > current->migration_disabled++;
> > }
> >
> > ...
> >
> > static inline void migrate_enable(void)
> > {
> > current->migration_disabled--;
> > }
> >
> > ... and make sure the scheduler migration code plus the CPU hotplug code considers
> > the counter.
> >
> > Would this work, and would this be the simplest all around solution?
>
> If you want to add expensive bits to hot paths like wakeups ... :/

Hmm, doesn't that get us back to exactly where we were: ?

tsk_cpus_allowed()
{
if (!tsk->migration_disabled)
return tsk->cpus_allowed;
else
return cpumask_of(task_cpu(tsk));
}