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)
This commit is contained in:
John Polstra 1998-10-09 00:24:49 +00:00
parent d0a638ae52
commit 9b35a0d694
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=40087

View File

@ -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);