Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107140331
D47829.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D47829.diff
View Options
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -1604,8 +1604,9 @@
continue;
}
- /* vm_page_rename() will dirty the page. */
- if (vm_page_rename(&pages, new_object, m->pindex - offidxstart)) {
+ /* vm_page_iter_rename() will dirty the page. */
+ if (!vm_page_iter_rename(&pages, m, new_object, m->pindex -
+ offidxstart)) {
vm_page_xunbusy(m);
VM_OBJECT_WUNLOCK(new_object);
VM_OBJECT_WUNLOCK(orig_object);
@@ -1789,9 +1790,10 @@
* backing object to the main object.
*
* If the page was mapped to a process, it can remain mapped
- * through the rename. vm_page_rename() will dirty the page.
+ * through the rename. vm_page_iter_rename() will dirty the
+ * page.
*/
- if (vm_page_rename(&pages, object, new_pindex)) {
+ if (!vm_page_iter_rename(&pages, p, object, new_pindex)) {
vm_page_xunbusy(p);
next = vm_object_collapse_scan_wait(&pages, object,
NULL);
diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h
--- a/sys/vm/vm_page.h
+++ b/sys/vm/vm_page.h
@@ -655,6 +655,8 @@
void vm_page_iter_limit_init(struct pctrie_iter *, vm_object_t, vm_pindex_t);
vm_page_t vm_page_iter_lookup(struct pctrie_iter *, vm_pindex_t);
bool vm_page_iter_remove(struct pctrie_iter *pages);
+bool vm_page_iter_rename(struct pctrie_iter *old_pages, vm_page_t m,
+ vm_object_t new_object, vm_pindex_t new_pindex);
void vm_page_launder(vm_page_t m);
vm_page_t vm_page_lookup(vm_object_t, vm_pindex_t);
vm_page_t vm_page_lookup_unlocked(vm_object_t, vm_pindex_t);
@@ -682,7 +684,6 @@
vm_page_t vm_page_relookup(vm_object_t, vm_pindex_t);
bool vm_page_remove(vm_page_t);
bool vm_page_remove_xbusy(vm_page_t);
-int vm_page_rename(struct pctrie_iter *, vm_object_t, vm_pindex_t);
void vm_page_replace(vm_page_t mnew, vm_object_t object,
vm_pindex_t pindex, vm_page_t mold);
int vm_page_sbusied(vm_page_t m);
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -2065,10 +2065,14 @@
}
/*
- * vm_page_rename:
+ * vm_page_iter_rename:
*
- * Move the current page, as identified by iterator, from its current
- * object to the specified target object/offset.
+ * Tries to move the specified page from its current object to a new object
+ * and pindex, using the given iterator to remove the page from its current
+ * object. Returns true if the move was successful, and false if the move
+ * was aborted due to a failed memory allocation.
+ *
+ * Panics if a page already resides in the new object at the new pindex.
*
* Note: swap associated with the page must be invalidated by the move. We
* have to do this for several reasons: (1) we aren't freeing the
@@ -2082,18 +2086,18 @@
*
* The objects must be locked.
*/
-int
-vm_page_rename(struct pctrie_iter *pages,
+bool
+vm_page_iter_rename(struct pctrie_iter *old_pages, vm_page_t m,
vm_object_t new_object, vm_pindex_t new_pindex)
{
- vm_page_t m, mpred;
+ vm_page_t mpred;
vm_pindex_t opidx;
+ KASSERT((m->ref_count & VPRC_OBJREF) != 0,
+ ("%s: page %p is missing object ref", __func__, m));
+ VM_OBJECT_ASSERT_WLOCKED(m->object);
VM_OBJECT_ASSERT_WLOCKED(new_object);
- m = vm_radix_iter_page(pages);
- KASSERT(m->ref_count != 0, ("vm_page_rename: page %p has no refs", m));
-
/*
* Create a custom version of vm_page_insert() which does not depend
* by m_prev and can cheat on the implementation aspects of the
@@ -2103,7 +2107,7 @@
m->pindex = new_pindex;
if (vm_radix_insert_lookup_lt(&new_object->rtree, m, &mpred) != 0) {
m->pindex = opidx;
- return (1);
+ return (false);
}
/*
@@ -2111,7 +2115,7 @@
* the listq iterator is tainted.
*/
m->pindex = opidx;
- vm_radix_iter_remove(pages);
+ vm_radix_iter_remove(old_pages);
vm_page_remove_radixdone(m);
/* Return back to the new pindex to complete vm_page_insert(). */
@@ -2121,7 +2125,7 @@
vm_page_insert_radixdone(m, new_object, mpred);
vm_page_dirty(m);
vm_pager_page_inserted(new_object, m);
- return (0);
+ return (true);
}
/*
diff --git a/sys/vm/vm_reserv.c b/sys/vm/vm_reserv.c
--- a/sys/vm/vm_reserv.c
+++ b/sys/vm/vm_reserv.c
@@ -678,7 +678,7 @@
if (pa < low || pa + size > high ||
!vm_addr_ok(pa, size, alignment, boundary))
goto out;
- /* Handle vm_page_rename(m, new_object, ...). */
+ /* Handle vm_page_iter_rename(..., m, new_object, ...). */
if (!bit_ntest(rv->popmap, index, index + npages - 1, 0))
goto out;
if (!vm_domain_allocate(vmd, req, npages))
@@ -847,7 +847,7 @@
vm_reserv_lock(rv);
/* Handle reclaim race. */
if (rv->object != object ||
- /* Handle vm_page_rename(m, new_object, ...). */
+ /* Handle vm_page_iter_rename(..., m, new_object, ...). */
bit_test(rv->popmap, index)) {
m = NULL;
goto out;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 11, 6:04 PM (2 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15756405
Default Alt Text
D47829.diff (4 KB)
Attached To
Mode
D47829: vm: Micro-optimize page rename
Attached
Detach File
Event Timeline
Log In to Comment