Commit eab0fed3 authored by Robert Love's avatar Robert Love Committed by Linus Torvalds

[PATCH] set_cpus_allowed optimization

This adds an optimization to set_cpus_allowed: if the task is not
running, there is no sense in kicking the migration_threads into action,
we just need to update task->cpu.  This was suggested by Mike Kravetz.

Besides being an optimization, this would prevent any future race
between set_cpus_allowed and the migration_threads.
parent 49610fe2
...@@ -1668,6 +1668,16 @@ void set_cpus_allowed(task_t *p, unsigned long new_mask) ...@@ -1668,6 +1668,16 @@ void set_cpus_allowed(task_t *p, unsigned long new_mask)
goto out; goto out;
} }
/*
* If the task is not on a runqueue, then it is sufficient
* to simply update the task's cpu field.
*/
if (!p->array) {
p->cpu = __ffs(p->cpus_allowed);
task_rq_unlock(rq, &flags);
goto out;
}
init_MUTEX_LOCKED(&req.sem); init_MUTEX_LOCKED(&req.sem);
req.task = p; req.task = p;
list_add(&req.list, &rq->migration_queue); list_add(&req.list, &rq->migration_queue);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment