Reduce diffs against HEAD:
- Reimplement vm_page_cache_transfer() properly - Remove vm_page_cache_rename() as a subsequent change
This commit is contained in:
parent
62f53da2e7
commit
439c0b8cf1
@ -1302,7 +1302,7 @@ vm_object_split(vm_map_entry_t entry)
|
||||
{
|
||||
vm_page_t m, m_next;
|
||||
vm_object_t orig_object, new_object, source;
|
||||
vm_pindex_t idx, offidxstart, start;
|
||||
vm_pindex_t idx, offidxstart;
|
||||
vm_size_t size;
|
||||
|
||||
orig_object = entry->object.vm_object;
|
||||
@ -1413,18 +1413,9 @@ vm_object_split(vm_map_entry_t entry)
|
||||
* should still be OBJT_DEFAULT and orig_object should not
|
||||
* contain any cached pages within the specified range.
|
||||
*/
|
||||
if (!vm_object_cache_is_empty(orig_object)) {
|
||||
start = offidxstart;
|
||||
mtx_lock(&vm_page_queue_free_mtx);
|
||||
while ((m = vm_radix_lookup_ge(&orig_object->cache,
|
||||
start)) != NULL) {
|
||||
if (m->pindex >= (offidxstart + size))
|
||||
break;
|
||||
idx = m->pindex - offidxstart;
|
||||
vm_page_cache_rename(m, new_object, idx);
|
||||
}
|
||||
mtx_unlock(&vm_page_queue_free_mtx);
|
||||
}
|
||||
if (!vm_object_cache_is_empty(orig_object))
|
||||
vm_page_cache_transfer(orig_object, offidxstart,
|
||||
new_object);
|
||||
}
|
||||
VM_OBJECT_UNLOCK(orig_object);
|
||||
TAILQ_FOREACH(m, &new_object->memq, listq)
|
||||
|
@ -1064,23 +1064,45 @@ vm_page_cache_free(vm_page_t m)
|
||||
}
|
||||
|
||||
/*
|
||||
* Attempt to rename a cached page from one object to another. If
|
||||
* it fails the cached page is freed.
|
||||
* Transfer all of the cached pages with offset greater than or
|
||||
* equal to 'offidxstart' from the original object's cache to the
|
||||
* new object's cache. However, any cached pages with offset
|
||||
* greater than or equal to the new object's size are kept in the
|
||||
* original object. Initially, the new object's cache must be
|
||||
* empty. Offset 'offidxstart' in the original object must
|
||||
* correspond to offset zero in the new object.
|
||||
*
|
||||
* The new object must be locked.
|
||||
*/
|
||||
void
|
||||
vm_page_cache_rename(vm_page_t m, vm_object_t new_object, vm_pindex_t idx)
|
||||
vm_page_cache_transfer(vm_object_t orig_object, vm_pindex_t offidxstart,
|
||||
vm_object_t new_object)
|
||||
{
|
||||
vm_object_t orig_object;
|
||||
vm_page_t m;
|
||||
|
||||
orig_object = m->object;
|
||||
VM_OBJECT_LOCK_ASSERT(orig_object, MA_OWNED);
|
||||
/*
|
||||
* Insertion into an object's collection of cached pages
|
||||
* requires the object to be locked. In contrast, removal does
|
||||
* not.
|
||||
*/
|
||||
VM_OBJECT_LOCK_ASSERT(new_object, MA_OWNED);
|
||||
mtx_assert(&vm_page_queue_free_mtx, MA_OWNED);
|
||||
vm_radix_remove(&orig_object->cache, m->pindex);
|
||||
if (vm_radix_insert(&new_object->cache, idx, m) != 0)
|
||||
panic("vm_page_cache_rename: failed vm_radix_insert");
|
||||
m->object = new_object;
|
||||
m->pindex = idx;
|
||||
VM_OBJECT_LOCK_ASSERT(orig_object, MA_OWNED);
|
||||
KASSERT(vm_object_cache_is_empty(new_object),
|
||||
("vm_page_cache_transfer: object %p has cached pages",
|
||||
new_object));
|
||||
mtx_lock(&vm_page_queue_free_mtx);
|
||||
while ((m = vm_radix_lookup_ge(&orig_object->cache,
|
||||
offidxstart)) != NULL) {
|
||||
if ((m->pindex - offidxstart) >= new_object->size)
|
||||
break;
|
||||
vm_radix_remove(&orig_object->cache, m->pindex);
|
||||
if (vm_radix_insert(&new_object->cache,
|
||||
m->pindex - offidxstart, m) != 0)
|
||||
panic("vm_page_cache_transfer: failed vm_radix_insert");
|
||||
m->object = new_object;
|
||||
m->pindex -= offidxstart;
|
||||
}
|
||||
mtx_unlock(&vm_page_queue_free_mtx);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -376,8 +376,8 @@ vm_page_t vm_page_alloc_contig(vm_object_t object, vm_pindex_t pindex, int req,
|
||||
vm_page_t vm_page_alloc_freelist(int, int);
|
||||
vm_page_t vm_page_grab (vm_object_t, vm_pindex_t, int);
|
||||
void vm_page_cache(vm_page_t);
|
||||
void vm_page_cache_transfer(vm_object_t, vm_pindex_t, vm_object_t);
|
||||
void vm_page_cache_free(vm_page_t);
|
||||
void vm_page_cache_rename(vm_page_t, vm_object_t, vm_pindex_t);
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user