Skip to content

Commit 03104c2

Browse files
davidhildenbrandtorvalds
authored andcommitted
mm/swapfile: remove stale reuse_swap_page()
All users are gone, let's remove it. We'll let SWP_STABLE_WRITES stick around for now, as it might come in handy in the near future. Link: https://lkml.kernel.org/r/20220131162940.210846-8-david@redhat.com Signed-off-by: David Hildenbrand <david@redhat.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Cc: David Rientjes <rientjes@google.com> Cc: Don Dutile <ddutile@redhat.com> Cc: Hugh Dickins <hughd@google.com> Cc: Jan Kara <jack@suse.cz> Cc: Jann Horn <jannh@google.com> Cc: Jason Gunthorpe <jgg@nvidia.com> Cc: John Hubbard <jhubbard@nvidia.com> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Liang Zhang <zhangliang5@huawei.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Michal Hocko <mhocko@kernel.org> Cc: Mike Kravetz <mike.kravetz@oracle.com> Cc: Mike Rapoport <rppt@linux.ibm.com> Cc: Nadav Amit <nadav.amit@gmail.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Peter Xu <peterx@redhat.com> Cc: Rik van Riel <riel@surriel.com> Cc: Roman Gushchin <roman.gushchin@linux.dev> Cc: Shakeel Butt <shakeelb@google.com> Cc: Yang Shi <shy828301@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 363106c commit 03104c2

2 files changed

Lines changed: 0 additions & 108 deletions

File tree

include/linux/swap.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,6 @@ extern int __swp_swapcount(swp_entry_t entry);
515515
extern int swp_swapcount(swp_entry_t entry);
516516
extern struct swap_info_struct *page_swap_info(struct page *);
517517
extern struct swap_info_struct *swp_swap_info(swp_entry_t entry);
518-
extern bool reuse_swap_page(struct page *);
519518
extern int try_to_free_swap(struct page *);
520519
struct backing_dev_info;
521520
extern int init_swap_address_space(unsigned int type, unsigned long nr_pages);
@@ -681,9 +680,6 @@ static inline int swp_swapcount(swp_entry_t entry)
681680
return 0;
682681
}
683682

684-
#define reuse_swap_page(page) \
685-
(page_trans_huge_mapcount(page) == 1)
686-
687683
static inline int try_to_free_swap(struct page *page)
688684
{
689685
return 0;

mm/swapfile.c

Lines changed: 0 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,16 +1167,6 @@ static struct swap_info_struct *_swap_info_get(swp_entry_t entry)
11671167
return NULL;
11681168
}
11691169

1170-
static struct swap_info_struct *swap_info_get(swp_entry_t entry)
1171-
{
1172-
struct swap_info_struct *p;
1173-
1174-
p = _swap_info_get(entry);
1175-
if (p)
1176-
spin_lock(&p->lock);
1177-
return p;
1178-
}
1179-
11801170
static struct swap_info_struct *swap_info_get_cont(swp_entry_t entry,
11811171
struct swap_info_struct *q)
11821172
{
@@ -1601,100 +1591,6 @@ static bool page_swapped(struct page *page)
16011591
return false;
16021592
}
16031593

1604-
static int page_trans_huge_map_swapcount(struct page *page,
1605-
int *total_swapcount)
1606-
{
1607-
int i, map_swapcount, _total_swapcount;
1608-
unsigned long offset = 0;
1609-
struct swap_info_struct *si;
1610-
struct swap_cluster_info *ci = NULL;
1611-
unsigned char *map = NULL;
1612-
int swapcount = 0;
1613-
1614-
/* hugetlbfs shouldn't call it */
1615-
VM_BUG_ON_PAGE(PageHuge(page), page);
1616-
1617-
if (!IS_ENABLED(CONFIG_THP_SWAP) || likely(!PageTransCompound(page))) {
1618-
if (PageSwapCache(page))
1619-
swapcount = page_swapcount(page);
1620-
if (total_swapcount)
1621-
*total_swapcount = swapcount;
1622-
return swapcount + page_trans_huge_mapcount(page);
1623-
}
1624-
1625-
page = compound_head(page);
1626-
1627-
_total_swapcount = map_swapcount = 0;
1628-
if (PageSwapCache(page)) {
1629-
swp_entry_t entry;
1630-
1631-
entry.val = page_private(page);
1632-
si = _swap_info_get(entry);
1633-
if (si) {
1634-
map = si->swap_map;
1635-
offset = swp_offset(entry);
1636-
}
1637-
}
1638-
if (map)
1639-
ci = lock_cluster(si, offset);
1640-
for (i = 0; i < HPAGE_PMD_NR; i++) {
1641-
int mapcount = atomic_read(&page[i]._mapcount) + 1;
1642-
if (map) {
1643-
swapcount = swap_count(map[offset + i]);
1644-
_total_swapcount += swapcount;
1645-
}
1646-
map_swapcount = max(map_swapcount, mapcount + swapcount);
1647-
}
1648-
unlock_cluster(ci);
1649-
1650-
if (PageDoubleMap(page))
1651-
map_swapcount -= 1;
1652-
1653-
if (total_swapcount)
1654-
*total_swapcount = _total_swapcount;
1655-
1656-
return map_swapcount + compound_mapcount(page);
1657-
}
1658-
1659-
/*
1660-
* We can write to an anon page without COW if there are no other references
1661-
* to it. And as a side-effect, free up its swap: because the old content
1662-
* on disk will never be read, and seeking back there to write new content
1663-
* later would only waste time away from clustering.
1664-
*/
1665-
bool reuse_swap_page(struct page *page)
1666-
{
1667-
int count, total_swapcount;
1668-
1669-
VM_BUG_ON_PAGE(!PageLocked(page), page);
1670-
if (unlikely(PageKsm(page)))
1671-
return false;
1672-
count = page_trans_huge_map_swapcount(page, &total_swapcount);
1673-
if (count == 1 && PageSwapCache(page) &&
1674-
(likely(!PageTransCompound(page)) ||
1675-
/* The remaining swap count will be freed soon */
1676-
total_swapcount == page_swapcount(page))) {
1677-
if (!PageWriteback(page)) {
1678-
page = compound_head(page);
1679-
delete_from_swap_cache(page);
1680-
SetPageDirty(page);
1681-
} else {
1682-
swp_entry_t entry;
1683-
struct swap_info_struct *p;
1684-
1685-
entry.val = page_private(page);
1686-
p = swap_info_get(entry);
1687-
if (p->flags & SWP_STABLE_WRITES) {
1688-
spin_unlock(&p->lock);
1689-
return false;
1690-
}
1691-
spin_unlock(&p->lock);
1692-
}
1693-
}
1694-
1695-
return count <= 1;
1696-
}
1697-
16981594
/*
16991595
* If swap is getting full, or if there are no more mappings of this page,
17001596
* then try_to_free_swap is called to free its swap space.

0 commit comments

Comments
 (0)