mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-26 04:16:39 +00:00
mm/memory.c: do_numa_page(): remove a redundant page table read
do_numa_page() is reading from the same page table entry, twice, while holding the page table lock: once while checking that the pte hasn't changed, and again in order to modify the pte. Instead, just read the pte once, and save it in the same old_pte variable that already exists. This has no effect on behavior, other than to provide a tiny potential improvement to performance, by avoiding the redundant memory read (which the compiler cannot elide, due to READ_ONCE()). Also improve the associated comments nearby. Link: https://lkml.kernel.org/r/20240228034151.459370-1-jhubbard@nvidia.com Signed-off-by: John Hubbard <jhubbard@nvidia.com> Reviewed-by: David Hildenbrand <david@redhat.com> Reviewed-by: Ryan Roberts <ryan.roberts@arm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
c8b3600312
commit
6c1b748ebf
1 changed files with 6 additions and 6 deletions
12
mm/memory.c
12
mm/memory.c
|
@ -5127,18 +5127,18 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf)
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The "pte" at this point cannot be used safely without
|
* The pte cannot be used safely until we verify, while holding the page
|
||||||
* validation through pte_unmap_same(). It's of NUMA type but
|
* table lock, that its contents have not changed during fault handling.
|
||||||
* the pfn may be screwed if the read is non atomic.
|
|
||||||
*/
|
*/
|
||||||
spin_lock(vmf->ptl);
|
spin_lock(vmf->ptl);
|
||||||
if (unlikely(!pte_same(ptep_get(vmf->pte), vmf->orig_pte))) {
|
/* Read the live PTE from the page tables: */
|
||||||
|
old_pte = ptep_get(vmf->pte);
|
||||||
|
|
||||||
|
if (unlikely(!pte_same(old_pte, vmf->orig_pte))) {
|
||||||
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the normal PTE */
|
|
||||||
old_pte = ptep_get(vmf->pte);
|
|
||||||
pte = pte_modify(old_pte, vma->vm_page_prot);
|
pte = pte_modify(old_pte, vma->vm_page_prot);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue