summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2013-04-22 01:26:13 +0000
committeralc <alc@FreeBSD.org>2013-04-22 01:26:13 +0000
commit78339bf7f3a0cd62b1bcf122e6ca71e724ee1df9 (patch)
tree03018f70bdac68afc57149ded58e443775166c5e
parent136b9108c6d50b6ad751df685c7892070d641e2e (diff)
downloadFreeBSD-src-78339bf7f3a0cd62b1bcf122e6ca71e724ee1df9.zip
FreeBSD-src-78339bf7f3a0cd62b1bcf122e6ca71e724ee1df9.tar.gz
Simplify vm_radix_{add,dec}lev().
Sponsored by: EMC / Isilon Storage Division
-rw-r--r--sys/vm/vm_radix.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/sys/vm/vm_radix.c b/sys/vm/vm_radix.c
index 970bc66..10ecff3 100644
--- a/sys/vm/vm_radix.c
+++ b/sys/vm/vm_radix.c
@@ -265,16 +265,19 @@ vm_radix_keybarr(struct vm_radix_node *rnode, vm_pindex_t idx)
static __inline int
vm_radix_addlev(vm_pindex_t *idx, boolean_t *levels, uint16_t ilev)
{
- vm_pindex_t wrapidx;
for (; levels[ilev] == FALSE ||
vm_radix_slot(*idx, ilev) == (VM_RADIX_COUNT - 1); ilev--)
if (ilev == 0)
return (1);
- wrapidx = *idx;
+
+ /*
+ * The following computation cannot overflow because *idx's slot at
+ * ilev is less than VM_RADIX_COUNT - 1.
+ */
*idx = vm_radix_trimkey(*idx, ilev);
*idx += VM_RADIX_UNITLEVEL(ilev);
- return (*idx < wrapidx);
+ return (0);
}
/*
@@ -286,17 +289,19 @@ vm_radix_addlev(vm_pindex_t *idx, boolean_t *levels, uint16_t ilev)
static __inline int
vm_radix_declev(vm_pindex_t *idx, boolean_t *levels, uint16_t ilev)
{
- vm_pindex_t wrapidx;
for (; levels[ilev] == FALSE ||
vm_radix_slot(*idx, ilev) == 0; ilev--)
if (ilev == 0)
return (1);
- wrapidx = *idx;
+
+ /*
+ * The following computation cannot overflow because *idx's slot at
+ * ilev is greater than 0.
+ */
*idx = vm_radix_trimkey(*idx, ilev);
- *idx |= VM_RADIX_UNITLEVEL(ilev) - 1;
- *idx -= VM_RADIX_UNITLEVEL(ilev);
- return (*idx > wrapidx);
+ *idx -= 1;
+ return (0);
}
/*
OpenPOWER on IntegriCloud