Skip to content

Commit

Permalink
workqueue: swap set_cpus_allowed_ptr() and PF_NO_SETAFFINITY
Browse files Browse the repository at this point in the history
Move the setting of PF_NO_SETAFFINITY up before set_cpus_allowed()
in create_worker(). Otherwise userland can change ->cpus_allowed
in between.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
  • Loading branch information
Oleg Nesterov authored and Tejun Heo committed Nov 22, 2013
1 parent 6ce4eac commit 9115122
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions kernel/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -1736,16 +1736,17 @@ static struct worker *create_worker(struct worker_pool *pool)
if (IS_ERR(worker->task))
goto fail;

set_user_nice(worker->task, pool->attrs->nice);

/* prevent userland from meddling with cpumask of workqueue workers */
worker->task->flags |= PF_NO_SETAFFINITY;

/*
* set_cpus_allowed_ptr() will fail if the cpumask doesn't have any
* online CPUs. It'll be re-applied when any of the CPUs come up.
*/
set_user_nice(worker->task, pool->attrs->nice);
set_cpus_allowed_ptr(worker->task, pool->attrs->cpumask);

/* prevent userland from meddling with cpumask of workqueue workers */
worker->task->flags |= PF_NO_SETAFFINITY;

/*
* The caller is responsible for ensuring %POOL_DISASSOCIATED
* remains stable across this function. See the comments above the
Expand Down

0 comments on commit 9115122

Please sign in to comment.