From fe1c35d79003f57aff393aad6c7fa5c4b5e03e15 Mon Sep 17 00:00:00 2001 From: tedu Date: Thu, 28 Jul 2016 16:08:56 +0000 Subject: [PATCH] replace hand rolled physlock with real rwlock. ok mlarkin --- sys/arch/i386/i386/mem.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/sys/arch/i386/i386/mem.c b/sys/arch/i386/i386/mem.c index 0cd086e0c97..513bc97b48a 100644 --- a/sys/arch/i386/i386/mem.c +++ b/sys/arch/i386/i386/mem.c @@ -1,5 +1,5 @@ /* $NetBSD: mem.c,v 1.31 1996/05/03 19:42:19 christos Exp $ */ -/* $OpenBSD: mem.c,v 1.47 2015/09/08 07:12:56 deraadt Exp $ */ +/* $OpenBSD: mem.c,v 1.48 2016/07/28 16:08:56 tedu Exp $ */ /* * Copyright (c) 1988 University of Utah. * Copyright (c) 1982, 1986, 1990, 1993 @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -119,18 +120,13 @@ mmrw(dev_t dev, struct uio *uio, int flags) size_t c; struct iovec *iov; int error = 0; - static int physlock; + static struct rwlock physlock = RWLOCK_INITIALIZER("mmrw"); if (minor(dev) == 0) { /* lock against other uses of shared vmmap */ - while (physlock > 0) { - physlock++; - error = tsleep((caddr_t)&physlock, PZERO | PCATCH, - "mmrw", 0); - if (error) - return (error); - } - physlock = 1; + error = rw_enter(&physlock, RW_WRITE | RW_INTR); + if (error) + return (error); } while (uio->uio_resid > 0 && error == 0) { iov = uio->uio_iov; @@ -197,9 +193,7 @@ mmrw(dev_t dev, struct uio *uio, int flags) uio->uio_resid -= c; } if (minor(dev) == 0) { - if (physlock > 1) - wakeup((caddr_t)&physlock); - physlock = 0; + rw_exit(&physlock); } return (error); } -- 2.20.1