Lines Matching full:entry
22 * @index is the index of the entry being operated on
28 * @entry refers to something stored in a slot in the xarray
118 * xas_squash_marks() - Merge all marks to the first entry
121 * Set a mark on the first entry if any entry has it set. Clear marks on
181 void *entry; in xas_start() local
188 entry = xa_head(xas->xa); in xas_start()
189 if (!xa_is_node(entry)) { in xas_start()
193 if ((xas->xa_index >> xa_to_node(entry)->shift) > XA_CHUNK_MASK) in xas_start()
198 return entry; in xas_start()
204 void *entry = xa_entry(xas->xa, node, offset); in xas_descend() local
207 if (xa_is_sibling(entry)) { in xas_descend()
208 offset = xa_to_sibling(entry); in xas_descend()
209 entry = xa_entry(xas->xa, node, offset); in xas_descend()
213 return entry; in xas_descend()
217 * xas_load() - Load an entry from the XArray (advanced).
220 * Usually walks the @xas to the appropriate state to load the entry
224 * If the xa_state is set up to operate on a multi-index entry, xas_load()
225 * may return %NULL or an internal entry, even if there are entries
229 * Return: Usually an entry in the XArray, but see description for exceptions.
233 void *entry = xas_start(xas); in xas_load() local
235 while (xa_is_node(entry)) { in xas_load()
236 struct xa_node *node = xa_to_node(entry); in xas_load()
240 entry = xas_descend(xas, node); in xas_load()
244 return entry; in xas_load()
408 * in order to add the entry described by @xas. Because we cannot store a
409 * multi-index entry at index 0, the calculation is a little more complex
429 static unsigned long max_index(void *entry) in max_index() argument
431 if (!xa_is_node(entry)) in max_index()
433 return (XA_CHUNK_SIZE << xa_to_node(entry)->shift) - 1; in max_index()
442 void *entry; in xas_shrink() local
447 entry = xa_entry_locked(xa, node, 0); in xas_shrink()
448 if (!entry) in xas_shrink()
450 if (!xa_is_node(entry) && node->shift) in xas_shrink()
452 if (xa_is_zero(entry) && xa_zero_busy(xa)) in xas_shrink()
453 entry = NULL; in xas_shrink()
456 RCU_INIT_POINTER(xa->xa_head, entry); in xas_shrink()
462 if (!xa_is_node(entry)) in xas_shrink()
466 if (!xa_is_node(entry)) in xas_shrink()
468 node = xa_to_node(entry); in xas_shrink()
528 void *entry = xa_entry_locked(xas->xa, node, offset); in xas_free_nodes() local
530 if (node->shift && xa_is_node(entry)) { in xas_free_nodes()
531 node = xa_to_node(entry); in xas_free_nodes()
535 if (entry) in xas_free_nodes()
626 * xas_create() - Create a slot to store an entry in.
628 * @allow_root: %true if we can store the entry in the root directly
641 void *entry; in xas_create() local
648 entry = xa_head_locked(xa); in xas_create()
650 if (!entry && xa_zero_busy(xa)) in xas_create()
651 entry = XA_ZERO_ENTRY; in xas_create()
652 shift = xas_expand(xas, entry); in xas_create()
657 entry = xa_head_locked(xa); in xas_create()
665 entry = xa_entry_locked(xa, node, offset); in xas_create()
669 entry = xa_head_locked(xa); in xas_create()
675 if (!entry) { in xas_create()
682 } else if (xa_is_node(entry)) { in xas_create()
683 node = xa_to_node(entry); in xas_create()
687 entry = xas_descend(xas, node); in xas_create()
691 return entry; in xas_create()
760 * xas_store() - Store this entry in the XArray.
762 * @entry: New entry.
764 * If @xas is operating on a multi-index entry, the entry returned by this
765 * function is essentially meaningless (it may be an internal entry or it
770 * Return: The old entry at this index.
772 void *xas_store(struct xa_state *xas, void *entry) in xas_store() argument
780 bool value = xa_is_value(entry); in xas_store()
782 if (entry) { in xas_store()
783 bool allow_root = !xa_is_node(entry) && !xa_is_zero(entry); in xas_store()
794 if ((first == entry) && !xas->xa_sibs) in xas_store()
805 if (!entry) in xas_store()
810 * Must clear the marks before setting the entry to NULL, in xas_store()
811 * otherwise xas_for_each_marked may find a NULL entry and in xas_store()
814 * entry is set to NULL. in xas_store()
816 rcu_assign_pointer(*slot, entry); in xas_store()
821 count += !next - !entry; in xas_store()
823 if (entry) { in xas_store()
826 if (!xa_is_sibling(entry)) in xas_store()
827 entry = xa_mk_sibling(xas->xa_offset); in xas_store()
834 if (!entry && (offset > max)) in xas_store()
865 * xas_set_mark() - Sets the mark on this entry and its parents.
869 * Sets the specified mark on this entry, and walks up the tree setting it
871 * an entry, or is in an error state.
894 * xas_clear_mark() - Clears the mark on this entry and its parents.
898 * Clears the specified mark on this entry, and walks back to the head
900 * @xas has not been walked to an entry, or is in an error state.
926 * xas_init_marks() - Initialise all marks for the entry
929 * Initialise all marks for the entry specified by @xas. If we're tracking
987 * xas_split_alloc() - Allocate memory for splitting an entry.
989 * @entry: New entry which will be stored in the array.
990 * @order: New entry order.
994 * If necessary, it will allocate new nodes (and fill them with @entry)
995 * to prepare for the upcoming split of an entry of @order size into
1000 void xas_split_alloc(struct xa_state *xas, void *entry, unsigned int order, in xas_split_alloc() argument
1023 RCU_INIT_POINTER(node->slots[i], entry); in xas_split_alloc()
1041 * xas_split() - Split a multi-index entry into smaller entries.
1043 * @entry: New entry to store in the array.
1044 * @order: New entry order.
1046 * The value in the entry is copied to all the replacement entries.
1050 void xas_split(struct xa_state *xas, void *entry, unsigned int order) in xas_split() argument
1073 child->nr_values = xa_is_value(entry) ? in xas_split()
1085 rcu_assign_pointer(node->slots[canon], entry); in xas_split()
1089 values += (xa_is_value(entry) - xa_is_value(curr)) * in xas_split()
1105 * on an entry. Those users should call this function before they drop
1138 * __xas_prev() - Find the previous entry in the XArray.
1146 void *entry; in __xas_prev() local
1166 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in __xas_prev()
1167 if (!xa_is_node(entry)) in __xas_prev()
1168 return entry; in __xas_prev()
1170 xas->xa_node = xa_to_node(entry); in __xas_prev()
1177 * __xas_next() - Find the next entry in the XArray.
1185 void *entry; in __xas_next() local
1205 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in __xas_next()
1206 if (!xa_is_node(entry)) in __xas_next()
1207 return entry; in __xas_next()
1209 xas->xa_node = xa_to_node(entry); in __xas_next()
1216 * xas_find() - Find the next present entry in the XArray.
1220 * If the @xas has not yet been walked to an entry, return the entry
1221 * which has an index >= xas.xa_index. If it has been walked, the entry
1223 * next entry.
1225 * If no entry is found and the array is smaller than @max, the iterator
1229 * Return: The entry, if found, otherwise %NULL.
1233 void *entry; in xas_find() local
1244 entry = xas_load(xas); in xas_find()
1245 if (entry || xas_not_node(xas->xa_node)) in xas_find()
1246 return entry; in xas_find()
1261 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find()
1262 if (xa_is_node(entry)) { in xas_find()
1263 xas->xa_node = xa_to_node(entry); in xas_find()
1267 if (entry && !xa_is_sibling(entry)) in xas_find()
1268 return entry; in xas_find()
1280 * xas_find_marked() - Find the next marked entry in the XArray.
1285 * If the @xas has not yet been walked to an entry, return the marked entry
1286 * which has an index >= xas.xa_index. If it has been walked, the entry
1288 * first marked entry with an index > xas.xa_index.
1290 * If no marked entry is found and the array is smaller than @max, @xas is
1295 * If no entry is found before @max is reached, @xas is set to the restart
1298 * Return: The entry, if found, otherwise %NULL.
1304 void *entry; in xas_find_marked() local
1316 entry = xa_head(xas->xa); in xas_find_marked()
1318 if (xas->xa_index > max_index(entry)) in xas_find_marked()
1320 if (!xa_is_node(entry)) { in xas_find_marked()
1322 return entry; in xas_find_marked()
1326 xas->xa_node = xa_to_node(entry); in xas_find_marked()
1341 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find_marked()
1342 if (xa_is_sibling(entry)) { in xas_find_marked()
1343 xas->xa_offset = xa_to_sibling(entry); in xas_find_marked()
1360 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find_marked()
1361 if (!entry && !(xa_track_free(xas->xa) && mark == XA_FREE_MARK)) in xas_find_marked()
1363 if (!xa_is_node(entry)) in xas_find_marked()
1364 return entry; in xas_find_marked()
1365 xas->xa_node = xa_to_node(entry); in xas_find_marked()
1380 * xas_find_conflict() - Find the next present entry in a range.
1386 * Return: The next entry in the range covered by @xas or %NULL.
1441 * xa_load() - Load an entry from an XArray.
1446 * Return: The entry at @index in @xa.
1451 void *entry; in xa_load() local
1455 entry = xas_load(&xas); in xa_load()
1456 if (xa_is_zero(entry)) in xa_load()
1457 entry = NULL; in xa_load()
1458 } while (xas_retry(&xas, entry)); in xa_load()
1461 return entry; in xa_load()
1475 * __xa_erase() - Erase this entry from the XArray while locked.
1480 * If the index is part of a multi-index entry, all indices will be erased
1481 * and none of the entries will be part of a multi-index entry.
1483 * Context: Any context. Expects xa_lock to be held on entry.
1484 * Return: The entry which used to be at this index.
1494 * xa_erase() - Erase this entry from the XArray.
1496 * @index: Index of entry.
1499 * If the index is part of a multi-index entry, all indices will be erased
1500 * and none of the entries will be part of a multi-index entry.
1503 * Return: The entry which used to be at this index.
1507 void *entry; in xa_erase() local
1510 entry = __xa_erase(xa, index); in xa_erase()
1513 return entry; in xa_erase()
1518 * __xa_store() - Store this entry in the XArray.
1521 * @entry: New entry.
1528 * Context: Any context. Expects xa_lock to be held on entry. May
1530 * Return: The old entry at this index or xa_err() if an error happened.
1532 void *__xa_store(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in __xa_store() argument
1537 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_store()
1539 if (xa_track_free(xa) && !entry) in __xa_store()
1540 entry = XA_ZERO_ENTRY; in __xa_store()
1543 curr = xas_store(&xas, entry); in __xa_store()
1553 * xa_store() - Store this entry in the XArray.
1556 * @entry: New entry.
1559 * After this function returns, loads from this index will return @entry.
1560 * Storing into an existing multi-index entry updates the entry of every index.
1561 * The marks associated with @index are unaffected unless @entry is %NULL.
1565 * Return: The old entry at this index on success, xa_err(-EINVAL) if @entry
1569 void *xa_store(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in xa_store() argument
1574 curr = __xa_store(xa, index, entry, gfp); in xa_store()
1582 * __xa_cmpxchg() - Store this entry in the XArray.
1586 * @entry: New entry.
1593 * Context: Any context. Expects xa_lock to be held on entry. May
1595 * Return: The old entry at this index or xa_err() if an error happened.
1598 void *old, void *entry, gfp_t gfp) in __xa_cmpxchg() argument
1603 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_cmpxchg()
1609 xas_store(&xas, entry); in __xa_cmpxchg()
1610 if (xa_track_free(xa) && entry && !curr) in __xa_cmpxchg()
1620 * __xa_insert() - Store this entry in the XArray if no entry is present.
1623 * @entry: New entry.
1626 * Inserting a NULL entry will store a reserved entry (like xa_reserve())
1627 * if no entry is present. Inserting will fail if a reserved entry is
1630 * Context: Any context. Expects xa_lock to be held on entry. May
1632 * Return: 0 if the store succeeded. -EBUSY if another entry was present.
1635 int __xa_insert(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in __xa_insert() argument
1640 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_insert()
1642 if (!entry) in __xa_insert()
1643 entry = XA_ZERO_ENTRY; in __xa_insert()
1648 xas_store(&xas, entry); in __xa_insert()
1693 * xa_store_range() - Store this entry at a range of indices in the XArray.
1697 * @entry: New entry.
1701 * inclusive will return @entry.
1702 * Storing into an existing multi-index entry updates the entry of every index.
1703 * The marks associated with @index are unaffected unless @entry is %NULL.
1707 * Return: %NULL on success, xa_err(-EINVAL) if @entry cannot be stored in
1711 unsigned long last, void *entry, gfp_t gfp) in xa_store_range() argument
1715 if (WARN_ON_ONCE(xa_is_internal(entry))) in xa_store_range()
1722 if (entry) { in xa_store_range()
1733 xas_store(&xas, entry); in xa_store_range()
1747 * xa_get_order() - Get the order of an entry.
1749 * @index: Index of the entry.
1751 * Return: A number between 0 and 63 indicating the order of the entry.
1756 void *entry; in xa_get_order() local
1760 entry = xas_load(&xas); in xa_get_order()
1762 if (!entry) in xa_get_order()
1788 * __xa_alloc() - Find somewhere to store this entry in the XArray.
1792 * @entry: New entry.
1795 * Finds an empty entry in @xa between @limit.min and @limit.max,
1796 * stores the index into the @id pointer, then stores the entry at
1799 * Context: Any context. Expects xa_lock to be held on entry. May
1804 int __xa_alloc(struct xarray *xa, u32 *id, void *entry, in __xa_alloc() argument
1809 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_alloc()
1814 if (!entry) in __xa_alloc()
1815 entry = XA_ZERO_ENTRY; in __xa_alloc()
1824 xas_store(&xas, entry); in __xa_alloc()
1833 * __xa_alloc_cyclic() - Find somewhere to store this entry in the XArray.
1836 * @entry: New entry.
1841 * Finds an empty entry in @xa between @limit.min and @limit.max,
1842 * stores the index into the @id pointer, then stores the entry at
1844 * The search for an empty entry will start at @next and will wrap
1847 * Context: Any context. Expects xa_lock to be held on entry. May
1853 int __xa_alloc_cyclic(struct xarray *xa, u32 *id, void *entry, in __xa_alloc_cyclic() argument
1860 ret = __xa_alloc(xa, id, entry, limit, gfp); in __xa_alloc_cyclic()
1868 ret = __xa_alloc(xa, id, entry, limit, gfp); in __xa_alloc_cyclic()
1883 * __xa_set_mark() - Set this mark on this entry while locked.
1885 * @index: Index of entry.
1888 * Attempting to set a mark on a %NULL entry does not succeed.
1890 * Context: Any context. Expects xa_lock to be held on entry.
1895 void *entry = xas_load(&xas); in __xa_set_mark() local
1897 if (entry) in __xa_set_mark()
1903 * __xa_clear_mark() - Clear this mark on this entry while locked.
1905 * @index: Index of entry.
1908 * Context: Any context. Expects xa_lock to be held on entry.
1913 void *entry = xas_load(&xas); in __xa_clear_mark() local
1915 if (entry) in __xa_clear_mark()
1921 * xa_get_mark() - Inquire whether this mark is set on this entry.
1923 * @index: Index of entry.
1930 * Return: True if the entry at @index has this mark set, false if it doesn't.
1935 void *entry; in xa_get_mark() local
1938 entry = xas_start(&xas); in xa_get_mark()
1940 if (!xa_is_node(entry)) in xa_get_mark()
1942 entry = xas_descend(&xas, xa_to_node(entry)); in xa_get_mark()
1953 * xa_set_mark() - Set this mark on this entry.
1955 * @index: Index of entry.
1958 * Attempting to set a mark on a %NULL entry does not succeed.
1971 * xa_clear_mark() - Clear this mark on this entry.
1973 * @index: Index of entry.
1989 * xa_find() - Search the XArray for an entry.
1995 * Finds the entry in @xa which matches the @filter, and has the lowest
1997 * If an entry is found, @indexp is updated to be the index of the entry.
2003 * Return: The entry, if found, otherwise %NULL.
2009 void *entry; in xa_find() local
2014 entry = xas_find_marked(&xas, max, filter); in xa_find()
2016 entry = xas_find(&xas, max); in xa_find()
2017 } while (xas_retry(&xas, entry)); in xa_find()
2020 if (entry) in xa_find()
2022 return entry; in xa_find()
2039 * xa_find_after() - Search the XArray for a present entry.
2045 * Finds the entry in @xa which matches the @filter and has the lowest
2047 * If an entry is found, @indexp is updated to be the index of the entry.
2059 void *entry; in xa_find_after() local
2067 entry = xas_find_marked(&xas, max, filter); in xa_find_after()
2069 entry = xas_find(&xas, max); in xa_find_after()
2075 if (!xas_retry(&xas, entry)) in xa_find_after()
2080 if (entry) in xa_find_after()
2082 return entry; in xa_find_after()
2089 void *entry; in xas_extract_present() local
2093 xas_for_each(xas, entry, max) { in xas_extract_present()
2094 if (xas_retry(xas, entry)) in xas_extract_present()
2096 dst[i++] = entry; in xas_extract_present()
2108 void *entry; in xas_extract_marked() local
2112 xas_for_each_marked(xas, entry, max, mark) { in xas_extract_marked()
2113 if (xas_retry(xas, entry)) in xas_extract_marked()
2115 dst[i++] = entry; in xas_extract_marked()
2171 * Context: xa_lock must be held on entry and will not be released.
2203 void *entry; in xa_destroy() local
2207 entry = xa_head_locked(xa); in xa_destroy()
2213 if (xa_is_node(entry)) in xa_destroy()
2214 xas_free_nodes(&xas, xa_to_node(entry)); in xa_destroy()
2252 void xa_dump_entry(const void *entry, unsigned long index, unsigned long shift) in xa_dump_entry() argument
2254 if (!entry) in xa_dump_entry()
2259 if (xa_is_node(entry)) { in xa_dump_entry()
2261 pr_cont("%px\n", entry); in xa_dump_entry()
2264 struct xa_node *node = xa_to_node(entry); in xa_dump_entry()
2270 } else if (xa_is_value(entry)) in xa_dump_entry()
2271 pr_cont("value %ld (0x%lx) [%px]\n", xa_to_value(entry), in xa_dump_entry()
2272 xa_to_value(entry), entry); in xa_dump_entry()
2273 else if (!xa_is_internal(entry)) in xa_dump_entry()
2274 pr_cont("%px\n", entry); in xa_dump_entry()
2275 else if (xa_is_retry(entry)) in xa_dump_entry()
2276 pr_cont("retry (%ld)\n", xa_to_internal(entry)); in xa_dump_entry()
2277 else if (xa_is_sibling(entry)) in xa_dump_entry()
2278 pr_cont("sibling (slot %ld)\n", xa_to_sibling(entry)); in xa_dump_entry()
2279 else if (xa_is_zero(entry)) in xa_dump_entry()
2280 pr_cont("zero (%ld)\n", xa_to_internal(entry)); in xa_dump_entry()
2282 pr_cont("UNKNOWN ENTRY (%px)\n", entry); in xa_dump_entry()
2287 void *entry = xa->xa_head; in xa_dump() local
2290 pr_info("xarray: %px head %px flags %x marks %d %d %d\n", xa, entry, in xa_dump()
2293 if (xa_is_node(entry)) in xa_dump()
2294 shift = xa_to_node(entry)->shift + XA_CHUNK_SHIFT; in xa_dump()
2295 xa_dump_entry(entry, 0, shift); in xa_dump()