From: Ralph Campbell <rcampbell@nvidia.com>
To: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>
Cc: Jerome Glisse <jglisse@redhat.com>,
John Hubbard <jhubbard@nvidia.com>,
Christoph Hellwig <hch@lst.de>,
Jason Gunthorpe <jgg@mellanox.com>,
"Bharata B Rao" <bharata@linux.ibm.com>,
Michal Hocko <mhocko@kernel.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
Ralph Campbell <rcampbell@nvidia.com>
Subject: [PATCH 3/3] mm/migrate: add stable check in migrate_vma_insert_page()
Date: Tue, 7 Jan 2020 13:12:08 -0800 [thread overview]
Message-ID: <20200107211208.24595-4-rcampbell@nvidia.com> (raw)
In-Reply-To: <20200107211208.24595-1-rcampbell@nvidia.com>
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.
Signed-off-by: Ralph Campbell <rcampbell@nvidia.com>
---
mm/migrate.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/mm/migrate.c b/mm/migrate.c
index 4b1a6d69afb5..403b82472d24 100644
--- a/mm/migrate.c
+++ b/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>
@@ -2675,6 +2676,14 @@ int migrate_vma_setup(struct migrate_vma *args)
}
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,
@@ -2755,6 +2764,9 @@ static void migrate_vma_insert_page(struct migrate_vma *migrate,
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);
--
2.20.1
next prev parent reply other threads:[~2020-01-07 21:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-07 21:12 [PATCH 0/3] mm/migrate: add missing check for stable Ralph Campbell
2020-01-07 21:12 ` [PATCH 1/3] mm/migrate: remove useless mask of start address Ralph Campbell
2020-01-08 7:11 ` Christoph Hellwig
2020-01-07 21:12 ` [PATCH 2/3] mm/migrate: clean up some minor coding style Ralph Campbell
2020-01-07 21:33 ` Chris Down
2020-01-08 7:11 ` Christoph Hellwig
2020-01-07 21:12 ` Ralph Campbell [this message]
2020-01-08 7:12 ` [PATCH 3/3] mm/migrate: add stable check in migrate_vma_insert_page() Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200107211208.24595-4-rcampbell@nvidia.com \
--to=rcampbell@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=bharata@linux.ibm.com \
--cc=hch@lst.de \
--cc=jgg@mellanox.com \
--cc=jglisse@redhat.com \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.