summaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
Diffstat (limited to 'mm')
-rw-r--r--mm/huge_memory.c15
-rw-r--r--mm/memory.c30
2 files changed, 39 insertions, 6 deletions
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index becf92ca54f3..7ab4e32afe12 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1285,6 +1285,7 @@ int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma,
1285 int target_nid, last_cpupid = -1; 1285 int target_nid, last_cpupid = -1;
1286 bool page_locked; 1286 bool page_locked;
1287 bool migrated = false; 1287 bool migrated = false;
1288 int flags = 0;
1288 1289
1289 spin_lock(&mm->page_table_lock); 1290 spin_lock(&mm->page_table_lock);
1290 if (unlikely(!pmd_same(pmd, *pmdp))) 1291 if (unlikely(!pmd_same(pmd, *pmdp)))
@@ -1299,6 +1300,14 @@ int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma,
1299 count_vm_numa_event(NUMA_HINT_FAULTS_LOCAL); 1300 count_vm_numa_event(NUMA_HINT_FAULTS_LOCAL);
1300 1301
1301 /* 1302 /*
1303 * Avoid grouping on DSO/COW pages in specific and RO pages
1304 * in general, RO pages shouldn't hurt as much anyway since
1305 * they can be in shared cache state.
1306 */
1307 if (!pmd_write(pmd))
1308 flags |= TNF_NO_GROUP;
1309
1310 /*
1302 * Acquire the page lock to serialise THP migrations but avoid dropping 1311 * Acquire the page lock to serialise THP migrations but avoid dropping
1303 * page_table_lock if at all possible 1312 * page_table_lock if at all possible
1304 */ 1313 */
@@ -1343,8 +1352,10 @@ int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma,
1343 spin_unlock(&mm->page_table_lock); 1352 spin_unlock(&mm->page_table_lock);
1344 migrated = migrate_misplaced_transhuge_page(mm, vma, 1353 migrated = migrate_misplaced_transhuge_page(mm, vma,
1345 pmdp, pmd, addr, page, target_nid); 1354 pmdp, pmd, addr, page, target_nid);
1346 if (migrated) 1355 if (migrated) {
1356 flags |= TNF_MIGRATED;
1347 page_nid = target_nid; 1357 page_nid = target_nid;
1358 }
1348 1359
1349 goto out; 1360 goto out;
1350clear_pmdnuma: 1361clear_pmdnuma:
@@ -1362,7 +1373,7 @@ out:
1362 page_unlock_anon_vma_read(anon_vma); 1373 page_unlock_anon_vma_read(anon_vma);
1363 1374
1364 if (page_nid != -1) 1375 if (page_nid != -1)
1365 task_numa_fault(last_cpupid, page_nid, HPAGE_PMD_NR, migrated); 1376 task_numa_fault(last_cpupid, page_nid, HPAGE_PMD_NR, flags);
1366 1377
1367 return 0; 1378 return 0;
1368} 1379}
diff --git a/mm/memory.c b/mm/memory.c
index c57efa25cdbb..eba846bcf124 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3547,6 +3547,7 @@ int do_numa_page(struct mm_struct *mm, struct vm_area_struct *vma,
3547 int last_cpupid; 3547 int last_cpupid;
3548 int target_nid; 3548 int target_nid;
3549 bool migrated = false; 3549 bool migrated = false;
3550 int flags = 0;
3550 3551
3551 /* 3552 /*
3552 * The "pte" at this point cannot be used safely without 3553 * The "pte" at this point cannot be used safely without
@@ -3575,6 +3576,14 @@ int do_numa_page(struct mm_struct *mm, struct vm_area_struct *vma,
3575 } 3576 }
3576 BUG_ON(is_zero_pfn(page_to_pfn(page))); 3577 BUG_ON(is_zero_pfn(page_to_pfn(page)));
3577 3578
3579 /*
3580 * Avoid grouping on DSO/COW pages in specific and RO pages
3581 * in general, RO pages shouldn't hurt as much anyway since
3582 * they can be in shared cache state.
3583 */
3584 if (!pte_write(pte))
3585 flags |= TNF_NO_GROUP;
3586
3578 last_cpupid = page_cpupid_last(page); 3587 last_cpupid = page_cpupid_last(page);
3579 page_nid = page_to_nid(page); 3588 page_nid = page_to_nid(page);
3580 target_nid = numa_migrate_prep(page, vma, addr, page_nid); 3589 target_nid = numa_migrate_prep(page, vma, addr, page_nid);
@@ -3586,12 +3595,14 @@ int do_numa_page(struct mm_struct *mm, struct vm_area_struct *vma,
3586 3595
3587 /* Migrate to the requested node */ 3596 /* Migrate to the requested node */
3588 migrated = migrate_misplaced_page(page, vma, target_nid); 3597 migrated = migrate_misplaced_page(page, vma, target_nid);
3589 if (migrated) 3598 if (migrated) {
3590 page_nid = target_nid; 3599 page_nid = target_nid;
3600 flags |= TNF_MIGRATED;
3601 }
3591 3602
3592out: 3603out:
3593 if (page_nid != -1) 3604 if (page_nid != -1)
3594 task_numa_fault(last_cpupid, page_nid, 1, migrated); 3605 task_numa_fault(last_cpupid, page_nid, 1, flags);
3595 return 0; 3606 return 0;
3596} 3607}
3597 3608
@@ -3632,6 +3643,7 @@ static int do_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma,
3632 int page_nid = -1; 3643 int page_nid = -1;
3633 int target_nid; 3644 int target_nid;
3634 bool migrated = false; 3645 bool migrated = false;
3646 int flags = 0;
3635 3647
3636 if (!pte_present(pteval)) 3648 if (!pte_present(pteval))
3637 continue; 3649 continue;
@@ -3651,20 +3663,30 @@ static int do_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma,
3651 if (unlikely(!page)) 3663 if (unlikely(!page))
3652 continue; 3664 continue;
3653 3665
3666 /*
3667 * Avoid grouping on DSO/COW pages in specific and RO pages
3668 * in general, RO pages shouldn't hurt as much anyway since
3669 * they can be in shared cache state.
3670 */
3671 if (!pte_write(pteval))
3672 flags |= TNF_NO_GROUP;
3673
3654 last_cpupid = page_cpupid_last(page); 3674 last_cpupid = page_cpupid_last(page);
3655 page_nid = page_to_nid(page); 3675 page_nid = page_to_nid(page);
3656 target_nid = numa_migrate_prep(page, vma, addr, page_nid); 3676 target_nid = numa_migrate_prep(page, vma, addr, page_nid);
3657 pte_unmap_unlock(pte, ptl); 3677 pte_unmap_unlock(pte, ptl);
3658 if (target_nid != -1) { 3678 if (target_nid != -1) {
3659 migrated = migrate_misplaced_page(page, vma, target_nid); 3679 migrated = migrate_misplaced_page(page, vma, target_nid);
3660 if (migrated) 3680 if (migrated) {
3661 page_nid = target_nid; 3681 page_nid = target_nid;
3682 flags |= TNF_MIGRATED;
3683 }
3662 } else { 3684 } else {
3663 put_page(page); 3685 put_page(page);
3664 } 3686 }
3665 3687
3666 if (page_nid != -1) 3688 if (page_nid != -1)
3667 task_numa_fault(last_cpupid, page_nid, 1, migrated); 3689 task_numa_fault(last_cpupid, page_nid, 1, flags);
3668 3690
3669 pte = pte_offset_map_lock(mm, pmdp, addr, &ptl); 3691 pte = pte_offset_map_lock(mm, pmdp, addr, &ptl);
3670 } 3692 }