The patch titled sched: CPU hotplug race vs. set_cpus_allowed() has been removed from the -mm tree. Its filename is sched-cpu-hotplug-race-vs-set_cpus_allowed.patch This patch was dropped because an updated version was merged ------------------------------------------------------ Subject: sched: CPU hotplug race vs. set_cpus_allowed() From: Kirill Korotaev <dev@xxxxxxxxxx> Looks like there is a race between set_cpus_allowed() and move_task_off_dead_cpu(). __migrate_task() doesn't report any err code, so task can be left on its runqueue if its cpus_allowed mask changed so that dest_cpu is not longer a possible target. Also, chaning cpus_allowed mask requires rq->lock being held. Signed-off-by: Kirill Korotaev <dev@xxxxxxxxxx> Acked-by: Ingo Molnar <mingo@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- kernel/sched.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff -puN kernel/sched.c~sched-cpu-hotplug-race-vs-set_cpus_allowed kernel/sched.c --- a/kernel/sched.c~sched-cpu-hotplug-race-vs-set_cpus_allowed +++ a/kernel/sched.c @@ -4444,12 +4444,13 @@ EXPORT_SYMBOL_GPL(set_cpus_allowed); * So we race with normal scheduler movements, but that's OK, as long * as the task is no longer on this CPU. */ -static void __migrate_task(struct task_struct *p, int src_cpu, int dest_cpu) +static int __migrate_task(struct task_struct *p, int src_cpu, int dest_cpu) { runqueue_t *rq_dest, *rq_src; + int res = 0; if (unlikely(cpu_is_offline(dest_cpu))) - return; + return 0; rq_src = cpu_rq(src_cpu); rq_dest = cpu_rq(dest_cpu); @@ -4477,9 +4478,10 @@ static void __migrate_task(struct task_s if (TASK_PREEMPTS_CURR(p, rq_dest)) resched_task(rq_dest->curr); } - + res = 1; out: double_rq_unlock(rq_src, rq_dest); + return res; } /* @@ -4549,9 +4551,12 @@ wait_to_die: /* Figure out where task on dead CPU should go, use force if neccessary. */ static void move_task_off_dead_cpu(int dead_cpu, struct task_struct *tsk) { - int dest_cpu; + runqueue_t *rq; + unsigned long flags; + int dest_cpu, res; cpumask_t mask; +restart: /* On same node? */ mask = node_to_cpumask(cpu_to_node(dead_cpu)); cpus_and(mask, mask, tsk->cpus_allowed); @@ -4563,8 +4568,10 @@ static void move_task_off_dead_cpu(int d /* No more Mr. Nice Guy. */ if (dest_cpu == NR_CPUS) { + rq = task_rq_lock(tsk, &flags); cpus_setall(tsk->cpus_allowed); dest_cpu = any_online_cpu(tsk->cpus_allowed); + task_rq_unlock(rq, &flags); /* * Don't tell them about moving exiting tasks or @@ -4576,7 +4583,9 @@ static void move_task_off_dead_cpu(int d "longer affine to cpu%d\n", tsk->pid, tsk->comm, dead_cpu); } - __migrate_task(tsk, dead_cpu, dest_cpu); + res = __migrate_task(tsk, dead_cpu, dest_cpu); + if (!res) + goto restart; } /* _ Patches currently in -mm which might be from dev@xxxxxxxxxx are origin.patch sched-cpu-hotplug-race-vs-set_cpus_allowed.patch proc-sysctl-add-_proc_do_string-helper.patch namespaces-add-nsproxy.patch namespaces-add-nsproxy-dont-include-compileh.patch namespaces-incorporate-fs-namespace-into-nsproxy.patch namespaces-utsname-introduce-temporary-helpers.patch namespaces-utsname-switch-to-using-uts-namespaces.patch namespaces-utsname-switch-to-using-uts-namespaces-alpha-fix.patch namespaces-utsname-switch-to-using-uts-namespaces-cleanup.patch namespaces-utsname-use-init_utsname-when-appropriate.patch namespaces-utsname-use-init_utsname-when-appropriate-cifs-update.patch namespaces-utsname-implement-utsname-namespaces.patch namespaces-utsname-implement-utsname-namespaces-export.patch namespaces-utsname-implement-utsname-namespaces-dont-include-compileh.patch namespaces-utsname-sysctl-hack.patch namespaces-utsname-sysctl-hack-cleanup.patch namespaces-utsname-sysctl-hack-cleanup-2.patch namespaces-utsname-sysctl-hack-cleanup-2-fix.patch namespaces-utsname-remove-system_utsname.patch namespaces-utsname-implement-clone_newuts-flag.patch uts-copy-nsproxy-only-when-needed.patch ipc-namespace-core.patch ipc-namespace-core-fix.patch ipc-namespace-core-unshare-fix.patch ipc-namespace-utils.patch ipc-namespace-msg.patch ipc-namespace-sem.patch ipc-namespace-shm.patch ipc-namespace-sysctls.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html