aboutsummaryrefslogtreecommitdiff
path: root/sys/vm/vm_radix.c
diff options
context:
space:
mode:
authorDoug Moore <dougm@FreeBSD.org>2023-06-20 16:30:29 +0000
committerDoug Moore <dougm@FreeBSD.org>2023-06-20 16:30:29 +0000
commit05963ea4d130c39b332ae8b69414e8a894ca81e0 (patch)
tree8d0c66bb2b27fc1e81271ee748205e9f20e63201 /sys/vm/vm_radix.c
parentafb001df81b4f69a739ee0cead50f71309f03ebb (diff)
downloadsrc-05963ea4d130c39b332ae8b69414e8a894ca81e0.tar.gz
src-05963ea4d130c39b332ae8b69414e8a894ca81e0.zip
Diffstat (limited to 'sys/vm/vm_radix.c')
-rw-r--r--sys/vm/vm_radix.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/vm/vm_radix.c b/sys/vm/vm_radix.c
index 908bc4ec0bd1..836c3652c2c1 100644
--- a/sys/vm/vm_radix.c
+++ b/sys/vm/vm_radix.c
@@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
+#include <sys/libkern.h>
#include <sys/proc.h>
#include <sys/vmmeter.h>
#include <sys/smr.h>
@@ -285,21 +286,22 @@ vm_radix_addpage(struct vm_radix_node *rnode, vm_pindex_t index, uint16_t clev,
}
/*
- * Returns the slot where two keys differ.
+ * Returns the level where two keys differ.
* It cannot accept 2 equal keys.
*/
static __inline uint16_t
vm_radix_keydiff(vm_pindex_t index1, vm_pindex_t index2)
{
- uint16_t clev;
KASSERT(index1 != index2, ("%s: passing the same key value %jx",
__func__, (uintmax_t)index1));
+ CTASSERT(sizeof(long long) >= sizeof(vm_pindex_t));
- index1 ^= index2;
- for (clev = VM_RADIX_LIMIT;; clev--)
- if (vm_radix_slot(index1, clev) != 0)
- return (clev);
+ /*
+ * From the highest-order bit where the indexes differ,
+ * compute the highest level in the trie where they differ.
+ */
+ return ((flsll(index1 ^ index2) - 1) / VM_RADIX_WIDTH);
}
/*