summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2013-03-26 17:30:40 +0000
committeralc <alc@FreeBSD.org>2013-03-26 17:30:40 +0000
commitf90174984dfa403fec79de5662436acef243e0ab (patch)
tree28cdb920fa456610d40d337d1347ea7fcd4d2888
parentd7ec6be5b684d752ac5e1385e4f770ad20869888 (diff)
downloadFreeBSD-src-f90174984dfa403fec79de5662436acef243e0ab.zip
FreeBSD-src-f90174984dfa403fec79de5662436acef243e0ab.tar.gz
Introduce vm_radix_isleaf() and use it in a couple places. As compared to
using vm_radix_node_page() == NULL, the compiler is able to generate one less conditional branch when vm_radix_isleaf() is used. More use cases involving the inner loops of vm_radix_insert(), vm_radix_lookup{,_ge,_le}(), and vm_radix_remove() will follow. Reviewed by: attilio Sponsored by: EMC / Isilon Storage Division
-rw-r--r--sys/vm/vm_radix.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/sys/vm/vm_radix.c b/sys/vm/vm_radix.c
index 61eb61e..61e3a2b 100644
--- a/sys/vm/vm_radix.c
+++ b/sys/vm/vm_radix.c
@@ -189,6 +189,16 @@ vm_radix_setroot(struct vm_radix *rtree, struct vm_radix_node *rnode)
}
/*
+ * Returns TRUE if the specified radix node is a leaf and FALSE otherwise.
+ */
+static __inline boolean_t
+vm_radix_isleaf(struct vm_radix_node *rnode)
+{
+
+ return (((uintptr_t)rnode & VM_RADIX_ISLEAF) != 0);
+}
+
+/*
* Returns the associated page extracted from rnode if available,
* and NULL otherwise.
*/
@@ -315,7 +325,7 @@ vm_radix_reclaim_allnodes_int(struct vm_radix_node *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)
+ if (!vm_radix_isleaf(rnode->rn_child[slot]))
vm_radix_reclaim_allnodes_int(rnode->rn_child[slot]);
rnode->rn_child[slot] = NULL;
rnode->rn_count--;
@@ -454,7 +464,7 @@ vm_radix_insert(struct vm_radix *rtree, vm_page_t page)
__func__, clev, rnode->rn_clev));
slot = vm_radix_slot(index, rnode->rn_clev);
tmp = rnode->rn_child[slot];
- KASSERT(tmp != NULL && vm_radix_node_page(tmp) == NULL,
+ KASSERT(tmp != NULL && !vm_radix_isleaf(tmp),
("%s: unexpected lookup interruption", __func__));
if (tmp->rn_clev > clev)
break;
OpenPOWER on IntegriCloud