|
NAMEvm_map_entry_resize_free —
vm map free space algorithm
SYNOPSIS#include <sys/param.h>
#include <vm/vm.h>
#include <vm/vm_map.h>
void
DESCRIPTIONThis manual page describes the vm_map_entry fields used in the VM map free space algorithm, how to maintain consistency of these variables, and thevm_map_entry_resize_free ()
function.
VM map entries are organized as both a doubly-linked list (prev and next pointers) and as a binary search tree (left and right pointers). The search tree is organized as a Sleator and Tarjan splay tree, also known as a “self-adjusting tree”. struct vm_map_entry { struct vm_map_entry *prev; struct vm_map_entry *next; struct vm_map_entry *left; struct vm_map_entry *right; vm_offset_t start; vm_offset_t end; vm_offset_t avail_ssize; vm_size_t adj_free; vm_size_t max_free; ... }; The free space algorithm adds two fields to struct vm_map_entry: adj_free and max_free. The adj_free field is the amount of free address space adjacent to and immediately following (higher address) the map entry. This field is unused in the map header. Note that adj_free depends on the linked list, not the splay tree and that adj_free can be computed as: entry->adj_free = (entry->next == &map->header ? map->max_offset : entry->next->start) - entry->end; The max_free field is the maximum amount of contiguous free space in the entry's subtree. Note that max_free depends on the splay tree, not the linked list and that max_free is computed by taking the maximum of its own adj_free and the max_free of its left and right subtrees. Again, max_free is unused in the map header. These fields allow for an
When a free region changes size, we must update
adj_free and max_free in the
preceding map entry and propagate max_free up the
tree. This is handled in The EXAMPLESConsider adding a map entry withvm_map_insert ().
ret = vm_map_insert(map, object, offset, start, end, prot, max_prot, cow); In this case, no further action is required to maintain
consistency of the free space variables. The
Now consider resizing an entry in-place without a call to
entry->start = new_start; if (entry->prev != &map->header) vm_map_entry_resize_free(map, entry->prev); In this case, resetting start changes the
amount of free space following the previous entry, so we use
Finally, suppose we change an entry's end address. entry->end = new_end; vm_map_entry_resize_free(map, entry); Here, we call SEE ALSOvm_map(9), vm_map_findspace(9)Daniel D. Sleator and Robert E. Tarjan, Self-Adjusting Binary Search Trees, JACM, vol. 32(3), pp. 652-686, July 1985. HISTORYSplay trees were added to the VM map in FreeBSD 5.0, and theO (log n) tree-based free
space algorithm was added in FreeBSD 5.3.
AUTHORSThe tree-based free space algorithm and this manual page were written by Mark W. Krentel <krentel@dreamscape.com>.
Visit the GSP FreeBSD Man Page Interface. |