mm: thp: enable thp migration in generic path
[sfrench/cifs-2.6.git] / mm / rmap.c
index c570f82e6827153316465b9e18f0fca376a1c1a1..7dc9c02f710693232bd1739667381e1c062b2c13 100644 (file)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1348,7 +1348,7 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
 
        if (flags & TTU_SPLIT_HUGE_PMD) {
                split_huge_pmd_address(vma, address,
-                               flags & TTU_MIGRATION, page);
+                               flags & TTU_SPLIT_FREEZE, page);
        }
 
        /*
@@ -1360,6 +1360,19 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
        mmu_notifier_invalidate_range_start(vma->vm_mm, start, end);
 
        while (page_vma_mapped_walk(&pvmw)) {
+#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION
+               /* PMD-mapped THP migration entry */
+               if (!pvmw.pte && (flags & TTU_MIGRATION)) {
+                       VM_BUG_ON_PAGE(PageHuge(page) || !PageTransCompound(page), page);
+
+                       if (!PageAnon(page))
+                               continue;
+
+                       set_pmd_migration_entry(&pvmw, page);
+                       continue;
+               }
+#endif
+
                /*
                 * If the page is mlock()d, we cannot swap it out.
                 * If it's recently referenced (perhaps page_referenced
@@ -1445,7 +1458,7 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
                         */
                        dec_mm_counter(mm, mm_counter(page));
                } else if (IS_ENABLED(CONFIG_MIGRATION) &&
-                               (flags & TTU_MIGRATION)) {
+                               (flags & (TTU_MIGRATION|TTU_SPLIT_FREEZE))) {
                        swp_entry_t entry;
                        pte_t swp_pte;
                        /*
@@ -1575,7 +1588,8 @@ bool try_to_unmap(struct page *page, enum ttu_flags flags)
         * locking requirements of exec(), migration skips
         * temporary VMAs until after exec() completes.
         */
-       if ((flags & TTU_MIGRATION) && !PageKsm(page) && PageAnon(page))
+       if ((flags & (TTU_MIGRATION|TTU_SPLIT_FREEZE))
+           && !PageKsm(page) && PageAnon(page))
                rwc.invalid_vma = invalid_migration_vma;
 
        if (flags & TTU_RMAP_LOCKED)