Re: set_cpus_allowed() optimization

Robert Love (rml@tech9.net)
13 May 2002 16:05:46 -0700


n Fri, 2002-05-10 at 13:09, Mike Kravetz wrote:
> Please consider the following optimization to set_cpus_allowed().
> In the case where the task does not reside on a runqueue, is it
> not safe/sufficient to simply set the task's cpu field? This
> would avoid scheduling the migration thread to perform the task.
>
> Previously, set_cpus_allowed() was always called for a task that
> resides on a runqueue. With the introduction of the 'cpu affinity'
> system calls, this is no longer the case.

I like! I agree, if the task is not runnable then it should be
sufficient to just set task->cpu as when it is activated it will be put
into the runqueue based on ->cpu.

There was a chance even without the CPU affinity runqueues a process
would dequeue before set_cpus_allowed returned. Look at the case in
migration_thread where exactly what your patch does is done. If !array,
then the code just sets task->cpu and returns.

Ingo? Good?

Robert Love

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/