aboutsummaryrefslogtreecommitdiffstats
path: root/mm/huge_memory.c
diff options
context:
space:
mode:
authorMel Gorman <mgorman@suse.de>2013-10-07 06:28:45 -0400
committerIngo Molnar <mingo@kernel.org>2013-10-29 06:37:52 -0400
commitc61109e34f60f6e85bb43c5a1cd51c0e3db40847 (patch)
tree5b03f4c2d1376166da7e4a507ddf7a4c6e16eee7 /mm/huge_memory.c
parent587fe586f44a48f9691001ba6c45b86c8e4ba21f (diff)
mm: numa: Sanitize task_numa_fault() callsites
There are three callers of task_numa_fault(): - do_huge_pmd_numa_page(): Accounts against the current node, not the node where the page resides, unless we migrated, in which case it accounts against the node we migrated to. - do_numa_page(): Accounts against the current node, not the node where the page resides, unless we migrated, in which case it accounts against the node we migrated to. - do_pmd_numa_page(): Accounts not at all when the page isn't migrated, otherwise accounts against the node we migrated towards. This seems wrong to me; all three sites should have the same sementaics, furthermore we should accounts against where the page really is, we already know where the task is. So modify all three sites to always account; we did after all receive the fault; and always account to where the page is after migration, regardless of success. They all still differ on when they clear the PTE/PMD; ideally that would get sorted too. Signed-off-by: Mel Gorman <mgorman@suse.de> Reviewed-by: Rik van Riel <riel@redhat.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Cc: <stable@kernel.org> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/1381141781-10992-8-git-send-email-mgorman@suse.de Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'mm/huge_memory.c')
-rw-r--r--mm/huge_memory.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index d8534b3630e4..00ddfcdd810e 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1281,18 +1281,19 @@ int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma,
1281 struct anon_vma *anon_vma = NULL; 1281 struct anon_vma *anon_vma = NULL;
1282 struct page *page; 1282 struct page *page;
1283 unsigned long haddr = addr & HPAGE_PMD_MASK; 1283 unsigned long haddr = addr & HPAGE_PMD_MASK;
1284 int page_nid = -1, this_nid = numa_node_id();
1284 int target_nid; 1285 int target_nid;
1285 int current_nid = -1; 1286 bool page_locked;
1286 bool migrated, page_locked; 1287 bool migrated = false;
1287 1288
1288 spin_lock(&mm->page_table_lock); 1289 spin_lock(&mm->page_table_lock);
1289 if (unlikely(!pmd_same(pmd, *pmdp))) 1290 if (unlikely(!pmd_same(pmd, *pmdp)))
1290 goto out_unlock; 1291 goto out_unlock;
1291 1292
1292 page = pmd_page(pmd); 1293 page = pmd_page(pmd);
1293 current_nid = page_to_nid(page); 1294 page_nid = page_to_nid(page);
1294 count_vm_numa_event(NUMA_HINT_FAULTS); 1295 count_vm_numa_event(NUMA_HINT_FAULTS);
1295 if (current_nid == numa_node_id()) 1296 if (page_nid == this_nid)
1296 count_vm_numa_event(NUMA_HINT_FAULTS_LOCAL); 1297 count_vm_numa_event(NUMA_HINT_FAULTS_LOCAL);
1297 1298
1298 /* 1299 /*
@@ -1335,19 +1336,18 @@ int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma,
1335 spin_unlock(&mm->page_table_lock); 1336 spin_unlock(&mm->page_table_lock);
1336 migrated = migrate_misplaced_transhuge_page(mm, vma, 1337 migrated = migrate_misplaced_transhuge_page(mm, vma,
1337 pmdp, pmd, addr, page, target_nid); 1338 pmdp, pmd, addr, page, target_nid);
1338 if (!migrated) 1339 if (migrated)
1340 page_nid = target_nid;
1341 else
1339 goto check_same; 1342 goto check_same;
1340 1343
1341 task_numa_fault(target_nid, HPAGE_PMD_NR, true); 1344 goto out;
1342 if (anon_vma)
1343 page_unlock_anon_vma_read(anon_vma);
1344 return 0;
1345 1345
1346check_same: 1346check_same:
1347 spin_lock(&mm->page_table_lock); 1347 spin_lock(&mm->page_table_lock);
1348 if (unlikely(!pmd_same(pmd, *pmdp))) { 1348 if (unlikely(!pmd_same(pmd, *pmdp))) {
1349 /* Someone else took our fault */ 1349 /* Someone else took our fault */
1350 current_nid = -1; 1350 page_nid = -1;
1351 goto out_unlock; 1351 goto out_unlock;
1352 } 1352 }
1353clear_pmdnuma: 1353clear_pmdnuma:
@@ -1362,8 +1362,9 @@ out:
1362 if (anon_vma) 1362 if (anon_vma)
1363 page_unlock_anon_vma_read(anon_vma); 1363 page_unlock_anon_vma_read(anon_vma);
1364 1364
1365 if (current_nid != -1) 1365 if (page_nid != -1)
1366 task_numa_fault(current_nid, HPAGE_PMD_NR, false); 1366 task_numa_fault(page_nid, HPAGE_PMD_NR, migrated);
1367
1367 return 0; 1368 return 0;
1368} 1369}
1369 1370