aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/vm/page_migration
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2006-02-06 07:43:13 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-02-06 07:43:13 -0500
commitb2faf597d93bdf5e2d12d93ea0815935a73f749e (patch)
tree1876616290ff282b8a0814e2429d23e0104f3701 /Documentation/vm/page_migration
parent638e174688f58200d0deb7435093435e7d737b09 (diff)
parent410c05427a69f53851637ccb85c2212131409fbd (diff)
Merge branch 'origin'
Diffstat (limited to 'Documentation/vm/page_migration')
-rw-r--r--Documentation/vm/page_migration129
1 files changed, 129 insertions, 0 deletions
diff --git a/Documentation/vm/page_migration b/Documentation/vm/page_migration
new file mode 100644
index 000000000000..c52820fcf500
--- /dev/null
+++ b/Documentation/vm/page_migration
@@ -0,0 +1,129 @@
1Page migration
2--------------
3
4Page migration allows the moving of the physical location of pages between
5nodes in a numa system while the process is running. This means that the
6virtual addresses that the process sees do not change. However, the
7system rearranges the physical location of those pages.
8
9The main intend of page migration is to reduce the latency of memory access
10by moving pages near to the processor where the process accessing that memory
11is running.
12
13Page migration allows a process to manually relocate the node on which its
14pages are located through the MF_MOVE and MF_MOVE_ALL options while setting
15a new memory policy. The pages of process can also be relocated
16from another process using the sys_migrate_pages() function call. The
17migrate_pages function call takes two sets of nodes and moves pages of a
18process that are located on the from nodes to the destination nodes.
19
20Manual migration is very useful if for example the scheduler has relocated
21a process to a processor on a distant node. A batch scheduler or an
22administrator may detect the situation and move the pages of the process
23nearer to the new processor. At some point in the future we may have
24some mechanism in the scheduler that will automatically move the pages.
25
26Larger installations usually partition the system using cpusets into
27sections of nodes. Paul Jackson has equipped cpusets with the ability to
28move pages when a task is moved to another cpuset. This allows automatic
29control over locality of a process. If a task is moved to a new cpuset
30then also all its pages are moved with it so that the performance of the
31process does not sink dramatically (as is the case today).
32
33Page migration allows the preservation of the relative location of pages
34within a group of nodes for all migration techniques which will preserve a
35particular memory allocation pattern generated even after migrating a
36process. This is necessary in order to preserve the memory latencies.
37Processes will run with similar performance after migration.
38
39Page migration occurs in several steps. First a high level
40description for those trying to use migrate_pages() and then
41a low level description of how the low level details work.
42
43A. Use of migrate_pages()
44-------------------------
45
461. Remove pages from the LRU.
47
48 Lists of pages to be migrated are generated by scanning over
49 pages and moving them into lists. This is done by
50 calling isolate_lru_page() or __isolate_lru_page().
51 Calling isolate_lru_page increases the references to the page
52 so that it cannot vanish under us.
53
542. Generate a list of newly allocates page to move the contents
55 of the first list to.
56
573. The migrate_pages() function is called which attempts
58 to do the migration. It returns the moved pages in the
59 list specified as the third parameter and the failed
60 migrations in the fourth parameter. The first parameter
61 will contain the pages that could still be retried.
62
634. The leftover pages of various types are returned
64 to the LRU using putback_to_lru_pages() or otherwise
65 disposed of. The pages will still have the refcount as
66 increased by isolate_lru_pages()!
67
68B. Operation of migrate_pages()
69--------------------------------
70
71migrate_pages does several passes over its list of pages. A page is moved
72if all references to a page are removable at the time.
73
74Steps:
75
761. Lock the page to be migrated
77
782. Insure that writeback is complete.
79
803. Make sure that the page has assigned swap cache entry if
81 it is an anonyous page. The swap cache reference is necessary
82 to preserve the information contain in the page table maps.
83
844. Prep the new page that we want to move to. It is locked
85 and set to not being uptodate so that all accesses to the new
86 page immediately lock while we are moving references.
87
885. All the page table references to the page are either dropped (file backed)
89 or converted to swap references (anonymous pages). This should decrease the
90 reference count.
91
926. The radix tree lock is taken
93
947. The refcount of the page is examined and we back out if references remain
95 otherwise we know that we are the only one referencing this page.
96
978. The radix tree is checked and if it does not contain the pointer to this
98 page then we back out.
99
1009. The mapping is checked. If the mapping is gone then a truncate action may
101 be in progress and we back out.
102
10310. The new page is prepped with some settings from the old page so that accesses
104 to the new page will be discovered to have the correct settings.
105
10611. The radix tree is changed to point to the new page.
107
10812. The reference count of the old page is dropped because the reference has now
109 been removed.
110
11113. The radix tree lock is dropped.
112
11314. The page contents are copied to the new page.
114
11515. The remaining page flags are copied to the new page.
116
11716. The old page flags are cleared to indicate that the page does
118 not use any information anymore.
119
12017. Queued up writeback on the new page is triggered.
121
12218. If swap pte's were generated for the page then remove them again.
123
12419. The locks are dropped from the old and new page.
125
12620. The new page is moved to the LRU.
127
128Christoph Lameter, December 19, 2005.
129