PERFORCE change 200662 for review
John Baldwin
jhb at FreeBSD.org
Mon Oct 24 18:41:50 UTC 2011
http://p4web.freebsd.org/@@200662?ac=10
Change 200662 by jhb at jhb_jhbbsd on 2011/10/24 18:40:59
Add a vm_object_page_cache() method which attempts to move clean
pages into the cache queue.
Affected files ...
.. //depot/projects/fadvise/sys/vm/vm_object.c#2 edit
.. //depot/projects/fadvise/sys/vm/vm_object.h#2 edit
Differences ...
==== //depot/projects/fadvise/sys/vm/vm_object.c#2 (text+ko) ====
@@ -1863,6 +1863,50 @@
}
/*
+ * vm_object_page_cache:
+ *
+ * For the given object, attempt to move the specified clean
+ * pages to the cache queue. If a page is wired for any reason,
+ * then it will not be changed. Pages are specified by the given
+ * range ["start", "end"). As a special case, if "end" is zero,
+ * then the range extends from "start" to the end of the object.
+ * Any mappings to the specified pages are removed before the
+ * pages are moved to the cache queue.
+ *
+ * This operation should only be performed on objects that
+ * contain managed pages.
+ *
+ * The object must be locked.
+ */
+void
+vm_object_page_cache(vm_object_t object, vm_pindex_t start, vm_pindex_t end)
+{
+ vm_page_t p, next;
+
+ VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
+ KASSERT((object->type != OBJT_DEVICE && object->type != OBJT_SG &&
+ object->type != OBJT_PHYS),
+ ("vm_object_page_cache: illegal object %p", object));
+ if (object->resident_page_count == 0)
+ return;
+ vm_object_pip_add(object, 1);
+ p = vm_page_find_least(object, start);
+
+ /*
+ * Here, the variable "p" is either (1) the page with the least pindex
+ * greater than or equal to the parameter "start" or (2) NULL.
+ */
+ for (; p != NULL && (p->pindex < end || end == 0); p = next) {
+ next = TAILQ_NEXT(p, listq);
+
+ vm_page_lock(p);
+ vm_page_try_to_cache(p);
+ vm_page_unlock(p);
+ }
+ vm_object_pip_wakeup(object);
+}
+
+/*
* Populate the specified range of the object with valid pages. Returns
* TRUE if the range is successfully populated and FALSE otherwise.
*
==== //depot/projects/fadvise/sys/vm/vm_object.h#2 (text+ko) ====
@@ -223,6 +223,8 @@
void vm_object_terminate (vm_object_t);
void vm_object_set_writeable_dirty (vm_object_t);
void vm_object_init (void);
+void vm_object_page_cache(vm_object_t object, vm_pindex_t start,
+ vm_pindex_t end);
void vm_object_page_clean(vm_object_t object, vm_ooffset_t start,
vm_ooffset_t end, int flags);
void vm_object_page_remove(vm_object_t object, vm_pindex_t start,
More information about the p4-projects
mailing list