Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: convert do_swap_page() to use folio_free_swap()

Also convert should_try_to_free_swap() to use a folio. This removes a few
calls to compound_head().

Link: https://lkml.kernel.org/r/20220902194653.1739778-47-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Matthew Wilcox (Oracle) and committed by
Andrew Morton
a160e537 b4e6f66e

+8 -8
+8 -8
mm/memory.c
··· 3641 3641 return 0; 3642 3642 } 3643 3643 3644 - static inline bool should_try_to_free_swap(struct page *page, 3644 + static inline bool should_try_to_free_swap(struct folio *folio, 3645 3645 struct vm_area_struct *vma, 3646 3646 unsigned int fault_flags) 3647 3647 { 3648 - if (!PageSwapCache(page)) 3648 + if (!folio_test_swapcache(folio)) 3649 3649 return false; 3650 - if (mem_cgroup_swap_full(page) || (vma->vm_flags & VM_LOCKED) || 3651 - PageMlocked(page)) 3650 + if (mem_cgroup_swap_full(&folio->page) || (vma->vm_flags & VM_LOCKED) || 3651 + folio_test_mlocked(folio)) 3652 3652 return true; 3653 3653 /* 3654 3654 * If we want to map a page that's in the swapcache writable, we ··· 3656 3656 * user. Try freeing the swapcache to get rid of the swapcache 3657 3657 * reference only in case it's likely that we'll be the exlusive user. 3658 3658 */ 3659 - return (fault_flags & FAULT_FLAG_WRITE) && !PageKsm(page) && 3660 - page_count(page) == 2; 3659 + return (fault_flags & FAULT_FLAG_WRITE) && !folio_test_ksm(folio) && 3660 + folio_ref_count(folio) == 2; 3661 3661 } 3662 3662 3663 3663 static vm_fault_t pte_marker_clear(struct vm_fault *vmf) ··· 3949 3949 * yet. 3950 3950 */ 3951 3951 swap_free(entry); 3952 - if (should_try_to_free_swap(page, vma, vmf->flags)) 3953 - try_to_free_swap(page); 3952 + if (should_try_to_free_swap(folio, vma, vmf->flags)) 3953 + folio_free_swap(folio); 3954 3954 3955 3955 inc_mm_counter_fast(vma->vm_mm, MM_ANONPAGES); 3956 3956 dec_mm_counter_fast(vma->vm_mm, MM_SWAPENTS);