diff options
Diffstat (limited to 'sys/vm')
-rw-r--r-- | sys/vm/vm_map.c | 8 | ||||
-rw-r--r-- | sys/vm/vm_object.c | 16 | ||||
-rw-r--r-- | sys/vm/vm_page.c | 25 | ||||
-rw-r--r-- | sys/vm/vm_page.h | 1 |
4 files changed, 29 insertions, 21 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 3ef93a3..c4089c6 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -1750,13 +1750,7 @@ vm_map_pmap_enter(vm_map_t map, vm_offset_t addr, vm_prot_t prot, start = 0; p_start = NULL; - if ((p = TAILQ_FIRST(&object->memq)) != NULL) { - if (p->pindex < pindex) { - p = vm_page_splay(pindex, object->root); - if ((object->root = p)->pindex < pindex) - p = TAILQ_NEXT(p, listq); - } - } + p = vm_page_find_least(object, pindex); /* * Assert: the variable p is either (1) the page with the * least pindex greater than or equal to the parameter pindex diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index ae7af15..11284ab 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -1400,13 +1400,7 @@ vm_object_split(vm_map_entry_t entry) orig_object->charge -= ptoa(size); } retry: - if ((m = TAILQ_FIRST(&orig_object->memq)) != NULL) { - if (m->pindex < offidxstart) { - m = vm_page_splay(offidxstart, orig_object->root); - if ((orig_object->root = m)->pindex < offidxstart) - m = TAILQ_NEXT(m, listq); - } - } + m = vm_page_find_least(orig_object, offidxstart); for (; m != NULL && (idx = m->pindex - offidxstart) < size; m = m_next) { m_next = TAILQ_NEXT(m, listq); @@ -1910,13 +1904,7 @@ vm_object_page_remove(vm_object_t object, vm_pindex_t start, vm_pindex_t end, vm_object_pip_add(object, 1); again: - if ((p = TAILQ_FIRST(&object->memq)) != NULL) { - if (p->pindex < start) { - p = vm_page_splay(start, object->root); - if ((object->root = p)->pindex < start) - p = TAILQ_NEXT(p, listq); - } - } + p = vm_page_find_least(object, start); /* * Assert: the variable p is either (1) the page with the diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index fc9fdd4..6659e76 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -879,6 +879,31 @@ vm_page_lookup(vm_object_t object, vm_pindex_t pindex) } /* + * vm_page_find_least: + * + * Returns the page associated with the object with least pindex + * greater than or equal to the parameter pindex, or NULL. + * + * The object must be locked. + * The routine may not block. + */ +vm_page_t +vm_page_find_least(vm_object_t object, vm_pindex_t pindex) +{ + vm_page_t m; + + VM_OBJECT_LOCK_ASSERT(object, MA_OWNED); + if ((m = TAILQ_FIRST(&object->memq)) != NULL) { + if (m->pindex < pindex) { + m = vm_page_splay(pindex, object->root); + if ((object->root = m)->pindex < pindex) + m = TAILQ_NEXT(m, listq); + } + } + return (m); +} + +/* * Returns the given page's successor (by pindex) within the object if it is * resident; if none is found, NULL is returned. * diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h index 54b9edd..c769a7b 100644 --- a/sys/vm/vm_page.h +++ b/sys/vm/vm_page.h @@ -345,6 +345,7 @@ int vm_page_try_to_cache (vm_page_t); int vm_page_try_to_free (vm_page_t); void vm_page_dontneed(vm_page_t); void vm_page_deactivate (vm_page_t); +vm_page_t vm_page_find_least(vm_object_t, vm_pindex_t); void vm_page_insert (vm_page_t, vm_object_t, vm_pindex_t); vm_page_t vm_page_lookup (vm_object_t, vm_pindex_t); vm_page_t vm_page_next(vm_page_t m); |