PERFORCE change 200834 for review
John Baldwin
jhb at FreeBSD.org
Thu Oct 27 17:37:01 UTC 2011
http://p4web.freebsd.org/@@200834?ac=10
Change 200834 by jhb at jhb_jhbbsd on 2011/10/27 17:36:23
Optimize vm page locking ala vm_unhold_pages().
Requested by: kib
Affected files ...
.. //depot/projects/fadvise/sys/vm/vm_object.c#4 edit
Differences ...
==== //depot/projects/fadvise/sys/vm/vm_object.c#4 (text+ko) ====
@@ -1881,6 +1881,7 @@
void
vm_object_page_cache(vm_object_t object, vm_pindex_t start, vm_pindex_t end)
{
+ struct mtx *mtx, *new_mtx;
vm_page_t p, next;
VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
@@ -1895,13 +1896,24 @@
* Here, the variable "p" is either (1) the page with the least pindex
* greater than or equal to the parameter "start" or (2) NULL.
*/
+ mtx = NULL;
for (; p != NULL && (p->pindex < end || end == 0); p = next) {
next = TAILQ_NEXT(p, listq);
- vm_page_lock(p);
+ /*
+ * Avoid releasing and reacquiring the same page lock.
+ */
+ new_mtx = vm_page_lockptr(p);
+ if (mtx != new_mtx) {
+ if (mtx != NULL)
+ mtx_unlock(mtx);
+ mtx = new_mtx;
+ mtx_lock(mtx);
+ }
vm_page_try_to_cache(p);
- vm_page_unlock(p);
}
+ if (mtx != NULL)
+ mtx_unlock(mtx);
}
/*
More information about the p4-projects
mailing list