summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_zone.c
diff options
context:
space:
mode:
authordillon <dillon@FreeBSD.org>2001-07-04 16:20:28 +0000
committerdillon <dillon@FreeBSD.org>2001-07-04 16:20:28 +0000
commite028603b7e3e4fb35cdf00aab533f3965f4a13cc (patch)
tree7420cce169451a74c5b87963467a4aeff668ed12 /sys/vm/vm_zone.c
parent0b028660051eb7abf4306d34e7fec0e7fde86a28 (diff)
downloadFreeBSD-src-e028603b7e3e4fb35cdf00aab533f3965f4a13cc.zip
FreeBSD-src-e028603b7e3e4fb35cdf00aab533f3965f4a13cc.tar.gz
With Alfred's permission, remove vm_mtx in favor of a fine-grained approach
(this commit is just the first stage). Also add various GIANT_ macros to formalize the removal of Giant, making it easy to test in a more piecemeal fashion. These macros will allow us to test fine-grained locks to a degree before removing Giant, and also after, and to remove Giant in a piecemeal fashion via sysctl's on those subsystems which the authors believe can operate without Giant.
Diffstat (limited to 'sys/vm/vm_zone.c')
-rw-r--r--sys/vm/vm_zone.c23
1 files changed, 3 insertions, 20 deletions
diff --git a/sys/vm/vm_zone.c b/sys/vm/vm_zone.c
index 30fadbe..5c6431b 100644
--- a/sys/vm/vm_zone.c
+++ b/sys/vm/vm_zone.c
@@ -19,6 +19,7 @@
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
+#include <sys/proc.h>
#include <sys/mutex.h>
#include <sys/queue.h>
#include <sys/sysctl.h>
@@ -119,6 +120,8 @@ zinitna(vm_zone_t z, vm_object_t obj, char *name, int size,
{
int totsize, oldzflags;
+ GIANT_REQUIRED;
+
oldzflags = z->zflags;
if ((z->zflags & ZONE_BOOT) == 0) {
z->zsize = (size + ZONE_ROUNDING - 1) & ~(ZONE_ROUNDING - 1);
@@ -137,8 +140,6 @@ zinitna(vm_zone_t z, vm_object_t obj, char *name, int size,
* in pages as needed.
*/
if (z->zflags & ZONE_INTERRUPT) {
- int hadvmlock;
-
totsize = round_page(z->zsize * nentries);
atomic_add_int(&zone_kmem_kvaspace, totsize);
z->zkva = kmem_alloc_pageable(kernel_map, totsize);
@@ -146,17 +147,12 @@ zinitna(vm_zone_t z, vm_object_t obj, char *name, int size,
return 0;
z->zpagemax = totsize / PAGE_SIZE;
- hadvmlock = mtx_owned(&vm_mtx);
- if (!hadvmlock)
- mtx_lock(&vm_mtx);
if (obj == NULL) {
z->zobj = vm_object_allocate(OBJT_DEFAULT, z->zpagemax);
} else {
z->zobj = obj;
_vm_object_allocate(OBJT_DEFAULT, z->zpagemax, obj);
}
- if (!hadvmlock)
- mtx_unlock(&vm_mtx);
z->zallocflag = VM_ALLOC_INTERRUPT;
z->zmax += nentries;
} else {
@@ -364,12 +360,8 @@ void *
zalloc(vm_zone_t z)
{
void *item;
- int hadvmlock;
KASSERT(z != NULL, ("invalid zone"));
- hadvmlock = mtx_owned(&vm_mtx);
- if (!hadvmlock)
- mtx_lock(&vm_mtx);
mtx_lock(&z->zmtx);
if (z->zfreecnt <= z->zfreemin) {
@@ -390,8 +382,6 @@ zalloc(vm_zone_t z)
out:
mtx_unlock(&z->zmtx);
- if (!hadvmlock)
- mtx_unlock(&vm_mtx);
return item;
}
@@ -401,13 +391,8 @@ out:
void
zfree(vm_zone_t z, void *item)
{
- int hadvmlock;
-
KASSERT(z != NULL, ("invalid zone"));
KASSERT(item != NULL, ("invalid item"));
- hadvmlock = mtx_owned(&vm_mtx);
- if (!hadvmlock)
- mtx_lock(&vm_mtx);
mtx_lock(&z->zmtx);
((void **) item)[0] = z->zitems;
@@ -419,8 +404,6 @@ zfree(vm_zone_t z, void *item)
z->zitems = item;
z->zfreecnt++;
- if (!hadvmlock)
- mtx_unlock(&vm_mtx);
mtx_unlock(&z->zmtx);
}
OpenPOWER on IntegriCloud