From b3ebc513d9ef54ff6e6e92ac94c4d05b7b060ec1 Mon Sep 17 00:00:00 2001 From: "Kirill A. Shutemov" Date: Thu, 19 Nov 2015 10:48:26 +1100 Subject: [PATCH] mm-prepare-page_referenced-and-page_idle-to-new-thp-refcounting-fix x86_64 allnoconfig: In file included from mm/rmap.c:47: include/linux/mm.h: In function 'page_referenced': include/linux/mm.h:448: error: call to '__compiletime_assert_448' declared with attribute error: BUILD_BUG failed make[1]: *** [mm/rmap.o] Error 1 make: *** [mm/rmap.o] Error 2 Signed-off-by: Andrew Morton --- include/linux/mm.h | 20 +++++--------------- mm/huge_memory.c | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 91c3f0887d58d0..53e9f4b4f5221b 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -433,24 +433,14 @@ static inline int page_mapcount(struct page *page) return ret; } +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +int total_mapcount(struct page *page); +#else static inline int total_mapcount(struct page *page) { - int i, ret; - - VM_BUG_ON_PAGE(PageTail(page), page); - - if (likely(!PageCompound(page))) - return atomic_read(&page->_mapcount) + 1; - - ret = compound_mapcount(page); - if (PageHuge(page)) - return ret; - for (i = 0; i < HPAGE_PMD_NR; i++) - ret += atomic_read(&page[i]._mapcount) + 1; - if (PageDoubleMap(page)) - ret -= HPAGE_PMD_NR; - return ret; + return page_mapcount(page); } +#endif static inline int page_count(struct page *page) { diff --git a/mm/huge_memory.c b/mm/huge_memory.c index b071974686fd2d..b41793b12a2dd8 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3223,6 +3223,25 @@ static void __split_huge_page(struct page *page, struct list_head *list) } } +int total_mapcount(struct page *page) +{ + int i, ret; + + VM_BUG_ON_PAGE(PageTail(page), page); + + if (likely(!PageCompound(page))) + return atomic_read(&page->_mapcount) + 1; + + ret = compound_mapcount(page); + if (PageHuge(page)) + return ret; + for (i = 0; i < HPAGE_PMD_NR; i++) + ret += atomic_read(&page[i]._mapcount) + 1; + if (PageDoubleMap(page)) + ret -= HPAGE_PMD_NR; + return ret; +} + /* * This function splits huge page into normal pages. @page can point to any * subpage of huge page to split. Split doesn't change the position of @page.