diff options
author | alc <alc@FreeBSD.org> | 2004-01-04 20:55:15 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 2004-01-04 20:55:15 +0000 |
commit | 8c0190db49bd4397a735eef56aa617b16862cb56 (patch) | |
tree | ca5c1935c2a900d3b0964519f7419f8fb918f9a2 /sys/vm/phys_pager.c | |
parent | 6fde69b7d17726e5071e0aeb2f166836ab07b949 (diff) | |
download | FreeBSD-src-8c0190db49bd4397a735eef56aa617b16862cb56.zip FreeBSD-src-8c0190db49bd4397a735eef56aa617b16862cb56.tar.gz |
Simplify the various pager allocation routines by computing the desired
object size once and assigning that value to a local variable.
Diffstat (limited to 'sys/vm/phys_pager.c')
-rw-r--r-- | sys/vm/phys_pager.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/sys/vm/phys_pager.c b/sys/vm/phys_pager.c index 6a2e191..3840004 100644 --- a/sys/vm/phys_pager.c +++ b/sys/vm/phys_pager.c @@ -65,6 +65,7 @@ phys_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, vm_ooffset_t foff) { vm_object_t object; + vm_pindex_t pindex; /* * Offset should be page aligned. @@ -72,7 +73,7 @@ phys_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, if (foff & PAGE_MASK) return (NULL); - size = round_page(size); + pindex = OFF_TO_IDX(foff + PAGE_MASK + size); if (handle != NULL) { mtx_lock(&Giant); @@ -93,8 +94,7 @@ phys_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, /* * Allocate object and associate it with the pager. */ - object = vm_object_allocate(OBJT_PHYS, - OFF_TO_IDX(foff + size)); + object = vm_object_allocate(OBJT_PHYS, pindex); object->handle = handle; mtx_lock(&phys_pager_mtx); TAILQ_INSERT_TAIL(&phys_pager_object_list, object, @@ -105,16 +105,15 @@ phys_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, * Gain a reference to the object. */ vm_object_reference(object); - if (OFF_TO_IDX(foff + size) > object->size) - object->size = OFF_TO_IDX(foff + size); + if (pindex > object->size) + object->size = pindex; } if (phys_pager_alloc_lock == -1) wakeup(&phys_pager_alloc_lock); phys_pager_alloc_lock = 0; mtx_unlock(&Giant); } else { - object = vm_object_allocate(OBJT_PHYS, - OFF_TO_IDX(foff + size)); + object = vm_object_allocate(OBJT_PHYS, pindex); } return (object); |