aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>2013-09-11 17:22:04 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-11 18:57:48 -0400
commite632a938d914d271bec26e570d36c755a1e35e4c (patch)
treee0912384cab7b9bdc3eacd4b3e232207f7c3944d /mm
parente2d8cf405525d83e6ca42969be460f94b0339798 (diff)
mm: migrate: add hugepage migration code to move_pages()
Extend move_pages() to handle vma with VM_HUGETLB set. We will be able to migrate hugepage with move_pages(2) after applying the enablement patch which comes later in this series. We avoid getting refcount on tail pages of hugepage, because unlike thp, hugepage is not split and we need not care about races with splitting. And migration of larger (1GB for x86_64) hugepage are not enabled. Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> Acked-by: Andi Kleen <ak@linux.intel.com> Reviewed-by: Wanpeng Li <liwanp@linux.vnet.ibm.com> Cc: Hillf Danton <dhillf@gmail.com> Cc: Mel Gorman <mgorman@suse.de> Cc: Hugh Dickins <hughd@google.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Michal Hocko <mhocko@suse.cz> Cc: Rik van Riel <riel@redhat.com> Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/memory.c17
-rw-r--r--mm/migrate.c13
2 files changed, 26 insertions, 4 deletions
diff --git a/mm/memory.c b/mm/memory.c
index c1c6d59b2b03..2b73dbde2274 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1481,7 +1481,8 @@ struct page *follow_page_mask(struct vm_area_struct *vma,
1481 if (pud_none(*pud)) 1481 if (pud_none(*pud))
1482 goto no_page_table; 1482 goto no_page_table;
1483 if (pud_huge(*pud) && vma->vm_flags & VM_HUGETLB) { 1483 if (pud_huge(*pud) && vma->vm_flags & VM_HUGETLB) {
1484 BUG_ON(flags & FOLL_GET); 1484 if (flags & FOLL_GET)
1485 goto out;
1485 page = follow_huge_pud(mm, address, pud, flags & FOLL_WRITE); 1486 page = follow_huge_pud(mm, address, pud, flags & FOLL_WRITE);
1486 goto out; 1487 goto out;
1487 } 1488 }
@@ -1492,8 +1493,20 @@ struct page *follow_page_mask(struct vm_area_struct *vma,
1492 if (pmd_none(*pmd)) 1493 if (pmd_none(*pmd))
1493 goto no_page_table; 1494 goto no_page_table;
1494 if (pmd_huge(*pmd) && vma->vm_flags & VM_HUGETLB) { 1495 if (pmd_huge(*pmd) && vma->vm_flags & VM_HUGETLB) {
1495 BUG_ON(flags & FOLL_GET);
1496 page = follow_huge_pmd(mm, address, pmd, flags & FOLL_WRITE); 1496 page = follow_huge_pmd(mm, address, pmd, flags & FOLL_WRITE);
1497 if (flags & FOLL_GET) {
1498 /*
1499 * Refcount on tail pages are not well-defined and
1500 * shouldn't be taken. The caller should handle a NULL
1501 * return when trying to follow tail pages.
1502 */
1503 if (PageHead(page))
1504 get_page(page);
1505 else {
1506 page = NULL;
1507 goto out;
1508 }
1509 }
1497 goto out; 1510 goto out;
1498 } 1511 }
1499 if ((flags & FOLL_NUMA) && pmd_numa(*pmd)) 1512 if ((flags & FOLL_NUMA) && pmd_numa(*pmd))
diff --git a/mm/migrate.c b/mm/migrate.c
index 3ec47d3394c8..d3137375fa80 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1092,7 +1092,11 @@ static struct page *new_page_node(struct page *p, unsigned long private,
1092 1092
1093 *result = &pm->status; 1093 *result = &pm->status;
1094 1094
1095 return alloc_pages_exact_node(pm->node, 1095 if (PageHuge(p))
1096 return alloc_huge_page_node(page_hstate(compound_head(p)),
1097 pm->node);
1098 else
1099 return alloc_pages_exact_node(pm->node,
1096 GFP_HIGHUSER_MOVABLE | GFP_THISNODE, 0); 1100 GFP_HIGHUSER_MOVABLE | GFP_THISNODE, 0);
1097} 1101}
1098 1102
@@ -1152,6 +1156,11 @@ static int do_move_page_to_node_array(struct mm_struct *mm,
1152 !migrate_all) 1156 !migrate_all)
1153 goto put_and_set; 1157 goto put_and_set;
1154 1158
1159 if (PageHuge(page)) {
1160 isolate_huge_page(page, &pagelist);
1161 goto put_and_set;
1162 }
1163
1155 err = isolate_lru_page(page); 1164 err = isolate_lru_page(page);
1156 if (!err) { 1165 if (!err) {
1157 list_add_tail(&page->lru, &pagelist); 1166 list_add_tail(&page->lru, &pagelist);
@@ -1174,7 +1183,7 @@ set_status:
1174 err = migrate_pages(&pagelist, new_page_node, 1183 err = migrate_pages(&pagelist, new_page_node,
1175 (unsigned long)pm, MIGRATE_SYNC, MR_SYSCALL); 1184 (unsigned long)pm, MIGRATE_SYNC, MR_SYSCALL);
1176 if (err) 1185 if (err)
1177 putback_lru_pages(&pagelist); 1186 putback_movable_pages(&pagelist);
1178 } 1187 }
1179 1188
1180 up_read(&mm->mmap_sem); 1189 up_read(&mm->mmap_sem);