]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm: Add functions to support extra actions on swap in/out
authorKhalid Aziz <khalid.aziz@oracle.com>
Wed, 18 Jan 2017 17:36:21 +0000 (10:36 -0700)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 9 Mar 2017 03:30:13 +0000 (19:30 -0800)
If a processor supports special metadata for a page, for example ADI
version tags on SPARC M7, this metadata must be saved when the page is
swapped out. The same metadata must be restored when the page is swapped
back in. This patch adds two new architecture specific functions -
arch_do_swap_page() to be called when a page is swapped in,
arch_unmap_one() to be called when a page is being unmapped for swap
out.

This is a backport of patch sent upstream and brings UEK code in sync
with upstream patch v6.

Orabug: 22713162

Signed-off-by: Khalid Aziz <khalid.aziz@oracle.com>
Cc: Khalid Aziz <khalid@gonehiking.org>
include/asm-generic/pgtable.h
mm/memory.c
mm/rmap.c

index 39f1d6a2b04d4292f2dbd01b59bc748484824eff..e2e800b176ca578d079621e04cc8efb0f01b3d7d 100644 (file)
@@ -238,6 +238,22 @@ static inline int pmd_same(pmd_t pmd_a, pmd_t pmd_b)
 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
 #endif
 
+#ifndef __HAVE_ARCH_DO_SWAP_PAGE
+static inline void arch_do_swap_page(struct mm_struct *mm, unsigned long addr,
+                                    pte_t pte, pte_t orig_pte)
+{
+
+}
+#endif
+
+#ifndef __HAVE_ARCH_UNMAP_ONE
+static inline void arch_unmap_one(struct mm_struct *mm, unsigned long addr,
+                                 pte_t pte, pte_t orig_pte)
+{
+
+}
+#endif
+
 #ifndef __HAVE_ARCH_PGD_OFFSET_GATE
 #define pgd_offset_gate(mm, addr)      pgd_offset(mm, addr)
 #endif
index 22e037e3364e0f49dcdc1de812181f54755bbbac..88f773b9fbe7191d5881560c72ca6a2ada89116b 100644 (file)
@@ -2566,6 +2566,7 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
        if (pte_swp_soft_dirty(orig_pte))
                pte = pte_mksoft_dirty(pte);
        set_pte_at(mm, address, page_table, pte);
+       arch_do_swap_page(mm, address, pte, orig_pte);
        if (page == swapcache) {
                do_page_add_anon_rmap(page, vma, address, exclusive);
                mem_cgroup_commit_charge(page, memcg, true);
index 24dd3f9fee27dfe577c7f605bd0c260f0bc143c7..90a262714cb9150d4dbe6af592b51a6baa215244 100644 (file)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1273,14 +1273,17 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
                        entry = make_migration_entry(page, pte_write(pteval));
                }
                swp_pte = swp_entry_to_pte(entry);
+               arch_unmap_one(mm, address, swp_pte, pteval);
                if (pte_soft_dirty(pteval))
                        swp_pte = pte_swp_mksoft_dirty(swp_pte);
+               arch_unmap_one(mm, address, swp_pte, pteval);
                set_pte_at(mm, address, pte, swp_pte);
        } else if (IS_ENABLED(CONFIG_MIGRATION) &&
                   (flags & TTU_MIGRATION)) {
                /* Establish migration entry for a file page */
                swp_entry_t entry;
                entry = make_migration_entry(page, pte_write(pteval));
+               arch_unmap_one(mm, address, swp_entry_to_pte(entry), pteval);
                set_pte_at(mm, address, pte, swp_entry_to_pte(entry));
        } else
                dec_mm_counter(mm, MM_FILEPAGES);