Skip to content

Commit 3578e2d

Browse files
committed
Merge: mm: fix finish_fault() handling for large folios
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/964 JIRA: https://issues.redhat.com/browse/RHEL-83854 Tested: by me This one was a hard one to track. Trinity would trigger this but sometimes taking multiple runs. We might need 3685024 backported in the future too, but I prefer not to mix up both in the same ticket. Signed-off-by: Aristeu Rozanski <arozansk@redhat.com> Approved-by: Waiman Long <longman@redhat.com> Approved-by: Donald Dutile <ddutile@redhat.com> Approved-by: Rafael Aquini <raquini@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Jan Stancek <jstancek@redhat.com>
2 parents d2f966a + 9ac0bb6 commit 3578e2d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

mm/memory.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5104,7 +5104,11 @@ vm_fault_t finish_fault(struct vm_fault *vmf)
51045104
bool is_cow = (vmf->flags & FAULT_FLAG_WRITE) &&
51055105
!(vma->vm_flags & VM_SHARED);
51065106
int type, nr_pages;
5107-
unsigned long addr = vmf->address;
5107+
unsigned long addr;
5108+
bool needs_fallback = false;
5109+
5110+
fallback:
5111+
addr = vmf->address;
51085112

51095113
/* Did we COW the page? */
51105114
if (is_cow)
@@ -5143,7 +5147,8 @@ vm_fault_t finish_fault(struct vm_fault *vmf)
51435147
* approach also applies to non-anonymous-shmem faults to avoid
51445148
* inflating the RSS of the process.
51455149
*/
5146-
if (!vma_is_anon_shmem(vma) || unlikely(userfaultfd_armed(vma))) {
5150+
if (!vma_is_anon_shmem(vma) || unlikely(userfaultfd_armed(vma)) ||
5151+
unlikely(needs_fallback)) {
51475152
nr_pages = 1;
51485153
} else if (nr_pages > 1) {
51495154
pgoff_t idx = folio_page_idx(folio, page);
@@ -5179,9 +5184,9 @@ vm_fault_t finish_fault(struct vm_fault *vmf)
51795184
ret = VM_FAULT_NOPAGE;
51805185
goto unlock;
51815186
} else if (nr_pages > 1 && !pte_range_none(vmf->pte, nr_pages)) {
5182-
update_mmu_tlb_range(vma, addr, vmf->pte, nr_pages);
5183-
ret = VM_FAULT_NOPAGE;
5184-
goto unlock;
5187+
needs_fallback = true;
5188+
pte_unmap_unlock(vmf->pte, vmf->ptl);
5189+
goto fallback;
51855190
}
51865191

51875192
folio_ref_add(folio, nr_pages - 1);

0 commit comments

Comments
 (0)