Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1599534

[PATCH v4 10/11] mm: migrate: move_pages() supports thp migration

From Zi Yan <zi.yan@sent.com>
Newsgroups linux.kernel
Subject [PATCH v4 10/11] mm: migrate: move_pages() supports thp migration
Date 2017-03-13 16:50 +0100
Message-ID <tkAoq-2CJ-35@gated-at.bofh.it> (permalink)
References <tkAop-2CJ-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>

This patch enables thp migration for move_pages(2).

Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
---
 mm/migrate.c | 37 ++++++++++++++++++++++++++++---------
 1 file changed, 28 insertions(+), 9 deletions(-)

diff --git a/mm/migrate.c b/mm/migrate.c
index 0bbad6dcf95a..0f9a97c76298 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1410,7 +1410,17 @@ static struct page *new_page_node(struct page *p, unsigned long private,
 	if (PageHuge(p))
 		return alloc_huge_page_node(page_hstate(compound_head(p)),
 					pm->node);
-	else
+	else if (thp_migration_supported() && PageTransHuge(p)) {
+		struct page *thp;
+
+		thp = alloc_pages_node(pm->node,
+			(GFP_TRANSHUGE | __GFP_THISNODE) & ~__GFP_RECLAIM,
+			HPAGE_PMD_ORDER);
+		if (!thp)
+			return NULL;
+		prep_transhuge_page(thp);
+		return thp;
+	} else
 		return __alloc_pages_node(pm->node,
 				GFP_HIGHUSER_MOVABLE | __GFP_THISNODE, 0);
 }
@@ -1437,6 +1447,8 @@ static int do_move_page_to_node_array(struct mm_struct *mm,
 	for (pp = pm; pp->node != MAX_NUMNODES; pp++) {
 		struct vm_area_struct *vma;
 		struct page *page;
+		struct page *head;
+		unsigned int follflags;
 
 		err = -EFAULT;
 		vma = find_vma(mm, pp->addr);
@@ -1444,8 +1456,10 @@ static int do_move_page_to_node_array(struct mm_struct *mm,
 			goto set_status;
 
 		/* FOLL_DUMP to ignore special (like zero) pages */
-		page = follow_page(vma, pp->addr,
-				FOLL_GET | FOLL_SPLIT | FOLL_DUMP);
+		follflags = FOLL_GET | FOLL_DUMP;
+		if (!thp_migration_supported())
+			follflags |= FOLL_SPLIT;
+		page = follow_page(vma, pp->addr, follflags);
 
 		err = PTR_ERR(page);
 		if (IS_ERR(page))
@@ -1455,7 +1469,6 @@ static int do_move_page_to_node_array(struct mm_struct *mm,
 		if (!page)
 			goto set_status;
 
-		pp->page = page;
 		err = page_to_nid(page);
 
 		if (err == pp->node)
@@ -1470,16 +1483,22 @@ static int do_move_page_to_node_array(struct mm_struct *mm,
 			goto put_and_set;
 
 		if (PageHuge(page)) {
-			if (PageHead(page))
+			if (PageHead(page)) {
 				isolate_huge_page(page, &pagelist);
+				err = 0;
+				pp->page = page;
+			}
 			goto put_and_set;
 		}
 
-		err = isolate_lru_page(page);
+		pp->page = compound_head(page);
+		head = compound_head(page);
+		err = isolate_lru_page(head);
 		if (!err) {
-			list_add_tail(&page->lru, &pagelist);
-			inc_node_page_state(page, NR_ISOLATED_ANON +
-					    page_is_file_cache(page));
+			list_add_tail(&head->lru, &pagelist);
+			mod_node_page_state(page_pgdat(head),
+				NR_ISOLATED_ANON + page_is_file_cache(head),
+				hpage_nr_pages(head));
 		}
 put_and_set:
 		/*
-- 
2.11.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v4 00/11] mm: page migration enhancement for thp Zi Yan <zi.yan@sent.com> - 2017-03-13 16:50 +0100
  [PATCH v4 09/11] mm: mempolicy: mbind and migrate_pages support thp migration Zi Yan <zi.yan@sent.com> - 2017-03-13 16:50 +0100
  [PATCH v4 08/11] mm: hwpoison: soft offline supports thp migration Zi Yan <zi.yan@sent.com> - 2017-03-13 16:50 +0100
  [PATCH v4 05/11] mm: thp: enable thp migration in generic path Zi Yan <zi.yan@sent.com> - 2017-03-13 16:50 +0100
    Re: [PATCH v4 05/11] mm: thp: enable thp migration in generic path kbuild test robot <lkp@intel.com> - 2017-03-14 22:30 +0100
      Re: [PATCH v4 05/11] mm: thp: enable thp migration in generic path Geert Uytterhoeven <geert@linux-m68k.org> - 2017-03-15 10:10 +0100
    Re: [PATCH v4 05/11] mm: thp: enable thp migration in generic path "Kirill A. Shutemov" <kirill@shutemov.name> - 2017-03-24 15:30 +0100
  [PATCH v4 10/11] mm: migrate: move_pages() supports thp migration Zi Yan <zi.yan@sent.com> - 2017-03-13 16:50 +0100
  [PATCH v4 01/11] mm: x86: move _PAGE_SWP_SOFT_DIRTY from bit 7 to bit 1 Zi Yan <zi.yan@sent.com> - 2017-03-13 16:50 +0100
    Re: [PATCH v4 01/11] mm: x86: move _PAGE_SWP_SOFT_DIRTY from bit 7  to bit 1 Tim Chen <tim.c.chen@linux.intel.com> - 2017-03-24 19:30 +0100
  [PATCH v4 04/11] mm: thp: introduce CONFIG_ARCH_ENABLE_THP_MIGRATION Zi Yan <zi.yan@sent.com> - 2017-03-13 16:50 +0100
    Re: [PATCH v4 04/11] mm: thp: introduce  CONFIG_ARCH_ENABLE_THP_MIGRATION "Kirill A. Shutemov" <kirill@shutemov.name> - 2017-03-24 15:20 +0100
  [PATCH v4 07/11] mm: soft-dirty: keep soft-dirty bits over thp migration Zi Yan <zi.yan@sent.com> - 2017-03-13 16:50 +0100

csiph-web