mm-thp-swap-make-reuse_swap_page-works-for-thp-swapped-out.patch removed from -mm tree
The patch titled
Subject: mm, THP, swap: make reuse_swap_page() works for THP swapped out
has been removed from the -mm tree. Its filename was
mm-thp-swap-make-reuse_swap_page-works-for-thp-swapped-out.patch
This patch was dropped because it was merged into mainline or a subsystem tree
------------------------------------------------------
From: Huang Ying <[email protected]>
Subject: mm, THP, swap: make reuse_swap_page() works for THP swapped out
After supporting to delay THP (Transparent Huge Page) splitting after swapped out, it is possible that some page table mappings of the THP are turned into swap entries. So reuse_swap_page() need to check the swap count in addition to the map count as before. This patch done that.
In the huge PMD write protect fault handler, in addition to the page map count, the swap count need to be checked too, so the page lock need to be acquired too when calling reuse_swap_page() in addition to the page table lock.
---
include/linux/swap.h | 4 - mm/huge_memory.c | 16 ++++++ mm/memory.c | 6 +- mm/swapfile.c | 102 +++++++++++++++++++++++++++++++++++++---- 4 files changed, 113 insertions(+), 15 deletions(-)
include/linux/swap.h renamed from include/linux/swap.h~mm-thp-swap-make-reuse_swap_page-works-for-thp-swapped-out +2 -2
@@ -510,8 +510,8 @@ static inline int swp_swapcount(swp_entrreturn 0 ; } -#define reuse_swap_page (page, total_mapcount) \ - (page_trans_huge_mapcount(page, total_mapcount) == 1) +#define reuse_swap_page (page, total_map_swapcount) \ + (page_trans_huge_mapcount(page, total_map_swapcount) == 1)static inline int try_to_free_swap (struct page *page) {
mm/huge_memory.c renamed from mm/huge_memory.c~mm-thp-swap-make-reuse_swap_page-works-for-thp-swapped-out +15 -1
@@ -1240,15 +1240,29 @@ int do_huge_pmd_wp_page(struct vm_fault* We can only reuse the page if nobody else maps the huge page or it's * part. */ -if (page_trans_huge_mapcount (page,NULL ) ==1 ) { +if (!trylock_page (page)) { +get_page (page); +spin_unlock (vmf->ptl); +lock_page (page); +spin_lock (vmf->ptl); +if (unlikely (!pmd_same (*vmf->pmd, orig_pmd))) { +unlock_page (page); +put_page (page); + goto out_unlock; + } +put_page (page); + } +if (reuse_swap_page (page,NULL )) {pmd_t entry; entry =pmd_mkyoung (orig_pmd); entry =maybe_pmd_mkwrite (pmd_mkdirty (entry), vma);if (pmdp_set_access_flags (vma, haddr, vmf->pmd, entry,1 ))update_mmu_cache_pmd (vma, vmf->address, vmf->pmd); ret |=VM_FAULT_WRITE ; +unlock_page (page); goto out_unlock; } +unlock_page (page);get_page (page);spin_unlock (vmf->ptl); alloc:
mm/memory.c renamed from mm/memory.c~mm-thp-swap-make-reuse_swap_page-works-for-thp-swapped-out +3 -3
@@ -2619,7 +2619,7 @@ static int do_wp_page(struct vm_fault *v* not dirty accountable. */ if (PageAnon (vmf->page) && !PageKsm (vmf->page)) { -int total_mapcount; +int total_map_swapcount;if (!trylock_page (vmf->page)) {get_page (vmf->page);pte_unmap_unlock (vmf->pte, vmf->ptl);
@@ -2634,8 +2634,8 @@ static int do_wp_page(struct vm_fault *v }put_page (vmf->page); } -if (reuse_swap_page (vmf->page, &total_mapcount)) { -if (total_mapcount ==1 ) { +if (reuse_swap_page (vmf->page, &total_map_swapcount)) { +if (total_map_swapcount ==1 ) {/* * The page is all ours. Move it to * our anon_vma so the rmap code will
mm/swapfile.c renamed from mm/swapfile.c~mm-thp-swap-make-reuse_swap_page-works-for-thp-swapped-out +93 -9
132 lines not on this page · raw message
_
Patches currently in -mm which might be from [email protected] are