linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
To: linux-mm@kvack.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Mel Gorman <mel@csn.ul.ie>, Hugh Dickins <hughd@google.com>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	Andi Kleen <andi@firstfloor.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/9] migrate: make core migration code aware of hugepage
Date: Thu, 21 Feb 2013 14:41:41 -0500	[thread overview]
Message-ID: <1361475708-25991-3-git-send-email-n-horiguchi@ah.jp.nec.com> (raw)
In-Reply-To: <1361475708-25991-1-git-send-email-n-horiguchi@ah.jp.nec.com>

Before enabling each user of page migration to support hugepage,
this patch adds necessary changes on core migration code.
The main change is that the list of pages to migrate can link
not only LRU pages, but also hugepages.
Along with this, functions such as migrate_pages() and
putback_movable_pages() need to be changed to handle hugepages.

Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
---
 include/linux/hugetlb.h   |  4 ++++
 include/linux/mempolicy.h |  2 +-
 include/linux/migrate.h   |  6 ++++++
 mm/hugetlb.c              | 16 ++++++++++++++++
 mm/migrate.c              | 27 +++++++++++++++++++++++++--
 5 files changed, 52 insertions(+), 3 deletions(-)

diff --git v3.8.orig/include/linux/hugetlb.h v3.8/include/linux/hugetlb.h
index 40b27f6..8f87115 100644
--- v3.8.orig/include/linux/hugetlb.h
+++ v3.8/include/linux/hugetlb.h
@@ -67,6 +67,8 @@ int hugetlb_reserve_pages(struct inode *inode, long from, long to,
 						vm_flags_t vm_flags);
 void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed);
 int dequeue_hwpoisoned_huge_page(struct page *page);
+void putback_active_hugepage(struct page *page);
+void putback_active_hugepages(struct list_head *l);
 void copy_huge_page(struct page *dst, struct page *src);
 
 extern unsigned long hugepages_treat_as_movable;
@@ -130,6 +132,8 @@ static inline int dequeue_hwpoisoned_huge_page(struct page *page)
 	return 0;
 }
 
+#define putback_active_hugepage(p) 0
+#define putback_active_hugepages(l) 0
 static inline void copy_huge_page(struct page *dst, struct page *src)
 {
 }
diff --git v3.8.orig/include/linux/mempolicy.h v3.8/include/linux/mempolicy.h
index 0d7df39..2e475b5 100644
--- v3.8.orig/include/linux/mempolicy.h
+++ v3.8/include/linux/mempolicy.h
@@ -173,7 +173,7 @@ extern int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol);
 /* Check if a vma is migratable */
 static inline int vma_migratable(struct vm_area_struct *vma)
 {
-	if (vma->vm_flags & (VM_IO | VM_HUGETLB | VM_PFNMAP))
+	if (vma->vm_flags & (VM_IO | VM_PFNMAP))
 		return 0;
 	/*
 	 * Migration allocates pages in the highest zone. If we cannot
diff --git v3.8.orig/include/linux/migrate.h v3.8/include/linux/migrate.h
index 1e9f627..d626c27 100644
--- v3.8.orig/include/linux/migrate.h
+++ v3.8/include/linux/migrate.h
@@ -42,6 +42,9 @@ extern int migrate_page(struct address_space *,
 extern int migrate_pages(struct list_head *l, new_page_t x,
 			unsigned long private, bool offlining,
 			enum migrate_mode mode, int reason);
+extern int migrate_movable_pages(struct list_head *from,
+		new_page_t get_new_page, unsigned long private, bool offlining,
+		enum migrate_mode mode, int reason);
 extern int migrate_huge_page(struct page *, new_page_t x,
 			unsigned long private, bool offlining,
 			enum migrate_mode mode);
@@ -64,6 +67,9 @@ static inline void putback_movable_pages(struct list_head *l) {}
 static inline int migrate_pages(struct list_head *l, new_page_t x,
 		unsigned long private, bool offlining,
 		enum migrate_mode mode, int reason) { return -ENOSYS; }
+static inline int migrate_movable_pages(struct list_head *from,
+		new_page_t get_new_page, unsigned long private, bool offlining,
+		enum migrate_mode mode, int reason) { return -ENOSYS; }
 static inline int migrate_huge_page(struct page *page, new_page_t x,
 		unsigned long private, bool offlining,
 		enum migrate_mode mode) { return -ENOSYS; }
diff --git v3.8.orig/mm/hugetlb.c v3.8/mm/hugetlb.c
index 351025e..cb9d43b8 100644
--- v3.8.orig/mm/hugetlb.c
+++ v3.8/mm/hugetlb.c
@@ -3186,3 +3186,19 @@ int dequeue_hwpoisoned_huge_page(struct page *hpage)
 	return ret;
 }
 #endif
+
+void putback_active_hugepage(struct page *page)
+{
+	VM_BUG_ON(!PageHead(page));
+	list_move_tail(&page->lru, &(page_hstate(page))->hugepage_activelist);
+	put_page(page);
+}
+
+void putback_active_hugepages(struct list_head *l)
+{
+	struct page *page;
+	struct page *page2;
+
+	list_for_each_entry_safe(page, page2, l, lru)
+		putback_active_hugepage(page);
+}
diff --git v3.8.orig/mm/migrate.c v3.8/mm/migrate.c
index 7d84f4c..e305dc0 100644
--- v3.8.orig/mm/migrate.c
+++ v3.8/mm/migrate.c
@@ -100,6 +100,10 @@ void putback_movable_pages(struct list_head *l)
 	struct page *page2;
 
 	list_for_each_entry_safe(page, page2, l, lru) {
+		if (unlikely(PageHuge(page))) {
+			putback_active_hugepage(page);
+			continue;
+		}
 		list_del(&page->lru);
 		dec_zone_page_state(page, NR_ISOLATED_ANON +
 				page_is_file_cache(page));
@@ -1046,8 +1050,12 @@ int migrate_pages(struct list_head *from,
 
 		list_for_each_entry_safe(page, page2, from, lru) {
 			cond_resched();
-
-			rc = unmap_and_move(get_new_page, private,
+			if (PageHuge(page))
+				rc = unmap_and_move_huge_page(get_new_page,
+						private, page, pass > 2,
+						offlining, mode);
+			else
+				rc = unmap_and_move(get_new_page, private,
 						page, pass > 2, offlining,
 						mode);
 
@@ -1081,6 +1089,21 @@ int migrate_pages(struct list_head *from,
 	return rc;
 }
 
+int migrate_movable_pages(struct list_head *from, new_page_t get_new_page,
+			unsigned long private, bool offlining,
+			enum migrate_mode mode, int reason)
+{
+	int err = 0;
+
+	if (!list_empty(from)) {
+		err = migrate_pages(from, get_new_page, private,
+				    offlining, mode, reason);
+		if (err)
+			putback_movable_pages(from);
+	}
+	return err;
+}
+
 int migrate_huge_page(struct page *hpage, new_page_t get_new_page,
 		      unsigned long private, bool offlining,
 		      enum migrate_mode mode)
-- 
1.7.11.7


  parent reply	other threads:[~2013-02-21 19:45 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-21 19:41 [RFC][PATCH 0/9] extend hugepage migration Naoya Horiguchi
2013-02-21 19:41 ` [PATCH 1/9] migrate: add migrate_entry_wait_huge() Naoya Horiguchi
2013-03-18 14:51   ` Michal Hocko
2013-03-19  0:06     ` Naoya Horiguchi
2013-03-19 23:57   ` Simon Jeons
2013-03-20 21:53     ` Naoya Horiguchi
2013-03-20 23:36       ` Simon Jeons
2013-04-04  4:57         ` Simon Jeons
2013-02-21 19:41 ` Naoya Horiguchi [this message]
2013-03-18 15:22   ` [PATCH 2/9] migrate: make core migration code aware of hugepage Michal Hocko
2013-03-18 15:33     ` Michal Hocko
2013-03-19  0:06       ` Naoya Horiguchi
2013-02-21 19:41 ` [PATCH 3/9] soft-offline: use migrate_pages() instead of migrate_huge_page() Naoya Horiguchi
2013-02-27  7:25   ` Chen Gong
2013-02-27 17:06     ` Naoya Horiguchi
2013-02-27 17:57       ` Naoya Horiguchi
2013-02-21 19:41 ` [PATCH 4/9] migrate: clean up migrate_huge_page() Naoya Horiguchi
2013-02-21 19:41 ` [PATCH 5/9] migrate: enable migrate_pages() to migrate hugepage Naoya Horiguchi
2013-03-18 15:40   ` Michal Hocko
2013-03-19  0:07     ` Naoya Horiguchi
2013-03-19  7:11       ` Michal Hocko
2013-03-20  6:12         ` Naoya Horiguchi
2013-03-20  7:41           ` Michal Hocko
2013-03-20  0:31       ` Simon Jeons
2013-03-20 21:59         ` Naoya Horiguchi
2013-03-21  0:06           ` Simon Jeons
2013-02-21 19:41 ` [PATCH 6/9] migrate: enable move_pages() " Naoya Horiguchi
2013-02-21 19:41 ` [PATCH 7/9] mbind: enable mbind() " Naoya Horiguchi
2013-02-21 19:41 ` [PATCH 8/9] memory-hotplug: enable memory hotplug to handle hugepage Naoya Horiguchi
2013-02-23  7:05   ` Hillf Danton
2013-02-25 16:57     ` Naoya Horiguchi
2013-02-27  7:36   ` Chen Gong
2013-02-27 17:16     ` Naoya Horiguchi
2013-03-18 16:07   ` Michal Hocko
2013-03-20  3:55     ` Naoya Horiguchi
2013-03-20  7:57       ` Michal Hocko
2013-03-20  1:03   ` Simon Jeons
2013-03-20 22:05     ` Naoya Horiguchi
2013-03-20 23:55       ` Simon Jeons
2013-02-21 19:41 ` [PATCH 9/9] remove /proc/sys/vm/hugepages_treat_as_movable Naoya Horiguchi
2013-02-28  6:02   ` KOSAKI Motohiro
2013-02-28 18:16     ` Naoya Horiguchi
2013-03-18 15:51   ` Michal Hocko
2013-03-19  0:07     ` Naoya Horiguchi
2013-03-19 23:43 ` [RFC][PATCH 0/9] extend hugepage migration Simon Jeons
2013-03-20 21:35   ` Naoya Horiguchi
2013-03-20 23:49     ` Simon Jeons
2013-03-21 12:56       ` Michal Hocko
2013-03-21 23:46         ` Simon Jeons
     [not found]           ` <20130322081532.GC31457@dhcp22.suse.cz>
2013-04-05  1:14             ` Simon Jeons
2013-04-05  8:08               ` Michal Hocko
2013-04-05  9:00                 ` Simon Jeons
2013-04-05  9:30                   ` Michal Hocko
2013-04-07  0:32                     ` Simon Jeons
2013-04-07 14:05                       ` KOSAKI Motohiro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1361475708-25991-3-git-send-email-n-horiguchi@ah.jp.nec.com \
    --to=n-horiguchi@ah.jp.nec.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=hughd@google.com \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mel@csn.ul.ie \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).