FROMGIT: mm: move FAULT_FLAG_VMA_LOCK check down in handle_pte_fault()

Call do_pte_missing() under the VMA lock ...  then immediately retry in
do_fault().

Link: https://lkml.kernel.org/r/20230724185410.1124082-7-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
Cc: Arjun Roy <arjunroy@google.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Punit Agrawal <punit.agrawal@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 4c753b25481499cd1cb6a8ddba18bc5585f34296
https: //git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-unstable)

Bug: 293665307
Change-Id: I8c8f2feaade7c40daf37b63e43111d22ec147e5f
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This commit is contained in:
Matthew Wilcox (Oracle) 2023-07-24 19:54:06 +01:00 committed by Suren Baghdasaryan
parent dd621869c1
commit fa9a8adff0

View File

@ -4695,6 +4695,11 @@ static vm_fault_t do_fault(struct vm_fault *vmf)
struct mm_struct *vm_mm = vma->vm_mm;
vm_fault_t ret;
if (vmf->flags & FAULT_FLAG_VMA_LOCK){
vma_end_read(vma);
return VM_FAULT_RETRY;
}
/*
* The VMA was not fully populated on mmap() or missing VM_DONTEXPAND
*/
@ -4969,11 +4974,6 @@ static vm_fault_t handle_pte_fault(struct vm_fault *vmf)
{
pte_t entry;
if ((vmf->flags & FAULT_FLAG_VMA_LOCK) && !vma_is_anonymous(vmf->vma)) {
vma_end_read(vmf->vma);
return VM_FAULT_RETRY;
}
if (unlikely(pmd_none(*vmf->pmd))) {
/*
* Leave __pte_alloc() until later: because vm_ops->fault may
@ -5030,6 +5030,12 @@ static vm_fault_t handle_pte_fault(struct vm_fault *vmf)
return do_fault(vmf);
}
if ((vmf->flags & FAULT_FLAG_VMA_LOCK) && !vma_is_anonymous(vmf->vma)) {
pte_unmap(vmf->pte);
vma_end_read(vmf->vma);
return VM_FAULT_RETRY;
}
if (!pte_present(vmf->orig_pte))
return do_swap_page(vmf);