Skip to content

Commit 691bedd

Browse files
x-y-zakpm00
authored andcommitted
mm/numa: no task_numa_fault() call if page table is changed
When handling a numa page fault, task_numa_fault() should be called by a process that restores the page table of the faulted folio to avoid duplicated stats counting. Commit b99a342 ("NUMA balancing: reduce TLB flush via delaying mapping on hint page fault") restructured do_numa_page() and do_huge_pmd_numa_page() and did not avoid task_numa_fault() call in the second page table check after a numa migration failure. Fix it by making all !pte_same()/!pmd_same() return immediately. This issue can cause task_numa_fault() being called more than necessary and lead to unexpected numa balancing results (It is hard to tell whether the issue will cause positive or negative performance impact due to duplicated numa fault counting). Link: https://lkml.kernel.org/r/[email protected] Fixes: b99a342 ("NUMA balancing: reduce TLB flush via delaying mapping on hint page fault") Signed-off-by: Zi Yan <[email protected]> Reported-by: "Huang, Ying" <[email protected]> Closes: https://lore.kernel.org/linux-mm/[email protected]/ Cc: Baolin Wang <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Kefeng Wang <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 2900cb5 commit 691bedd

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

mm/huge_memory.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,10 +1738,11 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf)
17381738
goto out_map;
17391739
}
17401740

1741-
out:
1741+
count_fault:
17421742
if (nid != NUMA_NO_NODE)
17431743
task_numa_fault(last_cpupid, nid, HPAGE_PMD_NR, flags);
17441744

1745+
out:
17451746
return 0;
17461747

17471748
out_map:
@@ -1753,7 +1754,7 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf)
17531754
set_pmd_at(vma->vm_mm, haddr, vmf->pmd, pmd);
17541755
update_mmu_cache_pmd(vma, vmf->address, vmf->pmd);
17551756
spin_unlock(vmf->ptl);
1756-
goto out;
1757+
goto count_fault;
17571758
}
17581759

17591760
/*

mm/memory.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5371,9 +5371,10 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf)
53715371
goto out_map;
53725372
}
53735373

5374-
out:
5374+
count_fault:
53755375
if (nid != NUMA_NO_NODE)
53765376
task_numa_fault(last_cpupid, nid, nr_pages, flags);
5377+
out:
53775378
return 0;
53785379
out_map:
53795380
/*
@@ -5387,7 +5388,7 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf)
53875388
numa_rebuild_single_mapping(vmf, vma, vmf->address, vmf->pte,
53885389
writable);
53895390
pte_unmap_unlock(vmf->pte, vmf->ptl);
5390-
goto out;
5391+
goto count_fault;
53915392
}
53925393

53935394
static inline vm_fault_t create_huge_pmd(struct vm_fault *vmf)

0 commit comments

Comments
 (0)