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>
This commit is contained in:
parent
b4e6f66e45
commit
a160e5377b
16
mm/memory.c
16
mm/memory.c
@ -3641,14 +3641,14 @@ static vm_fault_t remove_device_exclusive_entry(struct vm_fault *vmf)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool should_try_to_free_swap(struct page *page,
|
static inline bool should_try_to_free_swap(struct folio *folio,
|
||||||
struct vm_area_struct *vma,
|
struct vm_area_struct *vma,
|
||||||
unsigned int fault_flags)
|
unsigned int fault_flags)
|
||||||
{
|
{
|
||||||
if (!PageSwapCache(page))
|
if (!folio_test_swapcache(folio))
|
||||||
return false;
|
return false;
|
||||||
if (mem_cgroup_swap_full(page) || (vma->vm_flags & VM_LOCKED) ||
|
if (mem_cgroup_swap_full(&folio->page) || (vma->vm_flags & VM_LOCKED) ||
|
||||||
PageMlocked(page))
|
folio_test_mlocked(folio))
|
||||||
return true;
|
return true;
|
||||||
/*
|
/*
|
||||||
* If we want to map a page that's in the swapcache writable, we
|
* If we want to map a page that's in the swapcache writable, we
|
||||||
@ -3656,8 +3656,8 @@ static inline bool should_try_to_free_swap(struct page *page,
|
|||||||
* user. Try freeing the swapcache to get rid of the swapcache
|
* user. Try freeing the swapcache to get rid of the swapcache
|
||||||
* reference only in case it's likely that we'll be the exlusive user.
|
* reference only in case it's likely that we'll be the exlusive user.
|
||||||
*/
|
*/
|
||||||
return (fault_flags & FAULT_FLAG_WRITE) && !PageKsm(page) &&
|
return (fault_flags & FAULT_FLAG_WRITE) && !folio_test_ksm(folio) &&
|
||||||
page_count(page) == 2;
|
folio_ref_count(folio) == 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static vm_fault_t pte_marker_clear(struct vm_fault *vmf)
|
static vm_fault_t pte_marker_clear(struct vm_fault *vmf)
|
||||||
@ -3949,8 +3949,8 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
|
|||||||
* yet.
|
* yet.
|
||||||
*/
|
*/
|
||||||
swap_free(entry);
|
swap_free(entry);
|
||||||
if (should_try_to_free_swap(page, vma, vmf->flags))
|
if (should_try_to_free_swap(folio, vma, vmf->flags))
|
||||||
try_to_free_swap(page);
|
folio_free_swap(folio);
|
||||||
|
|
||||||
inc_mm_counter_fast(vma->vm_mm, MM_ANONPAGES);
|
inc_mm_counter_fast(vma->vm_mm, MM_ANONPAGES);
|
||||||
dec_mm_counter_fast(vma->vm_mm, MM_SWAPENTS);
|
dec_mm_counter_fast(vma->vm_mm, MM_SWAPENTS);
|
||||||
|
Loading…
Reference in New Issue
Block a user