Commit d08d2b62 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Linus Torvalds

mm: remove the total_mapcount argument from page_trans_huge_mapcount()

All callers pass NULL, so we can stop calculating the value we would
store in it.

Link: https://lkml.kernel.org/r/20211220205943.456187-3-willy@infradead.orgSigned-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: default avatarWilliam Kucharski <william.kucharski@oracle.com>
Acked-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Cc: David Hildenbrand <david@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 66c7f7a6
...@@ -799,19 +799,15 @@ static inline int page_mapcount(struct page *page) ...@@ -799,19 +799,15 @@ static inline int page_mapcount(struct page *page)
#ifdef CONFIG_TRANSPARENT_HUGEPAGE #ifdef CONFIG_TRANSPARENT_HUGEPAGE
int total_mapcount(struct page *page); int total_mapcount(struct page *page);
int page_trans_huge_mapcount(struct page *page, int *total_mapcount); int page_trans_huge_mapcount(struct page *page);
#else #else
static inline int total_mapcount(struct page *page) static inline int total_mapcount(struct page *page)
{ {
return page_mapcount(page); return page_mapcount(page);
} }
static inline int page_trans_huge_mapcount(struct page *page, static inline int page_trans_huge_mapcount(struct page *page)
int *total_mapcount)
{ {
int mapcount = page_mapcount(page); return page_mapcount(page);
if (total_mapcount)
*total_mapcount = mapcount;
return mapcount;
} }
#endif #endif
......
...@@ -681,7 +681,7 @@ static inline int swp_swapcount(swp_entry_t entry) ...@@ -681,7 +681,7 @@ static inline int swp_swapcount(swp_entry_t entry)
} }
#define reuse_swap_page(page) \ #define reuse_swap_page(page) \
(page_trans_huge_mapcount(page, NULL) == 1) (page_trans_huge_mapcount(page) == 1)
static inline int try_to_free_swap(struct page *page) static inline int try_to_free_swap(struct page *page)
{ {
......
...@@ -2542,38 +2542,28 @@ int total_mapcount(struct page *page) ...@@ -2542,38 +2542,28 @@ int total_mapcount(struct page *page)
* need full accuracy to avoid breaking page pinning, because * need full accuracy to avoid breaking page pinning, because
* page_trans_huge_mapcount() is slower than page_mapcount(). * page_trans_huge_mapcount() is slower than page_mapcount().
*/ */
int page_trans_huge_mapcount(struct page *page, int *total_mapcount) int page_trans_huge_mapcount(struct page *page)
{ {
int i, ret, _total_mapcount, mapcount; int i, ret;
/* hugetlbfs shouldn't call it */ /* hugetlbfs shouldn't call it */
VM_BUG_ON_PAGE(PageHuge(page), page); VM_BUG_ON_PAGE(PageHuge(page), page);
if (likely(!PageTransCompound(page))) { if (likely(!PageTransCompound(page)))
mapcount = atomic_read(&page->_mapcount) + 1; return atomic_read(&page->_mapcount) + 1;
if (total_mapcount)
*total_mapcount = mapcount;
return mapcount;
}
page = compound_head(page); page = compound_head(page);
_total_mapcount = ret = 0; ret = 0;
for (i = 0; i < thp_nr_pages(page); i++) { for (i = 0; i < thp_nr_pages(page); i++) {
mapcount = atomic_read(&page[i]._mapcount) + 1; int mapcount = atomic_read(&page[i]._mapcount) + 1;
ret = max(ret, mapcount); ret = max(ret, mapcount);
_total_mapcount += mapcount;
} }
if (PageDoubleMap(page)) {
if (PageDoubleMap(page))
ret -= 1; ret -= 1;
_total_mapcount -= thp_nr_pages(page);
} return ret + compound_mapcount(page);
mapcount = compound_mapcount(page);
ret += mapcount;
_total_mapcount += mapcount;
if (total_mapcount)
*total_mapcount = _total_mapcount;
return ret;
} }
/* Racy check whether the huge page can be split */ /* Racy check whether the huge page can be split */
......
...@@ -1619,7 +1619,7 @@ static int page_trans_huge_map_swapcount(struct page *page, ...@@ -1619,7 +1619,7 @@ static int page_trans_huge_map_swapcount(struct page *page,
swapcount = page_swapcount(page); swapcount = page_swapcount(page);
if (total_swapcount) if (total_swapcount)
*total_swapcount = swapcount; *total_swapcount = swapcount;
return swapcount + page_trans_huge_mapcount(page, NULL); return swapcount + page_trans_huge_mapcount(page);
} }
page = compound_head(page); page = compound_head(page);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment