Skip to content

Commit d08d2b6

Browse files
Matthew Wilcox (Oracle)torvalds
Matthew Wilcox (Oracle)
authored andcommitted
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/[email protected] Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Reviewed-by: William Kucharski <[email protected]> Acked-by: Linus Torvalds <[email protected]> Cc: David Hildenbrand <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 66c7f7a commit d08d2b6

File tree

4 files changed

+15
-29
lines changed

4 files changed

+15
-29
lines changed

include/linux/mm.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -799,19 +799,15 @@ static inline int page_mapcount(struct page *page)
799799

800800
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
801801
int total_mapcount(struct page *page);
802-
int page_trans_huge_mapcount(struct page *page, int *total_mapcount);
802+
int page_trans_huge_mapcount(struct page *page);
803803
#else
804804
static inline int total_mapcount(struct page *page)
805805
{
806806
return page_mapcount(page);
807807
}
808-
static inline int page_trans_huge_mapcount(struct page *page,
809-
int *total_mapcount)
808+
static inline int page_trans_huge_mapcount(struct page *page)
810809
{
811-
int mapcount = page_mapcount(page);
812-
if (total_mapcount)
813-
*total_mapcount = mapcount;
814-
return mapcount;
810+
return page_mapcount(page);
815811
}
816812
#endif
817813

include/linux/swap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ static inline int swp_swapcount(swp_entry_t entry)
681681
}
682682

683683
#define reuse_swap_page(page) \
684-
(page_trans_huge_mapcount(page, NULL) == 1)
684+
(page_trans_huge_mapcount(page) == 1)
685685

686686
static inline int try_to_free_swap(struct page *page)
687687
{

mm/huge_memory.c

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2542,38 +2542,28 @@ int total_mapcount(struct page *page)
25422542
* need full accuracy to avoid breaking page pinning, because
25432543
* page_trans_huge_mapcount() is slower than page_mapcount().
25442544
*/
2545-
int page_trans_huge_mapcount(struct page *page, int *total_mapcount)
2545+
int page_trans_huge_mapcount(struct page *page)
25462546
{
2547-
int i, ret, _total_mapcount, mapcount;
2547+
int i, ret;
25482548

25492549
/* hugetlbfs shouldn't call it */
25502550
VM_BUG_ON_PAGE(PageHuge(page), page);
25512551

2552-
if (likely(!PageTransCompound(page))) {
2553-
mapcount = atomic_read(&page->_mapcount) + 1;
2554-
if (total_mapcount)
2555-
*total_mapcount = mapcount;
2556-
return mapcount;
2557-
}
2552+
if (likely(!PageTransCompound(page)))
2553+
return atomic_read(&page->_mapcount) + 1;
25582554

25592555
page = compound_head(page);
25602556

2561-
_total_mapcount = ret = 0;
2557+
ret = 0;
25622558
for (i = 0; i < thp_nr_pages(page); i++) {
2563-
mapcount = atomic_read(&page[i]._mapcount) + 1;
2559+
int mapcount = atomic_read(&page[i]._mapcount) + 1;
25642560
ret = max(ret, mapcount);
2565-
_total_mapcount += mapcount;
25662561
}
2567-
if (PageDoubleMap(page)) {
2562+
2563+
if (PageDoubleMap(page))
25682564
ret -= 1;
2569-
_total_mapcount -= thp_nr_pages(page);
2570-
}
2571-
mapcount = compound_mapcount(page);
2572-
ret += mapcount;
2573-
_total_mapcount += mapcount;
2574-
if (total_mapcount)
2575-
*total_mapcount = _total_mapcount;
2576-
return ret;
2565+
2566+
return ret + compound_mapcount(page);
25772567
}
25782568

25792569
/* Racy check whether the huge page can be split */

mm/swapfile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,7 @@ static int page_trans_huge_map_swapcount(struct page *page,
16191619
swapcount = page_swapcount(page);
16201620
if (total_swapcount)
16211621
*total_swapcount = swapcount;
1622-
return swapcount + page_trans_huge_mapcount(page, NULL);
1622+
return swapcount + page_trans_huge_mapcount(page);
16231623
}
16241624

16251625
page = compound_head(page);

0 commit comments

Comments
 (0)