Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F150493897
D40585.id123465.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D40585.id123465.diff
View Options
Index: sys/kern/subr_pctrie.c
===================================================================
--- sys/kern/subr_pctrie.c
+++ sys/kern/subr_pctrie.c
@@ -54,6 +54,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
+#include <sys/libkern.h>
#include <sys/pctrie.h>
#include <sys/proc.h> /* smr.h depends on struct thread. */
#include <sys/smr.h>
@@ -259,21 +260,22 @@
}
/*
- * Returns the slot where two keys differ.
+ * Returns the level where two keys differ.
* It cannot accept 2 equal keys.
*/
static __inline uint16_t
pctrie_keydiff(uint64_t index1, uint64_t index2)
{
- uint16_t clev;
KASSERT(index1 != index2, ("%s: passing the same key value %jx",
__func__, (uintmax_t)index1));
+ CTASSERT(sizeof(long long) >= sizeof(uint64_t));
- index1 ^= index2;
- for (clev = PCTRIE_LIMIT;; clev--)
- if (pctrie_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) / PCTRIE_WIDTH);
}
/*
Index: sys/vm/vm_radix.c
===================================================================
--- sys/vm/vm_radix.c
+++ sys/vm/vm_radix.c
@@ -58,6 +58,7 @@
#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 @@
}
/*
- * 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);
}
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Apr 2, 5:01 PM (1 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30730643
Default Alt Text
D40585.id123465.diff (2 KB)
Attached To
Mode
D40585: radix_trie: eliminate iteration in keydiff
Attached
Detach File
Event Timeline
Log In to Comment