diff options
Diffstat (limited to 'sys/vm/vm_page.c')
-rw-r--r-- | sys/vm/vm_page.c | 25 |
1 files changed, 25 insertions, 0 deletions
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. * |