Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/vm_map.c
Context not available. | |||||
static inline void | static inline void | ||||
vm_map_entry_set_max_free(vm_map_entry_t entry) | vm_map_entry_set_max_free(vm_map_entry_t entry) | ||||
{ | { | ||||
vm_map_entry_t child; | vm_map_entry_t child; | ||||
vm_size_t max_left, max_right; | vm_size_t max_left, max_right; | ||||
kib: vm_map_maxfree_left, please honor the symbols namespace. | |||||
child = entry->left; | child = entry->left; | ||||
max_left = (child != NULL) ? child->max_free : | max_left = (child != NULL) ? child->max_free : | ||||
Done Inline ActionsThese functions operate on entries. Why has "entry_" been removed from the function name? alc: These functions operate on entries. Why has "entry_" been removed from the function name? | |||||
Done Inline ActionsBecause 80-character line limits and 8-space tabs make people desperate to avoid long names and nested loops. Neverthless, at the cost of wrapping 2 long lines, this has been changed. dougm: Because 80-character line limits and 8-space tabs make people desperate to avoid long names and… | |||||
entry->start - entry->prev->end; | entry->start - entry->prev->end; | ||||
child = entry->right; | child = entry->right; | ||||
Done Inline ActionsBlank line between functions definitions. kib: Blank line between functions definitions. | |||||
max_right = (child != NULL) ? child->max_free : | max_right = (child != NULL) ? child->max_free : | ||||
Done Inline Actionsnamespace. kib: namespace. | |||||
entry->next->start - entry->end; | entry->next->start - entry->end; | ||||
entry->max_free = MAX(max_left, max_right); | entry->max_free = MAX(max_left, max_right); | ||||
} | } | ||||
Done Inline Actionsvm_size_t, not size_t. alc: vm_size_t, not size_t. | |||||
#define SPLAY_LEFT_STEP(root, y, rlist, test) do { \ | #define SPLAY_LEFT_STEP(root, y, rlist, test) do { \ | ||||
y = root->left; \ | y = root->left; \ | ||||
if (y != NULL && (test)) { \ | if (y != NULL && (test)) { \ | ||||
Done Inline ActionsInsert blank line. alc: Insert blank line. | |||||
/* Rotate right and make y root. */ \ | /* Rotate right and make y root. */ \ | ||||
root->left = y->right; \ | root->left = y->right; \ | ||||
y->right = root; \ | y->right = root; \ | ||||
vm_map_entry_set_max_free(root); \ | if (root->max_free == y->max_free) \ | ||||
Done Inline ActionsDitto. alc: Ditto. | |||||
root = y; \ | vm_map_entry_set_max_free(root); \ | ||||
y = root->left; \ | root = y; \ | ||||
} \ | y = root->left; \ | ||||
Done Inline ActionsInsert blank line. alc: Insert blank line. | |||||
/* Put root on rlist. */ \ | } \ | ||||
root->left = rlist; \ | /* Put root on rlist. */ \ | ||||
rlist = root; \ | if (root->max_free == (y != NULL) ? \ | ||||
root = y; \ | y->max_free : root->start - root->prev->end) \ | ||||
root->max_free = 0; \ | |||||
root->left = rlist; \ | |||||
rlist = root; \ | |||||
root = y; \ | |||||
} while (0) | } while (0) | ||||
#define SPLAY_RIGHT_STEP(root, y, llist, test) do { \ | #define SPLAY_RIGHT_STEP(root, y, llist, test) do { \ | ||||
y = root->right; \ | y = root->right; \ | ||||
if (y != NULL && (test)) { \ | if (y != NULL && (test)) { \ | ||||
/* Rotate left and make y root. */ \ | /* Rotate left and make y root. */ \ | ||||
root->right = y->left; \ | root->right = y->left; \ | ||||
y->left = root; \ | y->left = root; \ | ||||
vm_map_entry_set_max_free(root); \ | if (root->max_free == y->max_free) \ | ||||
root = y; \ | vm_map_entry_set_max_free(root); \ | ||||
y = root->right; \ | root = y; \ | ||||
} \ | y = root->right; \ | ||||
/* Put root on llist. */ \ | } \ | ||||
root->right = llist; \ | /* Put root on llist. */ \ | ||||
llist = root; \ | if (root->max_free == (y != NULL) ? \ | ||||
root = y; \ | y->max_free : root->next->start - root->end) \ | ||||
root->max_free = 0; \ | |||||
root->right = llist; \ | |||||
llist = root; \ | |||||
root = y; \ | |||||
} while (0) | } while (0) | ||||
/* | /* | ||||
* Walk down the tree until we find addr or a NULL pointer where addr would go, | * Walk down the tree until we find addr or a NULL pointer where addr would go, | ||||
* breaking off left and right subtrees of nodes less than, or greater than | * breaking off left and right subtrees of nodes less than, or greater than | ||||
* addr. Treat pointers to nodes with max_free < length as NULL pointers. | * addr. Treat pointers to nodes with max_free < length as NULL pointers. | ||||
* llist and rlist are the two sides in reverse order (bottom-up), with llist | * llist and rlist are the two sides in reverse order (bottom-up), with llist | ||||
* linked by the right pointer and rlist linked by the left pointer in the | * linked by the right pointer and rlist linked by the left pointer in the | ||||
Show All 14 Lines | |||||
vm_map_entry_t llist, vm_map_entry_t rlist, | vm_map_entry_t llist, vm_map_entry_t rlist, | ||||
vm_map_entry_t ltree, vm_map_entry_t rtree) | vm_map_entry_t ltree, vm_map_entry_t rtree) | ||||
{ | { | ||||
vm_map_entry_t y; | vm_map_entry_t y; | ||||
while (llist != NULL) { | while (llist != NULL) { | ||||
y = llist->right; | y = llist->right; | ||||
llist->right = ltree; | llist->right = ltree; | ||||
vm_map_entry_set_max_free(llist); | if (llist->max_free == 0) | ||||
vm_map_entry_set_max_free(llist); | |||||
else | |||||
llist->max_free = MAX(llist->max_free, | |||||
((ltree != NULL) ? ltree->max_free : | |||||
llist->next->start - llist->end)); | |||||
ltree = llist; | ltree = llist; | ||||
llist = y; | llist = y; | ||||
} | } | ||||
while (rlist != NULL) { | while (rlist != NULL) { | ||||
y = rlist->left; | y = rlist->left; | ||||
rlist->left = rtree; | rlist->left = rtree; | ||||
vm_map_entry_set_max_free(rlist); | if (rlist->max_free == 0) | ||||
vm_map_entry_set_max_free(rlist); | |||||
else | |||||
rlist->max_free = MAX(rlist->max_free, | |||||
((rtree != NULL) ? rtree->max_free : | |||||
rlist->start - rlist->prev->end)); | |||||
rtree = rlist; | rtree = rlist; | ||||
rlist = y; | rlist = y; | ||||
} | } | ||||
/* | /* | ||||
* Final assembly: add ltree and rtree as subtrees of root. | * Final assembly: add ltree and rtree as subtrees of root. | ||||
*/ | */ | ||||
root->left = ltree; | root->left = ltree; | ||||
root->right = rtree; | root->right = rtree; | ||||
vm_map_entry_set_max_free(root); | vm_map_entry_set_max_free(root); | ||||
return (root); | return (root); | ||||
} | } | ||||
/* | /* | ||||
Done Inline ActionsWith this change, I would have expected the removal of entry_ from the function's name. In general, there is increasing inconsistency in the use of vm_map_entry_ versus vm_map_. alc: With this change, I would have expected the removal of entry_ from the function's name. In… | |||||
Context not available. | |||||
enum unlink_merge_type { | enum unlink_merge_type { | ||||
UNLINK_MERGE_PREV, | UNLINK_MERGE_PREV, | ||||
UNLINK_MERGE_NONE, | UNLINK_MERGE_NONE, | ||||
UNLINK_MERGE_NEXT | UNLINK_MERGE_NEXT | ||||
}; | }; | ||||
static void | static void | ||||
vm_map_entry_unlink(vm_map_t map, | vm_map_entry_unlink(vm_map_t map, | ||||
vm_map_entry_t entry, | vm_map_entry_t entry, | ||||
enum unlink_merge_type op) | enum unlink_merge_type op) | ||||
{ | { | ||||
vm_map_entry_t llist, rlist, root, y; | vm_map_entry_t llist, rlist, root, y; | ||||
VM_MAP_ASSERT_LOCKED(map); | VM_MAP_ASSERT_LOCKED(map); | ||||
llist = entry->prev; | |||||
rlist = entry->next; | |||||
llist->next = rlist; | |||||
rlist->prev = llist; | |||||
root = map->root; | root = map->root; | ||||
root = vm_map_splay_split(entry->start, 0, root, &llist, &rlist); | root = vm_map_splay_split(entry->start, 0, root, &llist, &rlist); | ||||
KASSERT(root != NULL, | KASSERT(root != NULL, | ||||
("vm_map_entry_unlink: unlink object not mapped")); | ("vm_map_entry_unlink: unlink object not mapped")); | ||||
Done Inline ActionsUnnecessary parentheses. alc: Unnecessary parentheses. | |||||
switch (op) { | switch (op) { | ||||
case UNLINK_MERGE_PREV: | case UNLINK_MERGE_PREV: | ||||
vm_map_splay_findprev(root, &llist); | vm_map_splay_findprev(root, &llist); | ||||
Done Inline ActionsIncorrect indentation. alc: Incorrect indentation. | |||||
llist->end = root->end; | llist->end = root->end; | ||||
y = root->right; | y = root->right; | ||||
root = llist; | root = llist; | ||||
llist = root->right; | llist = root->right; | ||||
root->right = y; | root->right = y; | ||||
break; | break; | ||||
case UNLINK_MERGE_NEXT: | case UNLINK_MERGE_NEXT: | ||||
Context not available. | |||||
if (llist != NULL) { | if (llist != NULL) { | ||||
root = llist; | root = llist; | ||||
llist = root->right; | llist = root->right; | ||||
root->right = NULL; | root->right = NULL; | ||||
} else if (rlist != NULL) { | } else if (rlist != NULL) { | ||||
root = rlist; | root = rlist; | ||||
rlist = root->left; | rlist = root->left; | ||||
root->left = NULL; | root->left = NULL; | ||||
} else | } else | ||||
root = NULL; | root = NULL; | ||||
break; | break; | ||||
} | } | ||||
if (root != NULL) | if (root != NULL) | ||||
root = vm_map_splay_merge(root, llist, rlist, | root = vm_map_splay_merge(root, llist, rlist, | ||||
root->left, root->right); | root->left, root->right); | ||||
if (llist == NULL) | |||||
llist = &map->header; | |||||
if (rlist == NULL) | |||||
rlist = &map->header; | |||||
llist->next = rlist; | |||||
rlist->prev = llist; | |||||
map->root = root; | map->root = root; | ||||
VM_MAP_ASSERT_CONSISTENT(map); | VM_MAP_ASSERT_CONSISTENT(map); | ||||
map->nentries--; | map->nentries--; | ||||
CTR3(KTR_VM, "vm_map_entry_unlink: map %p, nentries %d, entry %p", map, | CTR3(KTR_VM, "vm_map_entry_unlink: map %p, nentries %d, entry %p", map, | ||||
map->nentries, entry); | map->nentries, entry); | ||||
} | } | ||||
/* | /* | ||||
* vm_map_entry_resize_free: | * vm_map_entry_resize_free: | ||||
* | * | ||||
* Recompute the amount of free space following a modified vm_map_entry | * Recompute the amount of free space following a modified vm_map_entry | ||||
* and propagate those values up the tree. Call this function after | * and propagate those values up the tree. Call this function after | ||||
* resizing a map entry in-place by changing the end value, without a | * resizing a map entry in-place by changing the end value, without a | ||||
* call to vm_map_entry_link() or _unlink(). | * call to vm_map_entry_link() or _unlink(). | ||||
* | * | ||||
Context not available. |
vm_map_maxfree_left, please honor the symbols namespace.