Lines Matching +full:in +full:- +full:tree

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
40 * 00 - data pointer
41 * 10 - internal entry
42 * x1 - value entry
44 * The internal entry may be a pointer to the next level in the tree, a
45 * sibling entry, or an indicator that the entry in this slot has been moved
46 * to another location in the tree and the lookup should be restarted. While
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).
49 * This means that storing a NULL entry in the tree is the same as deleting
50 * the entry from the tree.
61 /*** radix-tree API starts here ***/
65 #define RADIX_TREE_MAP_MASK (RADIX_TREE_MAP_SIZE-1)
74 /* The IDR tag is stored in the low bits of xa_flags */
88 return root->xa_head == NULL; in radix_tree_empty()
92 * struct radix_tree_iter - radix tree iterator state
96 * @tags: bit-mask for tag-iterating
99 * This radix tree iterator works in terms of "chunks" of slots. A chunk is a
100 * subinterval of slots contained within one radix tree leaf node. It is
102 * which holds the chunk's position in the tree and its size. For tagged
103 * iteration radix_tree_iter also holds the slots' bit-mask for one chosen
104 * radix tree tag.
114 * Radix-tree synchronization
116 * The radix-tree API requires that users provide all synchronisation (with
119 * Synchronization of access to the data items being stored in the tree, and
122 * For API usage, in general,
123 * - any function _modifying_ the tree or tags (inserting or deleting
125 * exclude any functions reading the tree.
126 * - any function _reading_ the tree or tags (looking up items or tags,
127 * gang lookups) must exclude modifications to the tree, but may occur
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
149 * the radix tree *and* a synchronize_rcu() grace period).
152 * access to data items when inserting into or looking up from the radix tree)
157 * two consecutive reads in the same locked section may return different
165 * radix_tree_deref_slot - dereference a slot
168 * For use with radix_tree_lookup_slot(). Caller must hold tree at least read
175 * Return: entry stored in that slot.
183 * radix_tree_deref_slot_protected - dereference a slot with tree lock held
187 * lock but it must hold the tree lock to prevent parallel updates.
189 * Return: entry stored in that slot.
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.
268 RADIX_TREE_ITER_TAG_MASK = 0x0f, /* tag index in lower nybble */
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()
285 * in the case of a successful tagged chunk lookup. If the lookup was in radix_tree_iter_init()
286 * unsuccessful or non-tagged then nobody cares about ->tags. in radix_tree_iter_init()
289 * See the comment in radix_tree_next_chunk() for details. 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
299 * @root: radix tree root
304 * This function looks up the next chunk in the radix tree starting from
305 * @iter->next_index. It returns a pointer to the chunk's first slot.
306 * Also it fills @iter with data about chunk: position in the tree (index),
313 * radix_tree_iter_lookup - look up an index in the radix tree
314 * @root: radix tree root
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
334 * If we iterate over a tree protected only by the RCU lock, a race
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
367 * radix_tree_chunk_size - get current chunk size
369 * @iter: pointer to radix tree iterator
375 return iter->next_index - iter->index; in radix_tree_chunk_size()
379 * radix_tree_next_slot - find next slot in chunk
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
391 * radix_tree_iter_retry(). In these cases we don't end up dereferencing
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
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()
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()
420 while (--count > 0) { in radix_tree_next_slot()
422 iter->index = __radix_tree_iter_add(iter, 1); in radix_tree_next_slot()
428 iter->next_index = 0; in radix_tree_next_slot()
440 * radix_tree_for_each_slot - iterate over non-empty slots
447 * @slot points to radix tree slot, @iter->index contains its index.
455 * radix_tree_for_each_tagged - iterate over tagged slots
463 * @slot points to radix tree slot, @iter->index contains its index.