Skip to contentSkip to conversation

mm/migrate: allow migrate_vma() to alloc new page on empty entry

PATCH New [email protected] 1 participant 1 message Sep 8, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 27/126 mm/migrate: allow migrate_vma() to alloc new page on empty entry

From: Jérôme Glisse <[email protected]>
Subject: mm/migrate: allow migrate_vma() to alloc new page on empty entry

This allows callers of migrate_vma() to allocate new page for empty CPU page table entry (pte_none or back by zero page). This is only for anonymous memory and it won't allow new page to be instanced if the userfaultfd is armed.

This is useful to device driver that want to migrate a range of virtual address and would rather allocate new memory than having to fault later on.

Cc Aneesh Kumar <[email protected]>
Cc Balbir Singh <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Dan Williams <[email protected]>
Cc David Nellans <[email protected]>
Cc Evgeny Baskakov <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc John Hubbard <[email protected]>
Cc Kirill A. Shutemov <[email protected]>
Cc Mark Hairgrove <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Paul E. McKenney <[email protected]>
Cc Ross Zwisler <[email protected]>
Cc Sherry Cheung <[email protected]>
Cc Subhash Gutti <[email protected]>
Cc Vladimir Davydov <[email protected]>
Cc Bob Liu <[email protected]>

---

 include/linux/migrate.h |    9 +
 mm/migrate.c            |  205 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 205 insertions(+), 9 deletions(-)
include/linux/migrate.h renamed from include/linux/migrate.h~mm-migrate-allow-migrate_vma-to-alloc-new-page-on-empty-entry-v4 +9 -0
diff -puN include/linux/migrate.h~mm-migrate-allow-migrate_vma-to-alloc-new-page-on-empty-entry-v4 include/linux/migrate.h
@@ -218,6 +218,15 @@ static inline unsigned long migrate_pfn(
  * driver should avoid setting MIGRATE_PFN_ERROR unless it is really in an
  * unrecoverable state.
  *
+ * For empty entry inside CPU page table (pte_none() or pmd_none() is true) we
+ * do set MIGRATE_PFN_MIGRATE flag inside the corresponding source array thus
+ * allowing device driver to allocate device memory for those unback virtual
+ * address. For this the device driver simply have to allocate device memory
+ * and properly set the destination entry like for regular migration. Note that
+ * this can still fails and thus inside the device driver must check if the
+ * migration was successful for those entry inside the finalize_and_map()
+ * callback just like for regular migration.
+ *
  * THE alloc_and_copy() CALLBACK MUST NOT CHANGE ANY OF THE SRC ARRAY ENTRIES
  * OR BAD THINGS WILL HAPPEN !
  *
mm/migrate.c renamed from mm/migrate.c~mm-migrate-allow-migrate_vma-to-alloc-new-page-on-empty-entry-v4 +196 -9

284 lines not on this page · raw message

_