From 2395531439bb140427dff4dfd6d67856f907c15e Mon Sep 17 00:00:00 2001 From: Alfred Perlstein Date: Sat, 19 May 2001 01:28:09 +0000 Subject: 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 --- sys/vm/phys_pager.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'sys/vm/phys_pager.c') diff --git a/sys/vm/phys_pager.c b/sys/vm/phys_pager.c index 1f00ea0c9661..d34672b29e53 100644 --- a/sys/vm/phys_pager.c +++ b/sys/vm/phys_pager.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include @@ -43,7 +42,7 @@ #include /* 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)); -- cgit v1.2.3