git: 3c3a434f8ee8 - main - vm: avoid lock upgrade if possible in vm_fault_next

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

URL: https://cgit.FreeBSD.org/src/commit/?id=3c3a434f8ee867e6e4a69de07bf0811f2ae0c46e

commit 3c3a434f8ee867e6e4a69de07bf0811f2ae0c46e
Author:     Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2023-03-11 20:57:24 +0000
Commit:     Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2023-03-11 21:52:01 +0000

    vm: avoid lock upgrade if possible in vm_fault_next
    
    In my tests during buildkernel fs->m was always NULL at that stage.
    
    Note the change has no impact on vm obj contention during said workload.
    
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D39027
---
 sys/vm/vm_fault.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c
index 5df667052615..fadd7dbd2fd5 100644
--- a/sys/vm/vm_fault.c
+++ b/sys/vm/vm_fault.c
@@ -1092,7 +1092,7 @@ vm_fault_next(struct faultstate *fs)
 	if (fs->object == fs->first_object) {
 		fs->first_m = fs->m;
 		fs->m = NULL;
-	} else {
+	} else if (fs->m != NULL) {
 		if (!vm_fault_object_ensure_wlocked(fs)) {
 			fs->can_read_lock = false;
 			unlock_and_deallocate(fs);