Skip to content

Commit 66c7f7a

Browse files
Matthew Wilcox (Oracle)torvalds
Matthew Wilcox (Oracle)
authored andcommitted
mm: remove the total_mapcount argument from page_trans_huge_map_swapcount()
Now that we don't report it to the caller of reuse_swap_page(), we don't need to request it from page_trans_huge_map_swapcount(). 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 020e876 commit 66c7f7a

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

mm/swapfile.c

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,31 +1601,30 @@ static bool page_swapped(struct page *page)
16011601
return false;
16021602
}
16031603

1604-
static int page_trans_huge_map_swapcount(struct page *page, int *total_mapcount,
1604+
static int page_trans_huge_map_swapcount(struct page *page,
16051605
int *total_swapcount)
16061606
{
1607-
int i, map_swapcount, _total_mapcount, _total_swapcount;
1607+
int i, map_swapcount, _total_swapcount;
16081608
unsigned long offset = 0;
16091609
struct swap_info_struct *si;
16101610
struct swap_cluster_info *ci = NULL;
16111611
unsigned char *map = NULL;
1612-
int mapcount, swapcount = 0;
1612+
int swapcount = 0;
16131613

16141614
/* hugetlbfs shouldn't call it */
16151615
VM_BUG_ON_PAGE(PageHuge(page), page);
16161616

16171617
if (!IS_ENABLED(CONFIG_THP_SWAP) || likely(!PageTransCompound(page))) {
1618-
mapcount = page_trans_huge_mapcount(page, total_mapcount);
16191618
if (PageSwapCache(page))
16201619
swapcount = page_swapcount(page);
16211620
if (total_swapcount)
16221621
*total_swapcount = swapcount;
1623-
return mapcount + swapcount;
1622+
return swapcount + page_trans_huge_mapcount(page, NULL);
16241623
}
16251624

16261625
page = compound_head(page);
16271626

1628-
_total_mapcount = _total_swapcount = map_swapcount = 0;
1627+
_total_swapcount = map_swapcount = 0;
16291628
if (PageSwapCache(page)) {
16301629
swp_entry_t entry;
16311630

@@ -1639,28 +1638,22 @@ static int page_trans_huge_map_swapcount(struct page *page, int *total_mapcount,
16391638
if (map)
16401639
ci = lock_cluster(si, offset);
16411640
for (i = 0; i < HPAGE_PMD_NR; i++) {
1642-
mapcount = atomic_read(&page[i]._mapcount) + 1;
1643-
_total_mapcount += mapcount;
1641+
int mapcount = atomic_read(&page[i]._mapcount) + 1;
16441642
if (map) {
16451643
swapcount = swap_count(map[offset + i]);
16461644
_total_swapcount += swapcount;
16471645
}
16481646
map_swapcount = max(map_swapcount, mapcount + swapcount);
16491647
}
16501648
unlock_cluster(ci);
1651-
if (PageDoubleMap(page)) {
1649+
1650+
if (PageDoubleMap(page))
16521651
map_swapcount -= 1;
1653-
_total_mapcount -= HPAGE_PMD_NR;
1654-
}
1655-
mapcount = compound_mapcount(page);
1656-
map_swapcount += mapcount;
1657-
_total_mapcount += mapcount;
1658-
if (total_mapcount)
1659-
*total_mapcount = _total_mapcount;
1652+
16601653
if (total_swapcount)
16611654
*total_swapcount = _total_swapcount;
16621655

1663-
return map_swapcount;
1656+
return map_swapcount + compound_mapcount(page);
16641657
}
16651658

16661659
/*
@@ -1671,13 +1664,12 @@ static int page_trans_huge_map_swapcount(struct page *page, int *total_mapcount,
16711664
*/
16721665
bool reuse_swap_page(struct page *page)
16731666
{
1674-
int count, total_mapcount, total_swapcount;
1667+
int count, total_swapcount;
16751668

16761669
VM_BUG_ON_PAGE(!PageLocked(page), page);
16771670
if (unlikely(PageKsm(page)))
16781671
return false;
1679-
count = page_trans_huge_map_swapcount(page, &total_mapcount,
1680-
&total_swapcount);
1672+
count = page_trans_huge_map_swapcount(page, &total_swapcount);
16811673
if (count == 1 && PageSwapCache(page) &&
16821674
(likely(!PageTransCompound(page)) ||
16831675
/* The remaining swap count will be freed soon */

0 commit comments

Comments
 (0)