mm: introduce page_vma_mapped_walk()
Subsystems (3)
[email protected]
maintainerPATCH 44/124 mm: introduce page_vma_mapped_walk()
From: "Kirill A. Shutemov" <[email protected]>
Subject: mm: introduce page_vma_mapped_walk()
Introduce a new interface to check if a page is mapped into a vma. It aims to address shortcomings of page_check_address{,_transhuge}.
Existing interface is not able to handle PTE-mapped THPs: it only finds the first PTE. The rest lefted unnoticed.
page_vma_mapped_walk() iterates over all possible mapping of the page in the vma.
Signed-off-by Kirill A. Shutemov <[email protected]>
Cc Andrea Arcangeli <[email protected]>
Cc Hillf Danton <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Oleg Nesterov <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Srikar Dronamraju <[email protected]>
Cc Vladimir Davydov <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
include/linux/rmap.h | 26 +++++ mm/Makefile | 6 - mm/huge_memory.c | 9 + mm/page_vma_mapped.c | 188 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 224 insertions(+), 5 deletions(-)
include/linux/rmap.h renamed from include/linux/rmap.h~mm-introduce-page_vma_mapped_walk +26 -0
@@ -9,6 +9,7 @@#include <linux/mm.h> #include <linux/rwsem.h> #include <linux/memcontrol.h> +#include <linux/highmem.h> /* * The anon_vma heads a list of private "related" vmas, to scan if
@@ -232,6 +233,31 @@ static inline bool page_check_address_tr }#endif +/* Avoid racy checks */ +#define PVMW_SYNC (1 << 0) +/* Look for migarion entries rather than present PTEs */ +#define PVMW_MIGRATION (1 << 1) + +struct page_vma_mapped_walk { +struct page *page; +struct vm_area_struct *vma; +unsigned long address; +pmd_t *pmd; +pte_t *pte; +spinlock_t *ptl; +unsigned int flags; +}; + +static inline void page_vma_mapped_walk_done (struct page_vma_mapped_walk *pvmw) +{ +if (pvmw->pte) +pte_unmap (pvmw->pte); +if (pvmw->ptl) +spin_unlock (pvmw->ptl); +} + +bool page_vma_mapped_walk (struct page_vma_mapped_walk *pvmw); +/* * Used by swapoff to help locate where page is expected in vma. */
mm/Makefile renamed from mm/Makefile~mm-introduce-page_vma_mapped_walk +4 -2
@@ -23,8 +23,10 @@ KCOV_INSTRUMENT_vmstat.o := n mmu-y := nommu.o mmu-$(CONFIG_MMU) := gup.o highmem.o memory.o mincore.o \ - mlock.o mmap.o mprotect.o mremap.o msync.o rmap.o \ - vmalloc.o pagewalk.o pgtable-generic.o + mlock.o mmap.o mprotect.o mremap.o msync.o \ + page_vma_mapped.o pagewalk.o pgtable-generic.o \ + rmap.o vmalloc.o + ifdef CONFIG_CROSS_MEMORY_ATTACH mmu-$(CONFIG_MMU) += process_vm_access.o
mm/huge_memory.c renamed from mm/huge_memory.c~mm-introduce-page_vma_mapped_walk +6 -3
@@ -2129,9 +2129,12 @@ static void freeze_page(struct page *pagstatic void unfreeze_page (struct page *page) {int i; - -for (i =0 ; i <HPAGE_PMD_NR ; i++) -remove_migration_ptes (page + i, page + i, true); +if (PageTransHuge (page)) { +remove_migration_ptes (page, page, true); + }else { +for (i =0 ; i <HPAGE_PMD_NR ; i++) +remove_migration_ptes (page + i, page + i, true); + } } static void __split_huge_page_tail(struct page *head, int tail,
mm/page_vma_mapped.c new file +188 -0
188 lines not on this page · raw message
_