linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
To: Andi Kleen <tatsu@ab.jp.nec.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Wu Fengguang <fengguang.wu@intel.com>, Mel Gorman <mel@csn.ul.ie>,
	Christoph Lameter <cl@linux-foundation.org>,
	Huang Ying <ying.huang@intel.com>,
	Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>,
	tony.luck@intel.com, LKML <linux-kernel@vger.kernel.org>,
	linux-mm <linux-mm@kvack.org>
Subject: [PATCH 4/7] hugetlb, migration: add migration_hugepage_entry_wait()
Date: Fri, 21 Jan 2011 15:28:57 +0900	[thread overview]
Message-ID: <1295591340-1862-5-git-send-email-n-horiguchi@ah.jp.nec.com> (raw)
In-Reply-To: <1295591340-1862-1-git-send-email-n-horiguchi@ah.jp.nec.com>

migration_entry_wait() doesn't work for hugepage, because page->ptl
on hugepage is unused for now. So this patch introduces a hugepage
variant of this function.

Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
---
 include/linux/swapops.h |    8 ++++++++
 mm/hugetlb.c            |    3 ++-
 mm/migrate.c            |   33 +++++++++++++++++++++++++++++++++
 3 files changed, 43 insertions(+), 1 deletions(-)

diff --git v2.6.38-rc1/include/linux/swapops.h v2.6.38-rc1/include/linux/swapops.h
index cd42e30..a220ef5 100644
--- v2.6.38-rc1/include/linux/swapops.h
+++ v2.6.38-rc1/include/linux/swapops.h
@@ -169,3 +169,11 @@ static inline int non_swap_entry(swp_entry_t entry)
 	return 0;
 }
 #endif
+
+#if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_MIGRATION)
+extern void migration_hugepage_entry_wait(struct mm_struct *mm, pmd_t *pmd,
+					unsigned long address);
+#else
+static inline void migration_hugepage_entry_wait(struct mm_struct *mm,
+				 pmd_t *pmd, unsigned long address) { }
+#endif
diff --git v2.6.38-rc1/mm/hugetlb.c v2.6.38-rc1/mm/hugetlb.c
index 97c7471..d3b856a 100644
--- v2.6.38-rc1/mm/hugetlb.c
+++ v2.6.38-rc1/mm/hugetlb.c
@@ -2618,7 +2618,8 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
 	if (ptep) {
 		entry = huge_ptep_get(ptep);
 		if (unlikely(is_hugetlb_entry_migration(entry))) {
-			migration_entry_wait(mm, (pmd_t *)ptep, address);
+			migration_hugepage_entry_wait(mm, (pmd_t *)ptep,
+						      address);
 			return 0;
 		} else if (unlikely(is_hugetlb_entry_hwpoisoned(entry)))
 			return VM_FAULT_HWPOISON_LARGE | 
diff --git v2.6.38-rc1/mm/migrate.c v2.6.38-rc1/mm/migrate.c
index 46fe8cc..363685f 100644
--- v2.6.38-rc1/mm/migrate.c
+++ v2.6.38-rc1/mm/migrate.c
@@ -220,6 +220,39 @@ out:
 	pte_unmap_unlock(ptep, ptl);
 }
 
+void migration_hugepage_entry_wait(struct mm_struct *mm, pmd_t *pmd,
+				   unsigned long address)
+{
+	pte_t *ptep, pte;
+	spinlock_t *ptl;
+	swp_entry_t entry;
+	struct page *page;
+
+	ptep = (pte_t *)pmd;
+	ptl = &(mm)->page_table_lock;
+	spin_lock(ptl);
+	pte = *ptep;
+	if (!is_swap_pte(pte))
+		goto out;
+
+	entry = pte_to_swp_entry(pte);
+	if (!is_migration_entry(entry))
+		goto out;
+
+	page = migration_entry_to_page(entry);
+
+	if (!get_page_unless_zero(page))
+		goto out;
+	spin_unlock(ptl);
+	pte_unmap(ptep);
+	wait_on_page_locked(page);
+	put_page(page);
+	return;
+out:
+	spin_unlock(ptl);
+	pte_unmap(ptep);
+}
+
 /*
  * Replace the page in the mapping.
  *
-- 
1.7.3.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2011-01-21  6:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-21  6:28 [PATCH 0/7] HWPOISON for hugepage backed KVM guest Naoya Horiguchi
2011-01-21  6:28 ` [PATCH 1/7] hugetlb: check swap entry in follow_hugetlb_page() Naoya Horiguchi
2011-01-21  6:28 ` [PATCH 2/7] check hugepage swap entry in get_user_pages_fast() Naoya Horiguchi
2011-01-21  6:28 ` [PATCH 3/7] remove putback_lru_pages() in hugepage migration context Naoya Horiguchi
2011-01-21  6:40   ` Minchan Kim
2011-01-21 10:00     ` Naoya Horiguchi
2011-01-21  6:28 ` Naoya Horiguchi [this message]
2011-01-21  6:28 ` [PATCH 5/7] hugetlb: fix race condition between hugepage soft offline and page fault Naoya Horiguchi
2011-01-21  6:28 ` [PATCH 6/7] HWPOISON: pass order to set/clear_page_hwpoison_huge_page() Naoya Horiguchi
2011-01-21  6:29 ` [PATCH 7/7] HWPOISON, hugetlb: fix hard offline for hugepage backed KVM guest Naoya Horiguchi

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=1295591340-1862-5-git-send-email-n-horiguchi@ah.jp.nec.com \
    --to=n-horiguchi@ah.jp.nec.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux-foundation.org \
    --cc=fengguang.wu@intel.com \
    --cc=fernando@oss.ntt.co.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mel@csn.ul.ie \
    --cc=tatsu@ab.jp.nec.com \
    --cc=tony.luck@intel.com \
    --cc=ying.huang@intel.com \
    /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