History

sched: Optimize migration_cpu_stop()

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.

Peter Zijlstra committed 5 years ago

Commit 3f1bc111 parent 58b1a451 file · +12 −1Browse files

Unified · Split

kernel/sched/core.c+12−1
@@ -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 else1948 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()'s1960 * This happens when we get migrated between migrate_enable()'s

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t