History

sched/numa: Migrate pages to local nodes quicker early in the lifetime of a task

Automatic NUMA Balancing uses a multi-stage pass to decide whether a page should migrate to a local node. This filter avoids excessive ping-ponging if a page is shared or used by threads that migrate cross-node frequently. Threads inherit both page tables and the preferred node ID from the parent. This means that threads can trigger hinting faults earlier than a new task which delays scanning for a number of seconds. As it can be load balanced very early in its lifetime there can be an unnecessary delay before it starts migrating thread-local data. This patch migrates private pages faster early in the lifetime of a thread using the sequence counter as an identifier of new tasks. With this patch applied, STREAM performance is the same as 4.17 even though processes are not spread cross-node prematurely. Other workloads showed a mix of minor gains and losses. This is somewhat expected most workloads are not very sensitive to the starting conditions of a process. 4.19.0-rc5 4.19.0-rc5 4.17.0 numab-v1r1 fastmigrate-v1r1 vanilla MB/sec copy 43298.52 ( 0.00%) 47335.46 ( 9.32%) 47219.24 ( 9.06%) MB/sec scale 30115.06 ( 0.00%) 32568.12 ( 8.15%) 32527.56 ( 8.01%) MB/sec add 32825.12 ( 0.00%) 36078.94 ( 9.91%) 35928.02 ( 9.45%) MB/sec triad 32549.52 ( 0.00%) 35935.94 ( 10.40%) 35969.88 ( 10.51%)

Mel Gorman committed 8 years ago

Commit 37355bd1 parent efaffc51 file · +11 −1Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/sched/fair.c+11−1
@@ -1392,6 +1392,17 @@ bool should_numa_migrate_memory(struct task_struct *p, struct page * page, · 1391 unmodified lines
1392 int last_cpupid, this_cpupid;1392 int last_cpupid, this_cpupid;
1393 1393
1394 this_cpupid = cpu_pid_to_cpupid(dst_cpu, current->pid);1394 this_cpupid = cpu_pid_to_cpupid(dst_cpu, current->pid);
1395 last_cpupid = page_cpupid_xchg_last(page, this_cpupid);
1396
1397 /*
1398 * Allow first faults or private faults to migrate immediately early in
1399 * the lifetime of a task. The magic number 4 is based on waiting for
1400 * two full passes of the "multi-stage node selection" test that is
1401 * executed below.
1402 */
1403 if ((p->numa_preferred_nid == -1 || p->numa_scan_seq <= 4) &&
1404 (cpupid_pid_unset(last_cpupid) || cpupid_match_pid(p, last_cpupid)))
1405 return true;
1395 1406
1396 /*1407 /*
1397 * Multi-stage node selection is used in conjunction with a periodic1408 * Multi-stage node selection is used in conjunction with a periodic
@@ -1410,7 +1421,6 @@ bool should_numa_migrate_memory(struct task_struct *p, struct page * page, · 12 unmodified lines
1410 * This quadric squishes small probabilities, making it less likely we1421 * This quadric squishes small probabilities, making it less likely we
1411 * act on an unlikely task<->page relation.1422 * act on an unlikely task<->page relation.
1412 */1423 */
1413 last_cpupid = page_cpupid_xchg_last(page, this_cpupid);
1414 if (!cpupid_pid_unset(last_cpupid) &&1424 if (!cpupid_pid_unset(last_cpupid) &&
1415 cpupid_to_nid(last_cpupid) != dst_nid)1425 cpupid_to_nid(last_cpupid) != dst_nid)
1416 return false;1426 return false;

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