svn commit: r209896 - stable/8/sys/vm
Konstantin Belousov
kib at FreeBSD.org
Sun Jul 11 09:37:35 UTC 2010
Author: kib
Date: Sun Jul 11 09:37:34 2010
New Revision: 209896
URL: http://svn.freebsd.org/changeset/base/209896
Log:
MFC r209685:
Introduce a helper function vm_page_find_least(). Use it in several places,
which inline the function.
Modified:
stable/8/sys/vm/vm_map.c
stable/8/sys/vm/vm_object.c
stable/8/sys/vm/vm_page.c
stable/8/sys/vm/vm_page.h
Directory Properties:
stable/8/sys/ (props changed)
stable/8/sys/amd64/include/xen/ (props changed)
stable/8/sys/cddl/contrib/opensolaris/ (props changed)
stable/8/sys/contrib/dev/acpica/ (props changed)
stable/8/sys/contrib/pf/ (props changed)
stable/8/sys/dev/xen/xenpci/ (props changed)
Modified: stable/8/sys/vm/vm_map.c
==============================================================================
--- stable/8/sys/vm/vm_map.c Sun Jul 11 08:43:30 2010 (r209895)
+++ stable/8/sys/vm/vm_map.c Sun Jul 11 09:37:34 2010 (r209896)
@@ -1740,13 +1740,7 @@ vm_map_pmap_enter(vm_map_t map, vm_offse
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
Modified: stable/8/sys/vm/vm_object.c
==============================================================================
--- stable/8/sys/vm/vm_object.c Sun Jul 11 08:43:30 2010 (r209895)
+++ stable/8/sys/vm/vm_object.c Sun Jul 11 09:37:34 2010 (r209896)
@@ -1398,13 +1398,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);
vm_page_lock_queues();
for (; m != NULL && (idx = m->pindex - offidxstart) < size;
m = m_next) {
@@ -1909,13 +1903,7 @@ vm_object_page_remove(vm_object_t object
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);
vm_page_lock_queues();
/*
* Assert: the variable p is either (1) the page with the
Modified: stable/8/sys/vm/vm_page.c
==============================================================================
--- stable/8/sys/vm/vm_page.c Sun Jul 11 08:43:30 2010 (r209895)
+++ stable/8/sys/vm/vm_page.c Sun Jul 11 09:37:34 2010 (r209896)
@@ -786,6 +786,31 @@ vm_page_lookup(vm_object_t object, vm_pi
}
/*
+ * 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);
+}
+
+/*
* vm_page_rename:
*
* Move the given memory entry from its
Modified: stable/8/sys/vm/vm_page.h
==============================================================================
--- stable/8/sys/vm/vm_page.h Sun Jul 11 08:43:30 2010 (r209895)
+++ stable/8/sys/vm/vm_page.h Sun Jul 11 09:37:34 2010 (r209896)
@@ -312,6 +312,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);
void vm_page_remove (vm_page_t);
More information about the svn-src-all
mailing list