diff options
author | alc <alc@FreeBSD.org> | 2013-03-24 16:43:07 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 2013-03-24 16:43:07 +0000 |
commit | 97049bb4f6b85544ab07ec3f5b2e34de78c69275 (patch) | |
tree | 4cfbd3768014def53ec0212aa8d9ef1e96de1044 | |
parent | 78b3d7cc921f0b8fd36b0a7cefdf4c1a56c60463 (diff) | |
download | FreeBSD-src-97049bb4f6b85544ab07ec3f5b2e34de78c69275.zip FreeBSD-src-97049bb4f6b85544ab07ec3f5b2e34de78c69275.tar.gz |
Micro-optimize the control flow in a few places. Eliminate a panic call
that could never be reached in vm_radix_insert(). (If the pointer being
checked by the panic call were ever NULL, the immmediately preceding loop
would have already crashed on a NULL pointer dereference.)
Reviewed by: attilio (an earlier version)
Sponsored by: EMC / Isilon Storage Division
-rw-r--r-- | sys/vm/vm_radix.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/sys/vm/vm_radix.c b/sys/vm/vm_radix.c index 3909b91..61eb61e 100644 --- a/sys/vm/vm_radix.c +++ b/sys/vm/vm_radix.c @@ -310,7 +310,9 @@ vm_radix_reclaim_allnodes_int(struct vm_radix_node *rnode) { int slot; - for (slot = 0; slot < VM_RADIX_COUNT && rnode->rn_count != 0; slot++) { + KASSERT(rnode->rn_count <= VM_RADIX_COUNT, + ("vm_radix_reclaim_allnodes_int: bad count in rnode %p", rnode)); + for (slot = 0; rnode->rn_count != 0; slot++) { if (rnode->rn_child[slot] == NULL) continue; if (vm_radix_node_page(rnode->rn_child[slot]) == NULL) @@ -414,9 +416,7 @@ vm_radix_insert(struct vm_radix *rtree, vm_page_t page) vm_radix_addpage(rnode, index, 0, page); return; } - while (rnode != NULL) { - if (vm_radix_keybarr(rnode, index)) - break; + do { slot = vm_radix_slot(index, rnode->rn_clev); m = vm_radix_node_page(rnode->rn_child[slot]); if (m != NULL) { @@ -437,9 +437,7 @@ vm_radix_insert(struct vm_radix *rtree, vm_page_t page) return; } rnode = rnode->rn_child[slot]; - } - if (rnode == NULL) - panic("%s: path traversal ended unexpectedly", __func__); + } while (!vm_radix_keybarr(rnode, index)); /* * Scan the trie from the top and find the parent to insert @@ -748,8 +746,8 @@ vm_radix_reclaim_allnodes(struct vm_radix *rtree) root = vm_radix_getroot(rtree); if (root == NULL) return; - vm_radix_reclaim_allnodes_int(root); vm_radix_setroot(rtree, NULL); + vm_radix_reclaim_allnodes_int(root); } #ifdef DDB |