From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751748AbdB1Sk6 (ORCPT ); Tue, 28 Feb 2017 13:40:58 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:26852 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751373AbdB1Sk5 (ORCPT ); Tue, 28 Feb 2017 13:40:57 -0500 From: Khalid Aziz To: akpm@linux-foundation.org, davem@davemloft.net, arnd@arndb.de Cc: Khalid Aziz , kirill.shutemov@linux.intel.com, mhocko@suse.com, jmarchan@redhat.com, vbabka@suse.cz, dan.j.williams@intel.com, lstoakes@gmail.com, dave.hansen@linux.intel.com, hannes@cmpxchg.org, mgorman@suse.de, hughd@google.com, vdavydov.dev@gmail.com, minchan@kernel.org, namit@vmware.com, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, sparclinux@vger.kernel.org, Khalid Aziz Subject: [PATCH v6 2/4] mm: Add functions to support extra actions on swap in/out Date: Tue, 28 Feb 2017 11:35:21 -0700 Message-Id: <4c4da87ff45b98e236cdfef66055b876074dabfb.1488232597.git.khalid.aziz@oracle.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Khalid Aziz Cc: Khalid Aziz --- v5: - Replaced set_swp_pte() function with new architecture functions arch_do_swap_page() and arch_unmap_one() include/asm-generic/pgtable.h | 16 ++++++++++++++++ mm/memory.c | 1 + mm/rmap.c | 2 ++ 3 files changed, 19 insertions(+) diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h index 18af2bc..5764d8f 100644 --- a/include/asm-generic/pgtable.h +++ b/include/asm-generic/pgtable.h @@ -282,6 +282,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 6bf2b47..b086c76 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2658,6 +2658,7 @@ int do_swap_page(struct vm_fault *vmf) if (pte_swp_soft_dirty(vmf->orig_pte)) pte = pte_mksoft_dirty(pte); set_pte_at(vma->vm_mm, vmf->address, vmf->pte, pte); + arch_do_swap_page(vma->vm_mm, vmf->address, pte, vmf->orig_pte); vmf->orig_pte = pte; if (page == swapcache) { do_page_add_anon_rmap(page, vma, vmf->address, exclusive); diff --git a/mm/rmap.c b/mm/rmap.c index 91619fd..192c41a 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1538,6 +1538,7 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma, swp_pte = swp_entry_to_pte(entry); 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 (PageAnon(page)) { swp_entry_t entry = { .val = page_private(page) }; @@ -1571,6 +1572,7 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma, swp_pte = swp_entry_to_pte(entry); 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 dec_mm_counter(mm, mm_counter_file(page)); -- 2.7.4