summaryrefslogtreecommitdiffstats
path: root/sys/vm/phys_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/phys_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/phys_pager.c')
-rw-r--r--sys/vm/phys_pager.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/sys/vm/phys_pager.c b/sys/vm/phys_pager.c
index 1f00ea0..d34672b 100644
--- a/sys/vm/phys_pager.c
+++ b/sys/vm/phys_pager.c
@@ -34,7 +34,6 @@
#include <sys/mutex.h>
#include <sys/mman.h>
#include <sys/sysctl.h>
-#include <sys/sx.h>
#include <vm/vm.h>
#include <vm/vm_object.h>
@@ -43,7 +42,7 @@
#include <vm/vm_zone.h>
/* prevent concurrant creation races */
-static struct sx phys_pager_sx;
+static int phys_pager_alloc_lock;
/* list of device pager objects */
static struct pagerlst phys_pager_object_list;
/* protect access to phys_pager_object_list */
@@ -54,7 +53,6 @@ phys_pager_init(void)
{
TAILQ_INIT(&phys_pager_object_list);
- sx_init(&phys_pager_sx, "phys_pager create");
mtx_init(&phys_pager_mtx, "phys_pager list", MTX_DEF);
}
@@ -76,8 +74,11 @@ phys_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot,
/*
* Lock to prevent object creation race condition.
*/
- sx_xlock(&phys_pager_sx);
-
+ while (phys_pager_alloc_lock) {
+ phys_pager_alloc_lock = -1;
+ msleep(&phys_pager_alloc_lock, &vm_mtx, PVM, "swpalc", 0);
+ }
+
/*
* Look up pager, creating as necessary.
*/
@@ -101,7 +102,10 @@ phys_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot,
if (OFF_TO_IDX(foff + size) > object->size)
object->size = OFF_TO_IDX(foff + size);
}
- sx_xunlock(&phys_pager_sx);
+ if (phys_pager_alloc_lock)
+ wakeup(&phys_pager_alloc_lock);
+ phys_pager_alloc_lock = 0;
+
} else {
object = vm_object_allocate(OBJT_PHYS,
OFF_TO_IDX(foff + size));
OpenPOWER on IntegriCloud