Lines Matching full:entry

24  * @index is the index of the entry being operated on
30 * @entry refers to something stored in a slot in the xarray
120 * xas_squash_marks() - Merge all marks to the first entry
123 * Set a mark on the first entry if any entry has it set. Clear marks on
183 void *entry; in xas_start() local
190 entry = xa_head(xas->xa); in xas_start()
191 if (!xa_is_node(entry)) { in xas_start()
195 if ((xas->xa_index >> xa_to_node(entry)->shift) > XA_CHUNK_MASK) in xas_start()
200 return entry; in xas_start()
206 void *entry = xa_entry(xas->xa, node, offset); in xas_descend() local
209 while (xa_is_sibling(entry)) { in xas_descend()
210 offset = xa_to_sibling(entry); in xas_descend()
211 entry = xa_entry(xas->xa, node, offset); in xas_descend()
212 if (node->shift && xa_is_node(entry)) in xas_descend()
213 entry = XA_RETRY_ENTRY; in xas_descend()
217 return entry; in xas_descend()
221 * xas_load() - Load an entry from the XArray (advanced).
224 * Usually walks the @xas to the appropriate state to load the entry
228 * If the xa_state is set up to operate on a multi-index entry, xas_load()
229 * may return %NULL or an internal entry, even if there are entries
233 * Return: Usually an entry in the XArray, but see description for exceptions.
237 void *entry = xas_start(xas); in xas_load() local
239 while (xa_is_node(entry)) { in xas_load()
240 struct xa_node *node = xa_to_node(entry); in xas_load()
244 entry = xas_descend(xas, node); in xas_load()
248 return entry; in xas_load()
409 * in order to add the entry described by @xas. Because we cannot store a
410 * multi-index entry at index 0, the calculation is a little more complex
430 static unsigned long max_index(void *entry) in max_index() argument
432 if (!xa_is_node(entry)) in max_index()
434 return (XA_CHUNK_SIZE << xa_to_node(entry)->shift) - 1; in max_index()
443 void *entry; in xas_shrink() local
448 entry = xa_entry_locked(xa, node, 0); in xas_shrink()
449 if (!entry) in xas_shrink()
451 if (!xa_is_node(entry) && node->shift) in xas_shrink()
453 if (xa_is_zero(entry) && xa_zero_busy(xa)) in xas_shrink()
454 entry = NULL; in xas_shrink()
457 RCU_INIT_POINTER(xa->xa_head, entry); in xas_shrink()
463 if (!xa_is_node(entry)) in xas_shrink()
467 if (!xa_is_node(entry)) in xas_shrink()
469 node = xa_to_node(entry); in xas_shrink()
529 void *entry = xa_entry_locked(xas->xa, node, offset); in xas_free_nodes() local
531 if (node->shift && xa_is_node(entry)) { in xas_free_nodes()
532 node = xa_to_node(entry); in xas_free_nodes()
536 if (entry) in xas_free_nodes()
627 * xas_create() - Create a slot to store an entry in.
629 * @allow_root: %true if we can store the entry in the root directly
642 void *entry; in xas_create() local
649 entry = xa_head_locked(xa); in xas_create()
651 if (!entry && xa_zero_busy(xa)) in xas_create()
652 entry = XA_ZERO_ENTRY; in xas_create()
653 shift = xas_expand(xas, entry); in xas_create()
658 entry = xa_head_locked(xa); in xas_create()
666 entry = xa_entry_locked(xa, node, offset); in xas_create()
670 entry = xa_head_locked(xa); in xas_create()
676 if (!entry) { in xas_create()
683 } else if (xa_is_node(entry)) { in xas_create()
684 node = xa_to_node(entry); in xas_create()
688 entry = xas_descend(xas, node); in xas_create()
692 return entry; in xas_create()
763 * xas_store() - Store this entry in the XArray.
765 * @entry: New entry.
767 * If @xas is operating on a multi-index entry, the entry returned by this
768 * function is essentially meaningless (it may be an internal entry or it
773 * Return: The old entry at this index.
775 void *xas_store(struct xa_state *xas, void *entry) in xas_store() argument
783 bool value = xa_is_value(entry); in xas_store()
785 if (entry) { in xas_store()
786 bool allow_root = !xa_is_node(entry) && !xa_is_zero(entry); in xas_store()
797 if ((first == entry) && !xas->xa_sibs) in xas_store()
808 if (!entry) in xas_store()
813 * Must clear the marks before setting the entry to NULL, in xas_store()
814 * otherwise xas_for_each_marked may find a NULL entry and in xas_store()
817 * entry is set to NULL. in xas_store()
819 rcu_assign_pointer(*slot, entry); in xas_store()
824 count += !next - !entry; in xas_store()
826 if (entry) { in xas_store()
829 if (!xa_is_sibling(entry)) in xas_store()
830 entry = xa_mk_sibling(xas->xa_offset); in xas_store()
837 if (!entry && (offset > max)) in xas_store()
868 * xas_set_mark() - Sets the mark on this entry and its parents.
872 * Sets the specified mark on this entry, and walks up the tree setting it
874 * an entry, or is in an error state.
897 * xas_clear_mark() - Clears the mark on this entry and its parents.
901 * Clears the specified mark on this entry, and walks back to the head
903 * @xas has not been walked to an entry, or is in an error state.
929 * xas_init_marks() - Initialise all marks for the entry
932 * Initialise all marks for the entry specified by @xas. If we're tracking
990 * xas_split_alloc() - Allocate memory for splitting an entry.
992 * @entry: New entry which will be stored in the array.
993 * @order: Current entry order.
997 * If necessary, it will allocate new nodes (and fill them with @entry)
998 * to prepare for the upcoming split of an entry of @order size into
1003 void xas_split_alloc(struct xa_state *xas, void *entry, unsigned int order, in xas_split_alloc() argument
1026 RCU_INIT_POINTER(node->slots[i], entry); in xas_split_alloc()
1044 * xas_split() - Split a multi-index entry into smaller entries.
1046 * @entry: New entry to store in the array.
1047 * @order: Current entry order.
1049 * The size of the new entries is set in @xas. The value in @entry is
1054 void xas_split(struct xa_state *xas, void *entry, unsigned int order) in xas_split() argument
1077 child->nr_values = xa_is_value(entry) ? in xas_split()
1090 rcu_assign_pointer(node->slots[canon], entry); in xas_split()
1094 values += (xa_is_value(entry) - xa_is_value(curr)) * in xas_split()
1111 * on an entry. Those users should call this function before they drop
1144 * __xas_prev() - Find the previous entry in the XArray.
1152 void *entry; in __xas_prev() local
1172 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in __xas_prev()
1173 if (!xa_is_node(entry)) in __xas_prev()
1174 return entry; in __xas_prev()
1176 xas->xa_node = xa_to_node(entry); in __xas_prev()
1183 * __xas_next() - Find the next entry in the XArray.
1191 void *entry; in __xas_next() local
1211 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in __xas_next()
1212 if (!xa_is_node(entry)) in __xas_next()
1213 return entry; in __xas_next()
1215 xas->xa_node = xa_to_node(entry); in __xas_next()
1222 * xas_find() - Find the next present entry in the XArray.
1226 * If the @xas has not yet been walked to an entry, return the entry
1227 * which has an index >= xas.xa_index. If it has been walked, the entry
1229 * next entry.
1231 * If no entry is found and the array is smaller than @max, the iterator
1235 * Return: The entry, if found, otherwise %NULL.
1239 void *entry; in xas_find() local
1250 entry = xas_load(xas); in xas_find()
1251 if (entry || xas_not_node(xas->xa_node)) in xas_find()
1252 return entry; in xas_find()
1267 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find()
1268 if (xa_is_node(entry)) { in xas_find()
1269 xas->xa_node = xa_to_node(entry); in xas_find()
1273 if (entry && !xa_is_sibling(entry)) in xas_find()
1274 return entry; in xas_find()
1286 * xas_find_marked() - Find the next marked entry in the XArray.
1291 * If the @xas has not yet been walked to an entry, return the marked entry
1292 * which has an index >= xas.xa_index. If it has been walked, the entry
1294 * first marked entry with an index > xas.xa_index.
1296 * If no marked entry is found and the array is smaller than @max, @xas is
1301 * If no entry is found before @max is reached, @xas is set to the restart
1304 * Return: The entry, if found, otherwise %NULL.
1310 void *entry; in xas_find_marked() local
1322 entry = xa_head(xas->xa); in xas_find_marked()
1324 if (xas->xa_index > max_index(entry)) in xas_find_marked()
1326 if (!xa_is_node(entry)) { in xas_find_marked()
1328 return entry; in xas_find_marked()
1332 xas->xa_node = xa_to_node(entry); in xas_find_marked()
1347 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find_marked()
1348 if (xa_is_sibling(entry)) { in xas_find_marked()
1349 xas->xa_offset = xa_to_sibling(entry); in xas_find_marked()
1366 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find_marked()
1367 if (!entry && !(xa_track_free(xas->xa) && mark == XA_FREE_MARK)) in xas_find_marked()
1369 if (!xa_is_node(entry)) in xas_find_marked()
1370 return entry; in xas_find_marked()
1371 xas->xa_node = xa_to_node(entry); in xas_find_marked()
1386 * xas_find_conflict() - Find the next present entry in a range.
1392 * Return: The next entry in the range covered by @xas or %NULL.
1447 * xa_load() - Load an entry from an XArray.
1452 * Return: The entry at @index in @xa.
1457 void *entry; in xa_load() local
1461 entry = xas_load(&xas); in xa_load()
1462 if (xa_is_zero(entry)) in xa_load()
1463 entry = NULL; in xa_load()
1464 } while (xas_retry(&xas, entry)); in xa_load()
1467 return entry; in xa_load()
1481 * __xa_erase() - Erase this entry from the XArray while locked.
1486 * If the index is part of a multi-index entry, all indices will be erased
1487 * and none of the entries will be part of a multi-index entry.
1489 * Context: Any context. Expects xa_lock to be held on entry.
1490 * Return: The entry which used to be at this index.
1500 * xa_erase() - Erase this entry from the XArray.
1502 * @index: Index of entry.
1505 * If the index is part of a multi-index entry, all indices will be erased
1506 * and none of the entries will be part of a multi-index entry.
1509 * Return: The entry which used to be at this index.
1513 void *entry; in xa_erase() local
1516 entry = __xa_erase(xa, index); in xa_erase()
1519 return entry; in xa_erase()
1524 * __xa_store() - Store this entry in the XArray.
1527 * @entry: New entry.
1534 * Context: Any context. Expects xa_lock to be held on entry. May
1536 * Return: The old entry at this index or xa_err() if an error happened.
1538 void *__xa_store(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in __xa_store() argument
1543 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_store()
1545 if (xa_track_free(xa) && !entry) in __xa_store()
1546 entry = XA_ZERO_ENTRY; in __xa_store()
1549 curr = xas_store(&xas, entry); in __xa_store()
1559 * xa_store() - Store this entry in the XArray.
1562 * @entry: New entry.
1565 * After this function returns, loads from this index will return @entry.
1566 * Storing into an existing multi-index entry updates the entry of every index.
1567 * The marks associated with @index are unaffected unless @entry is %NULL.
1571 * Return: The old entry at this index on success, xa_err(-EINVAL) if @entry
1575 void *xa_store(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in xa_store() argument
1580 curr = __xa_store(xa, index, entry, gfp); in xa_store()
1588 * __xa_cmpxchg() - Store this entry in the XArray.
1592 * @entry: New entry.
1599 * Context: Any context. Expects xa_lock to be held on entry. May
1601 * Return: The old entry at this index or xa_err() if an error happened.
1604 void *old, void *entry, gfp_t gfp) in __xa_cmpxchg() argument
1609 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_cmpxchg()
1615 xas_store(&xas, entry); in __xa_cmpxchg()
1616 if (xa_track_free(xa) && entry && !curr) in __xa_cmpxchg()
1626 * __xa_insert() - Store this entry in the XArray if no entry is present.
1629 * @entry: New entry.
1632 * Inserting a NULL entry will store a reserved entry (like xa_reserve())
1633 * if no entry is present. Inserting will fail if a reserved entry is
1636 * Context: Any context. Expects xa_lock to be held on entry. May
1638 * Return: 0 if the store succeeded. -EBUSY if another entry was present.
1641 int __xa_insert(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in __xa_insert() argument
1646 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_insert()
1648 if (!entry) in __xa_insert()
1649 entry = XA_ZERO_ENTRY; in __xa_insert()
1654 xas_store(&xas, entry); in __xa_insert()
1699 * xa_store_range() - Store this entry at a range of indices in the XArray.
1703 * @entry: New entry.
1707 * inclusive will return @entry.
1708 * Storing into an existing multi-index entry updates the entry of every index.
1709 * The marks associated with @index are unaffected unless @entry is %NULL.
1713 * Return: %NULL on success, xa_err(-EINVAL) if @entry cannot be stored in
1717 unsigned long last, void *entry, gfp_t gfp) in xa_store_range() argument
1721 if (WARN_ON_ONCE(xa_is_internal(entry))) in xa_store_range()
1728 if (entry) { in xa_store_range()
1739 xas_store(&xas, entry); in xa_store_range()
1753 * xa_get_order() - Get the order of an entry.
1755 * @index: Index of the entry.
1757 * Return: A number between 0 and 63 indicating the order of the entry.
1762 void *entry; in xa_get_order() local
1766 entry = xas_load(&xas); in xa_get_order()
1768 if (!entry) in xa_get_order()
1794 * __xa_alloc() - Find somewhere to store this entry in the XArray.
1798 * @entry: New entry.
1801 * Finds an empty entry in @xa between @limit.min and @limit.max,
1802 * stores the index into the @id pointer, then stores the entry at
1808 * Context: Any context. Expects xa_lock to be held on entry. May
1813 int __xa_alloc(struct xarray *xa, u32 *id, void *entry, in __xa_alloc() argument
1818 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_alloc()
1823 if (!entry) in __xa_alloc()
1824 entry = XA_ZERO_ENTRY; in __xa_alloc()
1833 xas_store(&xas, entry); in __xa_alloc()
1842 * __xa_alloc_cyclic() - Find somewhere to store this entry in the XArray.
1845 * @entry: New entry.
1850 * Finds an empty entry in @xa between @limit.min and @limit.max,
1851 * stores the index into the @id pointer, then stores the entry at
1853 * The search for an empty entry will start at @next and will wrap
1859 * Context: Any context. Expects xa_lock to be held on entry. May
1865 int __xa_alloc_cyclic(struct xarray *xa, u32 *id, void *entry, in __xa_alloc_cyclic() argument
1872 ret = __xa_alloc(xa, id, entry, limit, gfp); in __xa_alloc_cyclic()
1880 ret = __xa_alloc(xa, id, entry, limit, gfp); in __xa_alloc_cyclic()
1895 * __xa_set_mark() - Set this mark on this entry while locked.
1897 * @index: Index of entry.
1900 * Attempting to set a mark on a %NULL entry does not succeed.
1902 * Context: Any context. Expects xa_lock to be held on entry.
1907 void *entry = xas_load(&xas); in __xa_set_mark() local
1909 if (entry) in __xa_set_mark()
1915 * __xa_clear_mark() - Clear this mark on this entry while locked.
1917 * @index: Index of entry.
1920 * Context: Any context. Expects xa_lock to be held on entry.
1925 void *entry = xas_load(&xas); in __xa_clear_mark() local
1927 if (entry) in __xa_clear_mark()
1933 * xa_get_mark() - Inquire whether this mark is set on this entry.
1935 * @index: Index of entry.
1942 * Return: True if the entry at @index has this mark set, false if it doesn't.
1947 void *entry; in xa_get_mark() local
1950 entry = xas_start(&xas); in xa_get_mark()
1952 if (!xa_is_node(entry)) in xa_get_mark()
1954 entry = xas_descend(&xas, xa_to_node(entry)); in xa_get_mark()
1965 * xa_set_mark() - Set this mark on this entry.
1967 * @index: Index of entry.
1970 * Attempting to set a mark on a %NULL entry does not succeed.
1983 * xa_clear_mark() - Clear this mark on this entry.
1985 * @index: Index of entry.
2001 * xa_find() - Search the XArray for an entry.
2007 * Finds the entry in @xa which matches the @filter, and has the lowest
2009 * If an entry is found, @indexp is updated to be the index of the entry.
2015 * Return: The entry, if found, otherwise %NULL.
2021 void *entry; in xa_find() local
2026 entry = xas_find_marked(&xas, max, filter); in xa_find()
2028 entry = xas_find(&xas, max); in xa_find()
2029 } while (xas_retry(&xas, entry)); in xa_find()
2032 if (entry) in xa_find()
2034 return entry; in xa_find()
2051 * xa_find_after() - Search the XArray for a present entry.
2057 * Finds the entry in @xa which matches the @filter and has the lowest
2059 * If an entry is found, @indexp is updated to be the index of the entry.
2071 void *entry; in xa_find_after() local
2079 entry = xas_find_marked(&xas, max, filter); in xa_find_after()
2081 entry = xas_find(&xas, max); in xa_find_after()
2087 if (!xas_retry(&xas, entry)) in xa_find_after()
2092 if (entry) in xa_find_after()
2094 return entry; in xa_find_after()
2101 void *entry; in xas_extract_present() local
2105 xas_for_each(xas, entry, max) { in xas_extract_present()
2106 if (xas_retry(xas, entry)) in xas_extract_present()
2108 dst[i++] = entry; in xas_extract_present()
2120 void *entry; in xas_extract_marked() local
2124 xas_for_each_marked(xas, entry, max, mark) { in xas_extract_marked()
2125 if (xas_retry(xas, entry)) in xas_extract_marked()
2127 dst[i++] = entry; in xas_extract_marked()
2183 * Context: xa_lock must be held on entry and will not be released.
2215 void *entry; in xa_destroy() local
2219 entry = xa_head_locked(xa); in xa_destroy()
2225 if (xa_is_node(entry)) in xa_destroy()
2226 xas_free_nodes(&xas, xa_to_node(entry)); in xa_destroy()
2264 void xa_dump_entry(const void *entry, unsigned long index, unsigned long shift) in xa_dump_entry() argument
2266 if (!entry) in xa_dump_entry()
2271 if (xa_is_node(entry)) { in xa_dump_entry()
2273 pr_cont("%px\n", entry); in xa_dump_entry()
2276 struct xa_node *node = xa_to_node(entry); in xa_dump_entry()
2282 } else if (xa_is_value(entry)) in xa_dump_entry()
2283 pr_cont("value %ld (0x%lx) [%px]\n", xa_to_value(entry), in xa_dump_entry()
2284 xa_to_value(entry), entry); in xa_dump_entry()
2285 else if (!xa_is_internal(entry)) in xa_dump_entry()
2286 pr_cont("%px\n", entry); in xa_dump_entry()
2287 else if (xa_is_retry(entry)) in xa_dump_entry()
2288 pr_cont("retry (%ld)\n", xa_to_internal(entry)); in xa_dump_entry()
2289 else if (xa_is_sibling(entry)) in xa_dump_entry()
2290 pr_cont("sibling (slot %ld)\n", xa_to_sibling(entry)); in xa_dump_entry()
2291 else if (xa_is_zero(entry)) in xa_dump_entry()
2292 pr_cont("zero (%ld)\n", xa_to_internal(entry)); in xa_dump_entry()
2294 pr_cont("UNKNOWN ENTRY (%px)\n", entry); in xa_dump_entry()
2299 void *entry = xa->xa_head; in xa_dump() local
2302 pr_info("xarray: %px head %px flags %x marks %d %d %d\n", xa, entry, in xa_dump()
2305 if (xa_is_node(entry)) in xa_dump()
2306 shift = xa_to_node(entry)->shift + XA_CHUNK_SHIFT; in xa_dump()
2307 xa_dump_entry(entry, 0, shift); in xa_dump()