Date: Sun, 24 Mar 2013 16:43:08 +0000 (UTC) From: Alan Cox <alc@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248684 - head/sys/vm Message-ID: <201303241643.r2OGh86O044196@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: alc Date: Sun Mar 24 16:43:07 2013 New Revision: 248684 URL: http://svnweb.freebsd.org/changeset/base/248684 Log: 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 Modified: head/sys/vm/vm_radix.c Modified: head/sys/vm/vm_radix.c ============================================================================== --- head/sys/vm/vm_radix.c Sun Mar 24 16:41:23 2013 (r248683) +++ head/sys/vm/vm_radix.c Sun Mar 24 16:43:07 2013 (r248684) @@ -310,7 +310,9 @@ vm_radix_reclaim_allnodes_int(struct vm_ { 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_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, 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_radi 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201303241643.r2OGh86O044196>