When the purpose of migration_cpu_stop() is to migrate the task to 'any' valid CPU, don't migrate the task when it's already running on a valid CPU.
Showing the changes to kernel (1 of 1 file). Show all
Unified · Split
| @@ -1936,14 +1936,25 @@ static int migration_cpu_stop(void *data) · 1935 unmodified lines | |||
| 1936 | complete = true; | 1936 | complete = true; |
| 1937 | } | 1937 | } |
| 1938 | 1938 | ||
| 1939 | if (dest_cpu < 0) | 1939 | if (dest_cpu < 0) { |
| 1940 | if (cpumask_test_cpu(task_cpu(p), &p->cpus_mask)) | ||
| 1941 | goto out; | ||
| 1942 | |||
| 1940 | dest_cpu = cpumask_any_distribute(&p->cpus_mask); | 1943 | dest_cpu = cpumask_any_distribute(&p->cpus_mask); |
| 1944 | } | ||
| 1941 | 1945 | ||
| 1942 | if (task_on_rq_queued(p)) | 1946 | if (task_on_rq_queued(p)) |
| 1943 | rq = __migrate_task(rq, &rf, p, dest_cpu); | 1947 | rq = __migrate_task(rq, &rf, p, dest_cpu); |
| 1944 | else | 1948 | else |
| 1945 | p->wake_cpu = dest_cpu; | 1949 | p->wake_cpu = dest_cpu; |
| 1946 | 1950 | ||
| 1951 | /* | ||
| 1952 | * XXX __migrate_task() can fail, at which point we might end | ||
| 1953 | * up running on a dodgy CPU, AFAICT this can only happen | ||
| 1954 | * during CPU hotplug, at which point we'll get pushed out | ||
| 1955 | * anyway, so it's probably not a big deal. | ||
| 1956 | */ | ||
| 1957 | |||
| 1947 | } else if (pending) { | 1958 | } else if (pending) { |
| 1948 | /* | 1959 | /* |
| 1949 | * This happens when we get migrated between migrate_enable()'s | 1960 | * This happens when we get migrated between migrate_enable()'s |