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


Groups > linux.kernel > #1583352

[PATCH 4/6] mm/migrate: Add new migrate mode MIGRATE_MT

From Anshuman Khandual <khandual@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject [PATCH 4/6] mm/migrate: Add new migrate mode MIGRATE_MT
Date 2017-02-17 12:30 +0100
Message-ID <tbOTE-3Eu-29@gated-at.bofh.it> (permalink)
References <tbOTD-3Eu-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Zi Yan <ziy@nvidia.com>

This change adds a new migration mode called MIGRATE_MT to enable multi
threaded page copy implementation inside copy_huge_page() function by
selectively calling copy_pages_mthread() when requested. But it still
falls back using the regular page copy mechanism instead the previous
multi threaded attempt fails. It also attempts multi threaded copy for
regular pages.

Signed-off-by: Zi Yan <zi.yan@cs.rutgers.edu>
Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
 include/linux/migrate_mode.h |  1 +
 mm/migrate.c                 | 25 ++++++++++++++++++-------
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/include/linux/migrate_mode.h b/include/linux/migrate_mode.h
index 89c1700..d344ad6 100644
--- a/include/linux/migrate_mode.h
+++ b/include/linux/migrate_mode.h
@@ -12,6 +12,7 @@ enum migrate_mode {
 	MIGRATE_SYNC_LIGHT	= 1<<1,
 	MIGRATE_SYNC		= 1<<2,
 	MIGRATE_ST		= 1<<3,
+	MIGRATE_MT		= 1<<4,
 };
 
 #endif		/* MIGRATE_MODE_H_INCLUDED */
diff --git a/mm/migrate.c b/mm/migrate.c
index 63c3682..6ac3572 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -594,6 +594,7 @@ static void copy_huge_page(struct page *dst, struct page *src,
 {
 	int i;
 	int nr_pages;
+	int rc = -EFAULT;
 
 	if (PageHuge(src)) {
 		/* hugetlbfs page */
@@ -610,10 +611,14 @@ static void copy_huge_page(struct page *dst, struct page *src,
 		nr_pages = hpage_nr_pages(src);
 	}
 
-	for (i = 0; i < nr_pages; i++) {
-		cond_resched();
-		copy_highpage(dst + i, src + i);
-	}
+	if (mode & MIGRATE_MT)
+		rc = copy_pages_mthread(dst, src, nr_pages);
+
+	if (rc)
+		for (i = 0; i < nr_pages; i++) {
+			cond_resched();
+			copy_highpage(dst + i, src + i);
+		}
 }
 
 /*
@@ -624,10 +629,16 @@ void migrate_page_copy(struct page *newpage, struct page *page,
 {
 	int cpupid;
 
-	if (PageHuge(page) || PageTransHuge(page))
+	if (PageHuge(page) || PageTransHuge(page)) {
 		copy_huge_page(newpage, page, mode);
-	else
-		copy_highpage(newpage, page);
+	} else {
+		if (mode & MIGRATE_MT) {
+			if (copy_pages_mthread(newpage, page, 1))
+				copy_highpage(newpage, page);
+		} else {
+			copy_highpage(newpage, page);
+		}
+	}
 
 	if (PageError(page))
 		SetPageError(newpage);
-- 
2.9.3

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


Thread

[PATCH 0/6] Enable parallel page migration Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2017-02-17 12:30 +0100
  [PATCH 6/6] sysctl: Add global tunable mt_page_copy Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2017-02-17 12:30 +0100
    Re: [PATCH 6/6] sysctl: Add global tunable mt_page_copy kbuild test robot <lkp@intel.com> - 2017-02-17 16:40 +0100
  [PATCH 2/6] mm/migrate: Make migrate_mode types non-exclusive Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2017-02-17 12:30 +0100
  [PATCH 1/6] mm/migrate: Add new mode parameter to migrate_page_copy() function Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2017-02-17 12:30 +0100
  [PATCH 4/6] mm/migrate: Add new migrate mode MIGRATE_MT Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2017-02-17 12:30 +0100
  Re: [PATCH 0/6] Enable parallel page migration Balbir Singh <bsingharora@gmail.com> - 2017-02-22 06:10 +0100
    Re: [PATCH 0/6] Enable parallel page migration Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2017-02-22 07:00 +0100
      Re: [PATCH 0/6] Enable parallel page migration Balbir Singh <bsingharora@gmail.com> - 2017-02-22 12:00 +0100

csiph-web