Skip to content

Commit 363106c

Browse files
davidhildenbrandtorvalds
authored andcommitted
mm/khugepaged: remove reuse_swap_page() usage
reuse_swap_page() currently indicates if we can write to an anon page without COW. A COW is required if the page is shared by multiple processes (either already mapped or via swap entries) or if there is concurrent writeback that cannot tolerate concurrent page modifications. However, in the context of khugepaged we're not actually going to write to a read-only mapped page, we'll copy the page content to our newly allocated THP and map that THP writable. All we have to make sure is that the read-only mapped page we're about to copy won't get reused by another process sharing the page, otherwise, page content would get modified. But that is already guaranteed via multiple mechanisms (e.g., holding a reference, holding the page lock, removing the rmap after copying the page). The swapcache handling was introduced in commit 1035921 ("mm: incorporate read-only pages into transparent huge pages") and it sounds like it merely wanted to mimic what do_swap_page() would do when trying to map a page obtained via the swapcache writable. As that logic is unnecessary, let's just remove it, removing the last user of reuse_swap_page(). Link: https://lkml.kernel.org/r/20220131162940.210846-7-david@redhat.com Signed-off-by: David Hildenbrand <david@redhat.com> Reviewed-by: Yang Shi <shy828301@gmail.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> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 3bff7e3 commit 363106c

2 files changed

Lines changed: 0 additions & 12 deletions

File tree

include/trace/events/huge_memory.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
EM( SCAN_VMA_NULL, "vma_null") \
3030
EM( SCAN_VMA_CHECK, "vma_check_failed") \
3131
EM( SCAN_ADDRESS_RANGE, "not_suitable_address_range") \
32-
EM( SCAN_SWAP_CACHE_PAGE, "page_swap_cache") \
3332
EM( SCAN_DEL_PAGE_LRU, "could_not_delete_page_from_lru")\
3433
EM( SCAN_ALLOC_HUGE_PAGE_FAIL, "alloc_huge_page_failed") \
3534
EM( SCAN_CGROUP_CHARGE_FAIL, "ccgroup_charge_failed") \

mm/khugepaged.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ enum scan_result {
4646
SCAN_VMA_NULL,
4747
SCAN_VMA_CHECK,
4848
SCAN_ADDRESS_RANGE,
49-
SCAN_SWAP_CACHE_PAGE,
5049
SCAN_DEL_PAGE_LRU,
5150
SCAN_ALLOC_HUGE_PAGE_FAIL,
5251
SCAN_CGROUP_CHARGE_FAIL,
@@ -683,16 +682,6 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma,
683682
result = SCAN_PAGE_COUNT;
684683
goto out;
685684
}
686-
if (!pte_write(pteval) && PageSwapCache(page) &&
687-
!reuse_swap_page(page)) {
688-
/*
689-
* Page is in the swap cache and cannot be re-used.
690-
* It cannot be collapsed into a THP.
691-
*/
692-
unlock_page(page);
693-
result = SCAN_SWAP_CACHE_PAGE;
694-
goto out;
695-
}
696685

697686
/*
698687
* Isolate the page to avoid collapsing an hugepage

0 commit comments

Comments
 (0)