aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/workqueue.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2013-11-14 06:56:18 -0500
committerTejun Heo <tj@kernel.org>2013-11-22 18:13:20 -0500
commit91151228065354a050fd0d190aefdd662a0580aa (patch)
treef4c9dda9a0a9d114526463be9f4d2e6880483945 /kernel/workqueue.c
parent6ce4eac1f600b34f2f7f58f9cd8f0503d79e42ae (diff)
workqueue: swap set_cpus_allowed_ptr() and PF_NO_SETAFFINITY
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>
Diffstat (limited to 'kernel/workqueue.c')
-rw-r--r--kernel/workqueue.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 987293d03ebc..f8942429268b 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1736,16 +1736,17 @@ static struct worker *create_worker(struct worker_pool *pool)
1736 if (IS_ERR(worker->task)) 1736 if (IS_ERR(worker->task))
1737 goto fail; 1737 goto fail;
1738 1738
1739 set_user_nice(worker->task, pool->attrs->nice);
1740
1741 /* prevent userland from meddling with cpumask of workqueue workers */
1742 worker->task->flags |= PF_NO_SETAFFINITY;
1743
1739 /* 1744 /*
1740 * set_cpus_allowed_ptr() will fail if the cpumask doesn't have any 1745 * set_cpus_allowed_ptr() will fail if the cpumask doesn't have any
1741 * online CPUs. It'll be re-applied when any of the CPUs come up. 1746 * online CPUs. It'll be re-applied when any of the CPUs come up.
1742 */ 1747 */
1743 set_user_nice(worker->task, pool->attrs->nice);
1744 set_cpus_allowed_ptr(worker->task, pool->attrs->cpumask); 1748 set_cpus_allowed_ptr(worker->task, pool->attrs->cpumask);
1745 1749
1746 /* prevent userland from meddling with cpumask of workqueue workers */
1747 worker->task->flags |= PF_NO_SETAFFINITY;
1748
1749 /* 1750 /*
1750 * The caller is responsible for ensuring %POOL_DISASSOCIATED 1751 * The caller is responsible for ensuring %POOL_DISASSOCIATED
1751 * remains stable across this function. See the comments above the 1752 * remains stable across this function. See the comments above the