From: mpi Date: Wed, 23 Oct 2024 07:18:44 +0000 (+0000) Subject: Decrement uobj reference count without KERNEL_LOCK(). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e49f26072736afaa0d375a3f7346557ffb406a19;p=openbsd Decrement uobj reference count without KERNEL_LOCK(). Reduce KERNEL_LOCK() contention when tearing down file-backed regions. Here it is safe to interleave the KERNEL_LOCK() and a rwlock because the former is released if the latter is contented. Contention analysed by and ok claudio@, ok kettenis@ --- diff --git a/sys/uvm/uvm_vnode.c b/sys/uvm/uvm_vnode.c index 079186cc563..8213f2699a4 100644 --- a/sys/uvm/uvm_vnode.c +++ b/sys/uvm/uvm_vnode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_vnode.c,v 1.133 2024/07/24 12:16:21 mpi Exp $ */ +/* $OpenBSD: uvm_vnode.c,v 1.134 2024/10/23 07:18:44 mpi Exp $ */ /* $NetBSD: uvm_vnode.c,v 1.36 2000/11/24 20:34:01 chs Exp $ */ /* @@ -306,15 +306,14 @@ uvn_detach(struct uvm_object *uobj) struct vnode *vp; int oldflags; - KERNEL_LOCK(); rw_enter(uobj->vmobjlock, RW_WRITE); uobj->uo_refs--; /* drop ref! */ if (uobj->uo_refs) { /* still more refs */ rw_exit(uobj->vmobjlock); - KERNEL_UNLOCK(); return; } + KERNEL_LOCK(); /* get other pointers ... */ uvn = (struct uvm_vnode *) uobj; vp = uvn->u_vnode;