From owner-svn-src-head@FreeBSD.ORG Sun Mar 24 16:43:08 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 9B5A79AA; Sun, 24 Mar 2013 16:43:08 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 74AE8614; Sun, 24 Mar 2013 16:43:08 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2OGh8To044197; Sun, 24 Mar 2013 16:43:08 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2OGh86O044196; Sun, 24 Mar 2013 16:43:08 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201303241643.r2OGh86O044196@svn.freebsd.org> From: Alan Cox Date: Sun, 24 Mar 2013 16:43:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248684 - head/sys/vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Mar 2013 16:43:08 -0000 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