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
19361936 complete = true;
19371937 }
19381938
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+
19401943 dest_cpu = cpumask_any_distribute(&p->cpus_mask);
1944+ }
19411945
19421946 if (task_on_rq_queued(p))
19431947 rq = __migrate_task(rq, &rf, p, dest_cpu);
19441948 else
19451949 p->wake_cpu = dest_cpu;
19461950
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+
19471958 } else if (pending) {
19481959 /*
19491960 * 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