[PATCH 074/166] migrate: set PROT_NONE on the PTEs and let NUMA balancing

From: Liu Jingqi
Date: Sat Sep 29 2018 - 11:29:56 EST


Need to enable CONFIG_NUMA_BALANCING firstly.
Set PROT_NONE on the PTEs that map to the page,
and do the actual migration in the context of process which initiate migration.

Signed-off-by: Liu Jingqi <jingqi.liu@xxxxxxxxx>
Signed-off-by: Fengguang Wu <fengguang.wu@xxxxxxxxx>
---
mm/migrate.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/mm/migrate.c b/mm/migrate.c
index b27a287081c2..d933f6966601 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1530,6 +1530,21 @@ static int add_page_for_migration(struct mm_struct *mm, unsigned long addr,
if (page_mapcount(page) > 1 && !migrate_all)
goto out_putpage;

+ if (flags & MPOL_MF_SW_YOUNG) {
+ unsigned long start, end;
+ unsigned long nr_pte_updates = 0;
+
+ start = max(addr, vma->vm_start);
+
+ /* TODO: if huge page */
+ end = ALIGN(addr + (1 << PAGE_SHIFT), PAGE_SIZE);
+ end = min(end, vma->vm_end);
+ nr_pte_updates = change_prot_numa(vma, start, end);
+
+ err = 0;
+ goto out_putpage;
+ }
+
if (PageHuge(page)) {
if (PageHead(page)) {
/* Check if the page is software young. */
--
2.15.0


--sbnmklyntwize2li
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="0075-migrate-consolidate-MPOL_MF_SW_YOUNG-behaviors.patch"