Index | Thread | Search

From:
Martin Pieuchot <mpi@grenadille.net>
Subject:
uvm_fault_lower(): document unlocking
To:
tech@openbsd.org
Date:
Tue, 3 Dec 2024 09:24:30 +0100

Download raw body.

Thread
In uvm_fault_lower() there's this unlocking dance that is different from
the rest of the fault handler which isn't obvious.

The reason is that that kernel just copied the content of `uobjpage' to
a newly allocated anon and there is no need to hold the lock of `uobj'
any longer.

Since this is no longer in NetBSD but I'd like to keep it instead of
holding the lock until after amap_add() and pmap_enter(), let's add some
comment.

ok?

diff --git sys/uvm/uvm_fault.c sys/uvm/uvm_fault.c
index e694554adf0..60694fcc802 100644
--- sys/uvm/uvm_fault.c
+++ sys/uvm/uvm_fault.c
@@ -1401,6 +1401,7 @@ uvm_fault_lower(struct uvm_faultinfo *ufi, struct uvm_faultctx *flt,
 			uvm_lock_pageq();
 			uvm_pageactivate(uobjpage);
 			uvm_unlock_pageq();
+			/* done with copied uobjpage. */
 			rw_exit(uobj->vmobjlock);
 			uobj = NULL;
 		} else {