diff --git a/kernel/sched/core.c b/kernel/sched/core.c index be4896a06967..3aee8077f23a 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2589,43 +2589,19 @@ void do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask) int dup_user_cpus_ptr(struct task_struct *dst, struct task_struct *src, int node) { - cpumask_t *user_mask; unsigned long flags; - /* - * Always clear dst->user_cpus_ptr first as their user_cpus_ptr's - * may differ by now due to racing. - */ - dst->user_cpus_ptr = NULL; - - /* - * This check is racy and losing the race is a valid situation. - * It is not worth the extra overhead of taking the pi_lock on - * every fork/clone. - */ if (!src->user_cpus_ptr) return 0; - user_mask = kmalloc_node(cpumask_size(), GFP_KERNEL, node); - if (!user_mask) + dst->user_cpus_ptr = kmalloc_node(cpumask_size(), GFP_KERNEL, node); + if (!dst->user_cpus_ptr) return -ENOMEM; - /* - * Use pi_lock to protect content of user_cpus_ptr - * - * Though unlikely, user_cpus_ptr can be reset to NULL by a concurrent - * do_set_cpus_allowed(). - */ + /* Use pi_lock to protect content of user_cpus_ptr */ raw_spin_lock_irqsave(&src->pi_lock, flags); - if (src->user_cpus_ptr) { - swap(dst->user_cpus_ptr, user_mask); - cpumask_copy(dst->user_cpus_ptr, src->user_cpus_ptr); - } + cpumask_copy(dst->user_cpus_ptr, src->user_cpus_ptr); raw_spin_unlock_irqrestore(&src->pi_lock, flags); - - if (unlikely(user_mask)) - kfree(user_mask); - return 0; }