Commit 34290e2c authored by Ralph Campbell's avatar Ralph Campbell Committed by Linus Torvalds

mm/migrate: add stable check in migrate_vma_insert_page()

migrate_vma_insert_page() closely follows the code in:
  __handle_mm_fault()
    handle_pte_fault()
      do_anonymous_page()

Add a call to check_stable_address_space() after locking the page table
entry before inserting a ZONE_DEVICE private zero page mapping similar
to page faulting a new anonymous page.

Link: http://lkml.kernel.org/r/20200107211208.24595-4-rcampbell@nvidia.comSigned-off-by: default avatarRalph Campbell <rcampbell@nvidia.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Cc: Jerome Glisse <jglisse@redhat.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Jason Gunthorpe <jgg@mellanox.com>
Cc: Bharata B Rao <bharata@linux.ibm.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Chris Down <chris@chrisdown.name>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c23a0c99
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include <linux/page_owner.h> #include <linux/page_owner.h>
#include <linux/sched/mm.h> #include <linux/sched/mm.h>
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/oom.h>
#include <asm/tlbflush.h> #include <asm/tlbflush.h>
...@@ -2695,6 +2696,14 @@ int migrate_vma_setup(struct migrate_vma *args) ...@@ -2695,6 +2696,14 @@ int migrate_vma_setup(struct migrate_vma *args)
} }
EXPORT_SYMBOL(migrate_vma_setup); EXPORT_SYMBOL(migrate_vma_setup);
/*
* This code closely matches the code in:
* __handle_mm_fault()
* handle_pte_fault()
* do_anonymous_page()
* to map in an anonymous zero page but the struct page will be a ZONE_DEVICE
* private page.
*/
static void migrate_vma_insert_page(struct migrate_vma *migrate, static void migrate_vma_insert_page(struct migrate_vma *migrate,
unsigned long addr, unsigned long addr,
struct page *page, struct page *page,
...@@ -2775,6 +2784,9 @@ static void migrate_vma_insert_page(struct migrate_vma *migrate, ...@@ -2775,6 +2784,9 @@ static void migrate_vma_insert_page(struct migrate_vma *migrate,
ptep = pte_offset_map_lock(mm, pmdp, addr, &ptl); ptep = pte_offset_map_lock(mm, pmdp, addr, &ptl);
if (check_stable_address_space(mm))
goto unlock_abort;
if (pte_present(*ptep)) { if (pte_present(*ptep)) {
unsigned long pfn = pte_pfn(*ptep); unsigned long pfn = pte_pfn(*ptep);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment