From e49f26072736afaa0d375a3f7346557ffb406a19 Mon Sep 17 00:00:00 2001 From: mpi Date: Wed, 23 Oct 2024 07:18:44 +0000 Subject: [PATCH] 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@ --- sys/uvm/uvm_vnode.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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; -- 2.20.1