git: 6d6c97fb72a7 - main - vm_fault: update pred lock acq in copy_entry

From: Doug Moore <dougm_at_FreeBSD.org>
Date: Thu, 27 Mar 2025 10:40:42 UTC
The branch main has been updated by dougm:

URL: https://cgit.FreeBSD.org/src/commit/?id=6d6c97fb72a7dce85008cef891d093b24dcbb380

commit 6d6c97fb72a7dce85008cef891d093b24dcbb380
Author:     Doug Moore <dougm@FreeBSD.org>
AuthorDate: 2025-03-27 10:39:44 +0000
Commit:     Doug Moore <dougm@FreeBSD.org>
CommitDate: 2025-03-27 10:39:44 +0000

    vm_fault: update pred lock acq in copy_entry
    
    In vm_fault_copy_entry, variable 'mpred' is invalided as the
    predecessor of the next page to be inserted when an allocation failure
    leads to lock release and reacquisition.  Recompute it in that case.
    
    Reported by:    markj
    Reviewed by:    markj
    Fixes:  vm_page: expose page_alloc_after 6b33d9dc46c2f1cbb9127377119
    Differential Revision:  https://reviews.freebsd.org/D49521
---
 sys/vm/vm_fault.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c
index c97a7cd998df..2e254e255dce 100644
--- a/sys/vm/vm_fault.c
+++ b/sys/vm/vm_fault.c
@@ -2199,14 +2199,16 @@ again:
 			/*
 			 * Allocate a page in the destination object.
 			 */
-			dst_m = vm_page_alloc_after(dst_object, (src_object ==
-			    dst_object ? src_pindex : 0) + dst_pindex,
+			pindex = (src_object == dst_object ? src_pindex : 0) +
+			    dst_pindex;
+			dst_m = vm_page_alloc_after(dst_object, pindex,
 			    VM_ALLOC_NORMAL, mpred);
 			if (dst_m == NULL) {
 				VM_OBJECT_WUNLOCK(dst_object);
 				VM_OBJECT_RUNLOCK(object);
 				vm_wait(dst_object);
 				VM_OBJECT_WLOCK(dst_object);
+				mpred = vm_page_mpred(src_object, pindex);
 				goto again;
 			}