aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>2015-04-15 19:14:41 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-15 19:35:19 -0400
commit7e1f049efb86bd86c06b80eeac0ef80cdeb8c0e7 (patch)
treef98ef2ddc292f1a6d9337cba73864618e7fcbcae
parentbcc54222309c70ebcb6c69c156fba4a13dee0a3b (diff)
mm: hugetlb: cleanup using paeg_huge_active()
Now we have an easy access to hugepages' activeness, so existing helpers to get the information can be cleaned up. [akpm@linux-foundation.org: s/PageHugeActive/page_huge_active/] Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> Cc: Hugh Dickins <hughd@google.com> Reviewed-by: Michal Hocko <mhocko@suse.cz> Cc: Mel Gorman <mgorman@suse.de> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/hugetlb.h2
-rw-r--r--include/linux/page-flags.h7
-rw-r--r--mm/hugetlb.c42
-rw-r--r--mm/memory_hotplug.c2
4 files changed, 13 insertions, 40 deletions
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 5713c49a4a5c..205026175c42 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -84,7 +84,6 @@ void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed);
84int dequeue_hwpoisoned_huge_page(struct page *page); 84int dequeue_hwpoisoned_huge_page(struct page *page);
85bool isolate_huge_page(struct page *page, struct list_head *list); 85bool isolate_huge_page(struct page *page, struct list_head *list);
86void putback_active_hugepage(struct page *page); 86void putback_active_hugepage(struct page *page);
87bool is_hugepage_active(struct page *page);
88void free_huge_page(struct page *page); 87void free_huge_page(struct page *page);
89 88
90#ifdef CONFIG_ARCH_WANT_HUGE_PMD_SHARE 89#ifdef CONFIG_ARCH_WANT_HUGE_PMD_SHARE
@@ -152,7 +151,6 @@ static inline bool isolate_huge_page(struct page *page, struct list_head *list)
152 return false; 151 return false;
153} 152}
154#define putback_active_hugepage(p) do {} while (0) 153#define putback_active_hugepage(p) do {} while (0)
155#define is_hugepage_active(x) false
156 154
157static inline unsigned long hugetlb_change_protection(struct vm_area_struct *vma, 155static inline unsigned long hugetlb_change_protection(struct vm_area_struct *vma,
158 unsigned long address, unsigned long end, pgprot_t newprot) 156 unsigned long address, unsigned long end, pgprot_t newprot)
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 84d10b65cec6..f34e040b34e9 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -470,11 +470,18 @@ static inline void ClearPageCompound(struct page *page)
470#ifdef CONFIG_HUGETLB_PAGE 470#ifdef CONFIG_HUGETLB_PAGE
471int PageHuge(struct page *page); 471int PageHuge(struct page *page);
472int PageHeadHuge(struct page *page); 472int PageHeadHuge(struct page *page);
473bool page_huge_active(struct page *page);
473#else 474#else
474TESTPAGEFLAG_FALSE(Huge) 475TESTPAGEFLAG_FALSE(Huge)
475TESTPAGEFLAG_FALSE(HeadHuge) 476TESTPAGEFLAG_FALSE(HeadHuge)
477
478static inline bool page_huge_active(struct page *page)
479{
480 return 0;
481}
476#endif 482#endif
477 483
484
478#ifdef CONFIG_TRANSPARENT_HUGEPAGE 485#ifdef CONFIG_TRANSPARENT_HUGEPAGE
479/* 486/*
480 * PageHuge() only returns true for hugetlbfs pages, but not for 487 * PageHuge() only returns true for hugetlbfs pages, but not for
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 05407831016b..271e4432734c 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3896,20 +3896,6 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address,
3896 3896
3897#ifdef CONFIG_MEMORY_FAILURE 3897#ifdef CONFIG_MEMORY_FAILURE
3898 3898
3899/* Should be called in hugetlb_lock */
3900static int is_hugepage_on_freelist(struct page *hpage)
3901{
3902 struct page *page;
3903 struct page *tmp;
3904 struct hstate *h = page_hstate(hpage);
3905 int nid = page_to_nid(hpage);
3906
3907 list_for_each_entry_safe(page, tmp, &h->hugepage_freelists[nid], lru)
3908 if (page == hpage)
3909 return 1;
3910 return 0;
3911}
3912
3913/* 3899/*
3914 * This function is called from memory failure code. 3900 * This function is called from memory failure code.
3915 * Assume the caller holds page lock of the head page. 3901 * Assume the caller holds page lock of the head page.
@@ -3921,7 +3907,11 @@ int dequeue_hwpoisoned_huge_page(struct page *hpage)
3921 int ret = -EBUSY; 3907 int ret = -EBUSY;
3922 3908
3923 spin_lock(&hugetlb_lock); 3909 spin_lock(&hugetlb_lock);
3924 if (is_hugepage_on_freelist(hpage)) { 3910 /*
3911 * Just checking !page_huge_active is not enough, because that could be
3912 * an isolated/hwpoisoned hugepage (which have >0 refcount).
3913 */
3914 if (!page_huge_active(hpage) && !page_count(hpage)) {
3925 /* 3915 /*
3926 * Hwpoisoned hugepage isn't linked to activelist or freelist, 3916 * Hwpoisoned hugepage isn't linked to activelist or freelist,
3927 * but dangling hpage->lru can trigger list-debug warnings 3917 * but dangling hpage->lru can trigger list-debug warnings
@@ -3965,25 +3955,3 @@ void putback_active_hugepage(struct page *page)
3965 spin_unlock(&hugetlb_lock); 3955 spin_unlock(&hugetlb_lock);
3966 put_page(page); 3956 put_page(page);
3967} 3957}
3968
3969bool is_hugepage_active(struct page *page)
3970{
3971 VM_BUG_ON_PAGE(!PageHuge(page), page);
3972 /*
3973 * This function can be called for a tail page because the caller,
3974 * scan_movable_pages, scans through a given pfn-range which typically
3975 * covers one memory block. In systems using gigantic hugepage (1GB
3976 * for x86_64,) a hugepage is larger than a memory block, and we don't
3977 * support migrating such large hugepages for now, so return false
3978 * when called for tail pages.
3979 */
3980 if (PageTail(page))
3981 return false;
3982 /*
3983 * Refcount of a hwpoisoned hugepages is 1, but they are not active,
3984 * so we should return false for them.
3985 */
3986 if (unlikely(PageHWPoison(page)))
3987 return false;
3988 return page_count(page) > 0;
3989}
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index e2e8014fb755..457bde530cbe 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1373,7 +1373,7 @@ static unsigned long scan_movable_pages(unsigned long start, unsigned long end)
1373 if (PageLRU(page)) 1373 if (PageLRU(page))
1374 return pfn; 1374 return pfn;
1375 if (PageHuge(page)) { 1375 if (PageHuge(page)) {
1376 if (is_hugepage_active(page)) 1376 if (page_huge_active(page))
1377 return pfn; 1377 return pfn;
1378 else 1378 else
1379 pfn = round_up(pfn + 1, 1379 pfn = round_up(pfn + 1,