summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_pager.c
diff options
context:
space:
mode:
authoralfred <alfred@FreeBSD.org>2001-05-19 01:28:09 +0000
committeralfred <alfred@FreeBSD.org>2001-05-19 01:28:09 +0000
commita3f0842419d98da211706f921fc626e160cd960b (patch)
treee86922a5639c32e1242d4f3088fc487f3be5b236 /sys/vm/vm_pager.c
parent9eda9187f024233436e6a743f13bd938b1a0f19c (diff)
downloadFreeBSD-src-a3f0842419d98da211706f921fc626e160cd960b.zip
FreeBSD-src-a3f0842419d98da211706f921fc626e160cd960b.tar.gz
Introduce a global lock for the vm subsystem (vm_mtx).
vm_mtx does not recurse and is required for most low level vm operations. faults can not be taken without holding Giant. Memory subsystems can now call the base page allocators safely. Almost all atomic ops were removed as they are covered under the vm mutex. Alpha and ia64 now need to catch up to i386's trap handlers. FFS and NFS have been tested, other filesystems will need minor changes (grabbing the vm lock when twiddling page properties). Reviewed (partially) by: jake, jhb
Diffstat (limited to 'sys/vm/vm_pager.c')
-rw-r--r--sys/vm/vm_pager.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c
index b13c9c0..e53a14c 100644
--- a/sys/vm/vm_pager.c
+++ b/sys/vm/vm_pager.c
@@ -240,21 +240,32 @@ vm_pager_bufferinit()
* need to perform page-level validation (e.g. the device pager).
*/
vm_object_t
-vm_pager_allocate(objtype_t type, void *handle, vm_ooffset_t size, vm_prot_t prot,
- vm_ooffset_t off)
+vm_pager_allocate(objtype_t type, void *handle, vm_ooffset_t size,
+ vm_prot_t prot, vm_ooffset_t off)
{
+ vm_object_t ret;
struct pagerops *ops;
+ int hadvmlock;
+ hadvmlock = mtx_owned(&vm_mtx);
+ if (!hadvmlock)
+ mtx_lock(&vm_mtx);
ops = pagertab[type];
if (ops)
- return ((*ops->pgo_alloc) (handle, size, prot, off));
- return (NULL);
+ ret = (*ops->pgo_alloc) (handle, size, prot, off);
+ else
+ ret = NULL;
+ if (!hadvmlock)
+ mtx_unlock(&vm_mtx);
+ return (ret);
}
void
vm_pager_deallocate(object)
vm_object_t object;
{
+
+ mtx_assert(&vm_mtx, MA_OWNED);
(*pagertab[object->type]->pgo_dealloc) (object);
}
@@ -374,6 +385,8 @@ initpbuf(struct buf *bp)
*
* NOTE: pfreecnt can be NULL, but this 'feature' will be removed
* relatively soon when the rest of the subsystems get smart about it. XXX
+ *
+ * vm_mtx can be held or unheld
*/
struct buf *
getpbuf(pfreecnt)
@@ -381,8 +394,12 @@ getpbuf(pfreecnt)
{
int s;
struct buf *bp;
+ int hadvmlock;
s = splvm();
+ hadvmlock = mtx_owned(&vm_mtx);
+ if (hadvmlock)
+ mtx_unlock(&vm_mtx);
mtx_lock(&pbuf_mtx);
for (;;) {
@@ -407,6 +424,8 @@ getpbuf(pfreecnt)
splx(s);
initpbuf(bp);
+ if (hadvmlock)
+ mtx_lock(&vm_mtx);
return bp;
}
OpenPOWER on IntegriCloud