diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2016-07-28 16:08:57 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2016-07-28 16:08:57 +0000 |
commit | ca6d0b057bbf2064794bdf42ef918005c161e12d (patch) | |
tree | 6d0703b5b0b88ce97163700845d563c8474bd522 /sys | |
parent | 3c8e684a5831fa2ac2b32ec06923e84ed84ec968 (diff) |
replace hand rolled physlock with real rwlock. ok mlarkin
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/i386/i386/mem.c | 20 |
1 files 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 <sys/malloc.h> #include <sys/memrange.h> #include <sys/fcntl.h> +#include <sys/rwlock.h> #include <machine/cpu.h> #include <machine/conf.h> @@ -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); } |