git: 73b951cd3914 - main - vm: move up object lock asserts in fault functions

From: Mateusz Guzik <mjg_at_FreeBSD.org>
Date: Sat, 11 Mar 2023 11:08:41 UTC
The branch main has been updated by mjg:

URL: https://cgit.FreeBSD.org/src/commit/?id=73b951cd39148accf768d01344a752c377ea4475

commit 73b951cd39148accf768d01344a752c377ea4475
Author:     Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2022-08-07 13:05:47 +0000
Commit:     Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2023-03-11 11:08:21 +0000

    vm: move up object lock asserts in fault functions
    
    No functional changes.
    
    Reviewed by:    kib
    Reviewed by:    markj
    Tested by:      pho
    Differential Revision:  https://reviews.freebsd.org/D38964
---
 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 336cee7ca972..2afe5a19d2d7 100644
--- a/sys/vm/vm_fault.c
+++ b/sys/vm/vm_fault.c
@@ -1047,6 +1047,8 @@ vm_fault_next(struct faultstate *fs)
 {
 	vm_object_t next_object;
 
+	VM_OBJECT_ASSERT_WLOCKED(fs->object);
+
 	/*
 	 * The requested page does not exist at this object/
 	 * offset.  Remove the invalid page from the object,
@@ -1067,7 +1069,6 @@ vm_fault_next(struct faultstate *fs)
 	 * Move on to the next object.  Lock the next object before
 	 * unlocking the current one.
 	 */
-	VM_OBJECT_ASSERT_WLOCKED(fs->object);
 	next_object = fs->object->backing_object;
 	if (next_object == NULL)
 		return (false);
@@ -1382,6 +1383,8 @@ vm_fault_object(struct faultstate *fs, int *behindp, int *aheadp)
 	enum fault_status res;
 	bool dead;
 
+	VM_OBJECT_ASSERT_WLOCKED(fs->object);
+
 	/*
 	 * If the object is marked for imminent termination, we retry
 	 * here, since the collapse pass has raced with us.  Otherwise,
@@ -1416,7 +1419,6 @@ vm_fault_object(struct faultstate *fs, int *behindp, int *aheadp)
 			return (FAULT_SOFT);
 		}
 	}
-	VM_OBJECT_ASSERT_WLOCKED(fs->object);
 
 	/*
 	 * Page is not resident.  If the pager might contain the page