summaryrefslogtreecommitdiff
path: root/sys/uvm/uvm_map.c
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2016-08-11 01:17:34 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2016-08-11 01:17:34 +0000
commitcfaa9b58f5d7101d7ba8a7aa453f04b56c2c740e (patch)
treebc4bb1f89eb5c727db87cb9d3f3a8ae46431e37f /sys/uvm/uvm_map.c
parent2954c847da8dbdcafe77e2ea77534fecd6715541 (diff)
replace abuse of the static map entries RB_ENTRY pointers with an SLIST
free static entries are kept in a simple linked list, so use SLIST to make this obvious. the RB_PARENT manipulations are ugly and confusing. ok kettenis@
Diffstat (limited to 'sys/uvm/uvm_map.c')
-rw-r--r--sys/uvm/uvm_map.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/sys/uvm/uvm_map.c b/sys/uvm/uvm_map.c
index 41e63bddb96..afef0ba38cd 100644
--- a/sys/uvm/uvm_map.c
+++ b/sys/uvm/uvm_map.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_map.c,v 1.219 2016/07/30 16:43:44 kettenis Exp $ */
+/* $OpenBSD: uvm_map.c,v 1.220 2016/08/11 01:17:33 dlg Exp $ */
/* $NetBSD: uvm_map.c,v 1.86 2000/11/27 08:40:03 chs Exp $ */
/*
@@ -1669,25 +1669,23 @@ uvm_mapent_alloc(struct vm_map *map, int flags)
if (map->flags & VM_MAP_INTRSAFE || cold) {
mtx_enter(&uvm_kmapent_mtx);
- me = uvm.kentry_free;
- if (me == NULL) {
+ if (SLIST_EMPTY(&uvm.kentry_free)) {
ne = km_alloc(PAGE_SIZE, &kv_page, &kp_dirty,
&kd_nowait);
if (ne == NULL)
panic("uvm_mapent_alloc: cannot allocate map "
"entry");
- for (i = 0;
- i < PAGE_SIZE / sizeof(struct vm_map_entry) - 1;
- i++)
- RB_LEFT(&ne[i], daddrs.addr_entry) = &ne[i + 1];
- RB_LEFT(&ne[i], daddrs.addr_entry) = NULL;
- me = ne;
+ for (i = 0; i < PAGE_SIZE / sizeof(*ne); i++) {
+ SLIST_INSERT_HEAD(&uvm.kentry_free,
+ &ne[i], daddrs.addr_kentry);
+ }
if (ratecheck(&uvm_kmapent_last_warn_time,
&uvm_kmapent_warn_rate))
printf("uvm_mapent_alloc: out of static "
"map entries\n");
}
- uvm.kentry_free = RB_LEFT(me, daddrs.addr_entry);
+ me = SLIST_FIRST(&uvm.kentry_free);
+ SLIST_REMOVE_HEAD(&uvm.kentry_free, daddrs.addr_kentry);
uvmexp.kmapent++;
mtx_leave(&uvm_kmapent_mtx);
me->flags = UVM_MAP_STATIC;
@@ -1725,8 +1723,7 @@ uvm_mapent_free(struct vm_map_entry *me)
{
if (me->flags & UVM_MAP_STATIC) {
mtx_enter(&uvm_kmapent_mtx);
- RB_LEFT(me, daddrs.addr_entry) = uvm.kentry_free;
- uvm.kentry_free = me;
+ SLIST_INSERT_HEAD(&uvm.kentry_free, me, daddrs.addr_kentry);
uvmexp.kmapent--;
mtx_leave(&uvm_kmapent_mtx);
} else if (me->flags & UVM_MAP_KMEM) {
@@ -2795,11 +2792,10 @@ uvm_map_init(void)
/* now set up static pool of kernel map entries ... */
mtx_init(&uvm_kmapent_mtx, IPL_VM);
- uvm.kentry_free = NULL;
+ SLIST_INIT(&uvm.kentry_free);
for (lcv = 0 ; lcv < MAX_KMAPENT ; lcv++) {
- RB_LEFT(&kernel_map_entry[lcv], daddrs.addr_entry) =
- uvm.kentry_free;
- uvm.kentry_free = &kernel_map_entry[lcv];
+ SLIST_INSERT_HEAD(&uvm.kentry_free,
+ &kernel_map_entry[lcv], daddrs.addr_kentry);
}
/* initialize the map-related pools. */