diff options
author | alc <alc@FreeBSD.org> | 2002-06-22 18:36:51 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 2002-06-22 18:36:51 +0000 |
commit | 411b7ea1b56bfd191313a2901c491f6f665c4282 (patch) | |
tree | 645f578dba7c36faf3edf635ce580ccccfd5badd /sys/vm/device_pager.c | |
parent | 7b9815cfbebc18bbc15daea92d4f6bfe511fa38b (diff) | |
download | FreeBSD-src-411b7ea1b56bfd191313a2901c491f6f665c4282.zip FreeBSD-src-411b7ea1b56bfd191313a2901c491f6f665c4282.tar.gz |
o Replace mtx_assert(&Giant, MA_OWNED) in dev_pager_alloc()
with the acquisition and release of Giant. (Annotate as MPSAFE.)
o Reorder the sanity checks in dev_pager_alloc() to reduce
the time that Giant is held.
Diffstat (limited to 'sys/vm/device_pager.c')
-rw-r--r-- | sys/vm/device_pager.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/sys/vm/device_pager.c b/sys/vm/device_pager.c index b1d05a6..4eb4ebd 100644 --- a/sys/vm/device_pager.c +++ b/sys/vm/device_pager.c @@ -97,6 +97,9 @@ dev_pager_init() NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); } +/* + * MPSAFE + */ static vm_object_t dev_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, vm_ooffset_t foff) { @@ -106,26 +109,27 @@ dev_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, vm_ooffset_t fo unsigned int npages; vm_offset_t off; - mtx_assert(&Giant, MA_OWNED); + /* + * Offset should be page aligned. + */ + if (foff & PAGE_MASK) + return (NULL); + + size = round_page(size); + /* * Make sure this device can be mapped. */ dev = handle; + mtx_lock(&Giant); mapfunc = devsw(dev)->d_mmap; if (mapfunc == NULL || mapfunc == (d_mmap_t *)nullop) { printf("obsolete map function %p\n", (void *)mapfunc); + mtx_unlock(&Giant); return (NULL); } /* - * Offset should be page aligned. - */ - if (foff & PAGE_MASK) - return (NULL); - - size = round_page(size); - - /* * Check that the specified range of the device allows the desired * protection. * @@ -133,8 +137,10 @@ dev_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, vm_ooffset_t fo */ npages = OFF_TO_IDX(size); for (off = foff; npages--; off += PAGE_SIZE) - if ((*mapfunc) (dev, off, (int) prot) == -1) + if ((*mapfunc)(dev, off, (int) prot) == -1) { + mtx_unlock(&Giant); return (NULL); + } /* * Lock to prevent object creation race condition. @@ -166,7 +172,7 @@ dev_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, vm_ooffset_t fo } sx_xunlock(&dev_pager_sx); - + mtx_unlock(&Giant); return (object); } |