Lines Matching +full:bypass +full:- +full:slot +full:- +full:no

1 /* SPDX-License-Identifier: GPL-2.0-or-later */
31 /* nodes->parent points to next preallocated node */
37 * The bottom two bits of the slot determine how the remaining bits in the
38 * slot are interpreted:
40 * 00 - data pointer
41 * 10 - internal entry
42 * x1 - value entry
45 * sibling entry, or an indicator that the entry in this slot has been moved
47 * NULL fits the 'data pointer' pattern, it means that there is no entry in
48 * the tree for this index (no matter what level of the tree it is found at).
61 /*** radix-tree API starts here ***/
65 #define RADIX_TREE_MAP_MASK (RADIX_TREE_MAP_SIZE-1)
88 return root->xa_head == NULL; in radix_tree_empty()
92 * struct radix_tree_iter - radix tree iterator state
94 * @index: index of current slot
96 * @tags: bit-mask for tag-iterating
97 * @node: node that contains current slot
101 * described by a pointer to its first slot and a struct radix_tree_iter
103 * iteration radix_tree_iter also holds the slots' bit-mask for one chosen
114 * Radix-tree synchronization
116 * The radix-tree API requires that users provide all synchronisation (with
123 * - any function _modifying_ the tree or tags (inserting or deleting
126 * - any function _reading_ the tree or tags (looking up items or tags,
142 * regions. Other readers (lock-free or otherwise) and modifications may be
146 * of the items. So if RCU lock-free lookups are used, typically this would mean
147 * that the items have their own locks, or are amenable to lock-free access; and
165 * radix_tree_deref_slot - dereference a slot
166 * @slot: slot pointer, returned by radix_tree_lookup_slot
169 * locked across slot lookup and dereference. Not required if write lock is
175 * Return: entry stored in that slot.
177 static inline void *radix_tree_deref_slot(void __rcu **slot) in radix_tree_deref_slot() argument
179 return rcu_dereference(*slot); in radix_tree_deref_slot()
183 * radix_tree_deref_slot_protected - dereference a slot with tree lock held
184 * @slot: slot pointer, returned by radix_tree_lookup_slot
189 * Return: entry stored in that slot.
191 static inline void *radix_tree_deref_slot_protected(void __rcu **slot, in radix_tree_deref_slot_protected() argument
194 return rcu_dereference_protected(*slot, lockdep_is_held(treelock)); in radix_tree_deref_slot_protected()
198 * radix_tree_deref_retry - check radix_tree_deref_slot
210 * radix_tree_exception - radix_tree_deref_slot returned either exception?
212 * Returns: 0 if well-aligned pointer, non-0 if either kind of exception.
227 void __rcu **slot, void *entry);
229 const struct radix_tree_iter *, void __rcu **slot, void *entry);
231 void __rcu **slot, void *entry);
233 struct radix_tree_iter *iter, void __rcu **slot);
274 * radix_tree_iter_init - initialize radix tree iterator
284 * Leave iter->tags uninitialized. radix_tree_next_chunk() will fill it in radix_tree_iter_init()
286 * unsuccessful or non-tagged then nobody cares about ->tags. in radix_tree_iter_init()
288 * Set index to zero to bypass next_index overflow protection. in radix_tree_iter_init()
291 iter->index = 0; in radix_tree_iter_init()
292 iter->next_index = start; in radix_tree_iter_init()
297 * radix_tree_next_chunk - find next chunk of slots for iteration
302 * Returns: pointer to chunk first slot, or NULL if there no more left
305 * @iter->next_index. It returns a pointer to the chunk's first slot.
313 * radix_tree_iter_lookup - look up an index in the radix tree
318 * If @index is present in the radix tree, this function returns the slot
331 * radix_tree_iter_retry - retry this chunk of the iteration
335 * against deletion or creation may result in seeing a slot for which
342 iter->next_index = iter->index; in radix_tree_iter_retry()
343 iter->tags = 0; in radix_tree_iter_retry()
350 return iter->index + slots; in __radix_tree_iter_add()
354 * radix_tree_iter_resume - resume iterating when the chunk may be invalid
355 * @slot: pointer to current slot
357 * Returns: New slot pointer
363 void __rcu **__must_check radix_tree_iter_resume(void __rcu **slot,
367 * radix_tree_chunk_size - get current chunk size
375 return iter->next_index - iter->index; in radix_tree_chunk_size()
379 * radix_tree_next_slot - find next slot in chunk
381 * @slot: pointer to current slot
384 * Returns: pointer to next slot, or NULL if there no more left
386 * This function updates @iter->index in the case of a successful lookup.
387 * For tagged lookup it also eats @iter->tags.
389 * There are several cases where 'slot' can be passed in as NULL to this
392 * 'slot' because either:
393 * a) we are doing tagged iteration and iter->tags has been set to 0, or
394 * b) we are doing non-tagged iteration, and iter->index and iter->next_index
397 static __always_inline void __rcu **radix_tree_next_slot(void __rcu **slot, in radix_tree_next_slot() argument
401 iter->tags >>= 1; in radix_tree_next_slot()
402 if (unlikely(!iter->tags)) in radix_tree_next_slot()
404 if (likely(iter->tags & 1ul)) { in radix_tree_next_slot()
405 iter->index = __radix_tree_iter_add(iter, 1); in radix_tree_next_slot()
406 slot++; in radix_tree_next_slot()
410 unsigned offset = __ffs(iter->tags); in radix_tree_next_slot()
412 iter->tags >>= offset++; in radix_tree_next_slot()
413 iter->index = __radix_tree_iter_add(iter, offset); in radix_tree_next_slot()
414 slot += offset; in radix_tree_next_slot()
420 while (--count > 0) { in radix_tree_next_slot()
421 slot++; in radix_tree_next_slot()
422 iter->index = __radix_tree_iter_add(iter, 1); in radix_tree_next_slot()
424 if (likely(*slot)) in radix_tree_next_slot()
428 iter->next_index = 0; in radix_tree_next_slot()
436 return slot; in radix_tree_next_slot()
440 * radix_tree_for_each_slot - iterate over non-empty slots
442 * @slot: the void** variable for pointer to slot
447 * @slot points to radix tree slot, @iter->index contains its index.
449 #define radix_tree_for_each_slot(slot, root, iter, start) \ argument
450 for (slot = radix_tree_iter_init(iter, start) ; \
451 slot || (slot = radix_tree_next_chunk(root, iter, 0)) ; \
452 slot = radix_tree_next_slot(slot, iter, 0))
455 * radix_tree_for_each_tagged - iterate over tagged slots
457 * @slot: the void** variable for pointer to slot
463 * @slot points to radix tree slot, @iter->index contains its index.
465 #define radix_tree_for_each_tagged(slot, root, iter, start, tag) \ argument
466 for (slot = radix_tree_iter_init(iter, start) ; \
467 slot || (slot = radix_tree_next_chunk(root, iter, \
469 slot = radix_tree_next_slot(slot, iter, \