diff options
author | jdp <jdp@FreeBSD.org> | 1998-10-09 00:24:49 +0000 |
---|---|---|
committer | jdp <jdp@FreeBSD.org> | 1998-10-09 00:24:49 +0000 |
commit | 2846983609af2a237a822ac831e14fb2a1f0d487 (patch) | |
tree | 825e1f646df26a6464694ef0de4681945d59db96 /sys/vm | |
parent | 1f21e28dc65a305fd2bd4e5192d900026b17bd76 (diff) | |
download | FreeBSD-src-2846983609af2a237a822ac831e14fb2a1f0d487.zip FreeBSD-src-2846983609af2a237a822ac831e14fb2a1f0d487.tar.gz |
Fix a panic on SMP systems, caused by sleeping while holding a
simple-lock.
The reviewer raises the following caveat: "I believe these changes
open a non-critical race condition when adding memory to the pool
for the zone. I think what will happen is that you could have two
threads that are simultaneously adding additional memory when the
pool runs out. This appears to not be a problem, however, since
the re-aquisition of the lock will protect the list pointers."
The submitter agrees that the race is non-critical, and points out
that it already existed for the non-SMP case. He suggests that
perhaps a sleep lock (using the lock manager) should be used to
close that race. This might be worth revisiting after 3.0 is
released.
Reviewed by: dg (David Greenman)
Submitted by: tegge (Tor Egge)
Diffstat (limited to 'sys/vm')
-rw-r--r-- | sys/vm/vm_zone.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/vm/vm_zone.c b/sys/vm/vm_zone.c index 478ed48..11a7ae0 100644 --- a/sys/vm/vm_zone.c +++ b/sys/vm/vm_zone.c @@ -11,7 +11,7 @@ * 2. Absolutely no warranty of function or purpose is made by the author * John S. Dyson. * - * $Id: vm_zone.c,v 1.20 1998/04/15 17:47:40 bde Exp $ + * $Id: vm_zone.c,v 1.21 1998/04/25 04:50:01 dyson Exp $ */ #include <sys/param.h> @@ -326,11 +326,23 @@ _zget(vm_zone_t z) if (lockstatus(&kernel_map->lock)) { int s; s = splvm(); +#ifdef SMP + simple_unlock(&z->zlock); +#endif item = (void *) kmem_malloc(kmem_map, nbytes, M_WAITOK); +#ifdef SMP + simple_lock(&z->zlock); +#endif zone_kmem_pages += z->zalloc; splx(s); } else { +#ifdef SMP + simple_unlock(&z->zlock); +#endif item = (void *) kmem_alloc(kernel_map, nbytes); +#ifdef SMP + simple_lock(&z->zlock); +#endif zone_kern_pages += z->zalloc; } bzero(item, nbytes); |