The patch titled Subject: mm/migrate: add stable check in migrate_vma_insert_page() has been added to the -mm tree. Its filename is mm-migrate-add-stable-check-in-migrate_vma_insert_page.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-migrate-add-stable-check-in-migrate_vma_insert_page.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-migrate-add-stable-check-in-migrate_vma_insert_page.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Ralph Campbell <rcampbell@xxxxxxxxxx> Subject: 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@xxxxxxxxxx Signed-off-by: Ralph Campbell <rcampbell@xxxxxxxxxx> Cc: Jerome Glisse <jglisse@xxxxxxxxxx> Cc: John Hubbard <jhubbard@xxxxxxxxxx> Cc: Christoph Hellwig <hch@xxxxxx> Cc: Jason Gunthorpe <jgg@xxxxxxxxxxxx> Cc: "Bharata B Rao" <bharata@xxxxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxxxx> Cc: Chris Down <chris@xxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/migrate.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/mm/migrate.c~mm-migrate-add-stable-check-in-migrate_vma_insert_page +++ a/mm/migrate.c @@ -48,6 +48,7 @@ #include <linux/page_owner.h> #include <linux/sched/mm.h> #include <linux/ptrace.h> +#include <linux/oom.h> #include <asm/tlbflush.h> @@ -2674,6 +2675,14 @@ int migrate_vma_setup(struct migrate_vma } 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, unsigned long addr, struct page *page, @@ -2754,6 +2763,9 @@ static void migrate_vma_insert_page(stru ptep = pte_offset_map_lock(mm, pmdp, addr, &ptl); + if (check_stable_address_space(mm)) + goto unlock_abort; + if (pte_present(*ptep)) { unsigned long pfn = pte_pfn(*ptep); _ Patches currently in -mm which might be from rcampbell@xxxxxxxxxx are mm-migrate-remove-useless-mask-of-start-address.patch mm-migrate-clean-up-some-minor-coding-style.patch mm-migrate-add-stable-check-in-migrate_vma_insert_page.patch