From: Khalid Aziz Date: Wed, 18 Jan 2017 17:36:21 +0000 (-0700) Subject: mm: Add functions to support extra actions on swap in/out X-Git-Tag: v4.1.12-92~1^2~8 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a957b34219130e5b0669d74bb17ee23f8649291c;p=users%2Fjedix%2Flinux-maple.git mm: Add functions to support extra actions on swap in/out 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 Cc: Khalid Aziz --- diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h index 39f1d6a2b04d4..e2e800b176ca5 100644 --- a/include/asm-generic/pgtable.h +++ b/include/asm-generic/pgtable.h @@ -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 diff --git a/mm/memory.c b/mm/memory.c index 22e037e3364e0..88f773b9fbe71 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -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); diff --git a/mm/rmap.c b/mm/rmap.c index 24dd3f9fee27d..90a262714cb91 100644 --- 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);