Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F115944939
D50088.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D50088.diff
View Options
diff --git a/sys/kern/subr_pctrie.c b/sys/kern/subr_pctrie.c
--- a/sys/kern/subr_pctrie.c
+++ b/sys/kern/subr_pctrie.c
@@ -609,22 +609,19 @@
/*
* Returns the number of contiguous, non-NULL entries read into the value[]
- * array, without requiring an external lock. These entries *may* never have
- * been in the pctrie all at one time, but for a series of times t0, t1, t2,
- * ..., with ti <= t(i+1), value[i] was in the trie at time ti.
+ * array, starting at index.
*/
-int
-pctrie_lookup_range_unlocked(struct pctrie *ptree, uint64_t index,
- uint64_t *value[], int count, smr_t smr)
+static __always_inline int
+_pctrie_lookup_range(struct pctrie *ptree, uint64_t index, uint64_t *value[],
+ int count, smr_t smr, enum pctrie_access access)
{
struct pctrie_node *parent, *node;
int base, end, i;
parent = NULL;
- smr_enter(smr);
for (i = 0; i < count;) {
node = _pctrie_lookup_node(ptree, parent, index + i, &parent,
- smr, PCTRIE_SMR);
+ smr, access);
value[i] = pctrie_match_value(node, index + i);
if (value[i] == NULL)
break;
@@ -635,7 +632,7 @@
end = MIN(count, i + PCTRIE_COUNT - base);
while (i < end) {
node = pctrie_node_load(&parent->pn_child[base++],
- smr, PCTRIE_SMR);
+ smr, access);
value[i] = pctrie_toval(node);
if (value[i] == NULL)
break;
@@ -644,10 +641,41 @@
if (i < end)
break;
}
- smr_exit(smr);
return (i);
}
+/*
+ * Returns the number of contiguous, non-NULL entries read into the value[]
+ * array, starting at index, assuming access is externally synchronized by a
+ * lock.
+ */
+int
+pctrie_lookup_range(struct pctrie *ptree, uint64_t index,
+ uint64_t *value[], int count)
+{
+ return (_pctrie_lookup_range(ptree, index, value, count, NULL,
+ PCTRIE_LOCKED));
+}
+
+/*
+ * Returns the number of contiguous, non-NULL entries read into the value[]
+ * array, starting at index, without requiring an external lock. These entries
+ * *may* never have been in the pctrie all at one time, but for a series of
+ * times t0, t1, t2, ..., with ti <= t(i+1), value[i] was in the trie at time
+ * ti.
+ */
+int
+pctrie_lookup_range_unlocked(struct pctrie *ptree, uint64_t index,
+ uint64_t *value[], int count, smr_t smr)
+{
+ int res;
+
+ smr_enter(smr);
+ res = _pctrie_lookup_range(ptree, index, value, count, smr, PCTRIE_SMR);
+ smr_exit(smr);
+ return (res);
+}
+
/*
* Find first leaf >= index, and fill iter with the path to the parent of that
* leaf. Return NULL if there is no such leaf less than limit.
diff --git a/sys/sys/pctrie.h b/sys/sys/pctrie.h
--- a/sys/sys/pctrie.h
+++ b/sys/sys/pctrie.h
@@ -215,6 +215,18 @@
return name##_PCTRIE_VAL2PTR(pctrie_lookup(ptree, key)); \
} \
\
+static __inline __unused int \
+name##_PCTRIE_LOOKUP_RANGE(struct pctrie *ptree, uint64_t key, \
+ struct type *value[], int count) \
+{ \
+ uint64_t **data = (uint64_t **)value; \
+ \
+ count = pctrie_lookup_range(ptree, key, data, count); \
+ for (int i = 0; i < count; i++) \
+ value[i] = name##_PCTRIE_NZVAL2PTR(data[i]); \
+ return (count); \
+} \
+ \
static __inline __unused struct type * \
name##_PCTRIE_LOOKUP_LE(struct pctrie *ptree, uint64_t key) \
{ \
@@ -383,6 +395,8 @@
uint64_t *pctrie_lookup(struct pctrie *ptree, uint64_t key);
uint64_t *pctrie_lookup_unlocked(struct pctrie *ptree, uint64_t key,
smr_t smr);
+int pctrie_lookup_range(struct pctrie *ptree,
+ uint64_t index, uint64_t *value[], int count);
int pctrie_lookup_range_unlocked(struct pctrie *ptree,
uint64_t index, uint64_t *value[], int count, smr_t smr);
uint64_t *pctrie_iter_lookup(struct pctrie_iter *it, uint64_t index);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, May 1, 5:40 PM (6 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17887415
Default Alt Text
D50088.diff (3 KB)
Attached To
Mode
D50088: pctrie: add a locked pctrie_lookup_range
Attached
Detach File
Event Timeline
Log In to Comment