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()
762 * xas_store() - Store this entry in the XArray.
764 * @entry: New entry.
766 * If @xas is operating on a multi-index entry, the entry returned by this
767 * function is essentially meaningless (it may be an internal entry or it
772 * Return: The old entry at this index.
774 void *xas_store(struct xa_state *xas, void *entry) in xas_store() argument
782 bool value = xa_is_value(entry); in xas_store()
784 if (entry) { in xas_store()
785 bool allow_root = !xa_is_node(entry) && !xa_is_zero(entry); in xas_store()
796 if ((first == entry) && !xas->xa_sibs) in xas_store()
807 if (!entry) in xas_store()
812 * Must clear the marks before setting the entry to NULL, in xas_store()
813 * otherwise xas_for_each_marked may find a NULL entry and in xas_store()
816 * entry is set to NULL. in xas_store()
818 rcu_assign_pointer(*slot, entry); in xas_store()
823 count += !next - !entry; in xas_store()
825 if (entry) { in xas_store()
828 if (!xa_is_sibling(entry)) in xas_store()
829 entry = xa_mk_sibling(xas->xa_offset); in xas_store()
836 if (!entry && (offset > max)) in xas_store()
867 * xas_set_mark() - Sets the mark on this entry and its parents.
871 * Sets the specified mark on this entry, and walks up the tree setting it
873 * an entry, or is in an error state.
896 * xas_clear_mark() - Clears the mark on this entry and its parents.
900 * Clears the specified mark on this entry, and walks back to the head
902 * @xas has not been walked to an entry, or is in an error state.
928 * xas_init_marks() - Initialise all marks for the entry
931 * Initialise all marks for the entry specified by @xas. If we're tracking
989 * xas_split_alloc() - Allocate memory for splitting an entry.
991 * @entry: New entry which will be stored in the array.
992 * @order: New entry order.
996 * If necessary, it will allocate new nodes (and fill them with @entry)
997 * to prepare for the upcoming split of an entry of @order size into
1002 void xas_split_alloc(struct xa_state *xas, void *entry, unsigned int order, in xas_split_alloc() argument
1025 RCU_INIT_POINTER(node->slots[i], entry); in xas_split_alloc()
1043 * xas_split() - Split a multi-index entry into smaller entries.
1045 * @entry: New entry to store in the array.
1046 * @order: New entry order.
1048 * The value in the entry is copied to all the replacement entries.
1052 void xas_split(struct xa_state *xas, void *entry, unsigned int order) in xas_split() argument
1075 child->nr_values = xa_is_value(entry) ? in xas_split()
1088 rcu_assign_pointer(node->slots[canon], entry); in xas_split()
1092 values += (xa_is_value(entry) - xa_is_value(curr)) * in xas_split()
1109 * on an entry. Those users should call this function before they drop
1142 * __xas_prev() - Find the previous entry in the XArray.
1150 void *entry; in __xas_prev() local
1170 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in __xas_prev()
1171 if (!xa_is_node(entry)) in __xas_prev()
1172 return entry; in __xas_prev()
1174 xas->xa_node = xa_to_node(entry); in __xas_prev()
1181 * __xas_next() - Find the next entry in the XArray.
1189 void *entry; in __xas_next() local
1209 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in __xas_next()
1210 if (!xa_is_node(entry)) in __xas_next()
1211 return entry; in __xas_next()
1213 xas->xa_node = xa_to_node(entry); in __xas_next()
1220 * xas_find() - Find the next present entry in the XArray.
1224 * If the @xas has not yet been walked to an entry, return the entry
1225 * which has an index >= xas.xa_index. If it has been walked, the entry
1227 * next entry.
1229 * If no entry is found and the array is smaller than @max, the iterator
1233 * Return: The entry, if found, otherwise %NULL.
1237 void *entry; in xas_find() local
1248 entry = xas_load(xas); in xas_find()
1249 if (entry || xas_not_node(xas->xa_node)) in xas_find()
1250 return entry; in xas_find()
1265 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find()
1266 if (xa_is_node(entry)) { in xas_find()
1267 xas->xa_node = xa_to_node(entry); in xas_find()
1271 if (entry && !xa_is_sibling(entry)) in xas_find()
1272 return entry; in xas_find()
1284 * xas_find_marked() - Find the next marked entry in the XArray.
1289 * If the @xas has not yet been walked to an entry, return the marked entry
1290 * which has an index >= xas.xa_index. If it has been walked, the entry
1292 * first marked entry with an index > xas.xa_index.
1294 * If no marked entry is found and the array is smaller than @max, @xas is
1299 * If no entry is found before @max is reached, @xas is set to the restart
1302 * Return: The entry, if found, otherwise %NULL.
1308 void *entry; in xas_find_marked() local
1320 entry = xa_head(xas->xa); in xas_find_marked()
1322 if (xas->xa_index > max_index(entry)) in xas_find_marked()
1324 if (!xa_is_node(entry)) { in xas_find_marked()
1326 return entry; in xas_find_marked()
1330 xas->xa_node = xa_to_node(entry); in xas_find_marked()
1345 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find_marked()
1346 if (xa_is_sibling(entry)) { in xas_find_marked()
1347 xas->xa_offset = xa_to_sibling(entry); in xas_find_marked()
1364 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find_marked()
1365 if (!entry && !(xa_track_free(xas->xa) && mark == XA_FREE_MARK)) in xas_find_marked()
1367 if (!xa_is_node(entry)) in xas_find_marked()
1368 return entry; in xas_find_marked()
1369 xas->xa_node = xa_to_node(entry); in xas_find_marked()
1384 * xas_find_conflict() - Find the next present entry in a range.
1390 * Return: The next entry in the range covered by @xas or %NULL.
1445 * xa_load() - Load an entry from an XArray.
1450 * Return: The entry at @index in @xa.
1455 void *entry; in xa_load() local
1459 entry = xas_load(&xas); in xa_load()
1460 if (xa_is_zero(entry)) in xa_load()
1461 entry = NULL; in xa_load()
1462 } while (xas_retry(&xas, entry)); in xa_load()
1465 return entry; in xa_load()
1479 * __xa_erase() - Erase this entry from the XArray while locked.
1484 * If the index is part of a multi-index entry, all indices will be erased
1485 * and none of the entries will be part of a multi-index entry.
1487 * Context: Any context. Expects xa_lock to be held on entry.
1488 * Return: The entry which used to be at this index.
1498 * xa_erase() - Erase this entry from the XArray.
1500 * @index: Index of entry.
1503 * If the index is part of a multi-index entry, all indices will be erased
1504 * and none of the entries will be part of a multi-index entry.
1507 * Return: The entry which used to be at this index.
1511 void *entry; in xa_erase() local
1514 entry = __xa_erase(xa, index); in xa_erase()
1517 return entry; in xa_erase()
1522 * __xa_store() - Store this entry in the XArray.
1525 * @entry: New entry.
1532 * Context: Any context. Expects xa_lock to be held on entry. May
1534 * Return: The old entry at this index or xa_err() if an error happened.
1536 void *__xa_store(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in __xa_store() argument
1541 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_store()
1543 if (xa_track_free(xa) && !entry) in __xa_store()
1544 entry = XA_ZERO_ENTRY; in __xa_store()
1547 curr = xas_store(&xas, entry); in __xa_store()
1557 * xa_store() - Store this entry in the XArray.
1560 * @entry: New entry.
1563 * After this function returns, loads from this index will return @entry.
1564 * Storing into an existing multi-index entry updates the entry of every index.
1565 * The marks associated with @index are unaffected unless @entry is %NULL.
1569 * Return: The old entry at this index on success, xa_err(-EINVAL) if @entry
1573 void *xa_store(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in xa_store() argument
1578 curr = __xa_store(xa, index, entry, gfp); in xa_store()
1586 * __xa_cmpxchg() - Store this entry in the XArray.
1590 * @entry: New entry.
1597 * Context: Any context. Expects xa_lock to be held on entry. May
1599 * Return: The old entry at this index or xa_err() if an error happened.
1602 void *old, void *entry, gfp_t gfp) in __xa_cmpxchg() argument
1607 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_cmpxchg()
1613 xas_store(&xas, entry); in __xa_cmpxchg()
1614 if (xa_track_free(xa) && entry && !curr) in __xa_cmpxchg()
1624 * __xa_insert() - Store this entry in the XArray if no entry is present.
1627 * @entry: New entry.
1630 * Inserting a NULL entry will store a reserved entry (like xa_reserve())
1631 * if no entry is present. Inserting will fail if a reserved entry is
1634 * Context: Any context. Expects xa_lock to be held on entry. May
1636 * Return: 0 if the store succeeded. -EBUSY if another entry was present.
1639 int __xa_insert(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in __xa_insert() argument
1644 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_insert()
1646 if (!entry) in __xa_insert()
1647 entry = XA_ZERO_ENTRY; in __xa_insert()
1652 xas_store(&xas, entry); in __xa_insert()
1697 * xa_store_range() - Store this entry at a range of indices in the XArray.
1701 * @entry: New entry.
1705 * inclusive will return @entry.
1706 * Storing into an existing multi-index entry updates the entry of every index.
1707 * The marks associated with @index are unaffected unless @entry is %NULL.
1711 * Return: %NULL on success, xa_err(-EINVAL) if @entry cannot be stored in
1715 unsigned long last, void *entry, gfp_t gfp) in xa_store_range() argument
1719 if (WARN_ON_ONCE(xa_is_internal(entry))) in xa_store_range()
1726 if (entry) { in xa_store_range()
1737 xas_store(&xas, entry); in xa_store_range()
1751 * xa_get_order() - Get the order of an entry.
1753 * @index: Index of the entry.
1755 * Return: A number between 0 and 63 indicating the order of the entry.
1760 void *entry; in xa_get_order() local
1764 entry = xas_load(&xas); in xa_get_order()
1766 if (!entry) in xa_get_order()
1792 * __xa_alloc() - Find somewhere to store this entry in the XArray.
1796 * @entry: New entry.
1799 * Finds an empty entry in @xa between @limit.min and @limit.max,
1800 * stores the index into the @id pointer, then stores the entry at
1803 * Context: Any context. Expects xa_lock to be held on entry. May
1808 int __xa_alloc(struct xarray *xa, u32 *id, void *entry, in __xa_alloc() argument
1813 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_alloc()
1818 if (!entry) in __xa_alloc()
1819 entry = XA_ZERO_ENTRY; in __xa_alloc()
1828 xas_store(&xas, entry); in __xa_alloc()
1837 * __xa_alloc_cyclic() - Find somewhere to store this entry in the XArray.
1840 * @entry: New entry.
1845 * Finds an empty entry in @xa between @limit.min and @limit.max,
1846 * stores the index into the @id pointer, then stores the entry at
1848 * The search for an empty entry will start at @next and will wrap
1851 * Context: Any context. Expects xa_lock to be held on entry. May
1857 int __xa_alloc_cyclic(struct xarray *xa, u32 *id, void *entry, in __xa_alloc_cyclic() argument
1864 ret = __xa_alloc(xa, id, entry, limit, gfp); in __xa_alloc_cyclic()
1872 ret = __xa_alloc(xa, id, entry, limit, gfp); in __xa_alloc_cyclic()
1887 * __xa_set_mark() - Set this mark on this entry while locked.
1889 * @index: Index of entry.
1892 * Attempting to set a mark on a %NULL entry does not succeed.
1894 * Context: Any context. Expects xa_lock to be held on entry.
1899 void *entry = xas_load(&xas); in __xa_set_mark() local
1901 if (entry) in __xa_set_mark()
1907 * __xa_clear_mark() - Clear this mark on this entry while locked.
1909 * @index: Index of entry.
1912 * Context: Any context. Expects xa_lock to be held on entry.
1917 void *entry = xas_load(&xas); in __xa_clear_mark() local
1919 if (entry) in __xa_clear_mark()
1925 * xa_get_mark() - Inquire whether this mark is set on this entry.
1927 * @index: Index of entry.
1934 * Return: True if the entry at @index has this mark set, false if it doesn't.
1939 void *entry; in xa_get_mark() local
1942 entry = xas_start(&xas); in xa_get_mark()
1944 if (!xa_is_node(entry)) in xa_get_mark()
1946 entry = xas_descend(&xas, xa_to_node(entry)); in xa_get_mark()
1957 * xa_set_mark() - Set this mark on this entry.
1959 * @index: Index of entry.
1962 * Attempting to set a mark on a %NULL entry does not succeed.
1975 * xa_clear_mark() - Clear this mark on this entry.
1977 * @index: Index of entry.
1993 * xa_find() - Search the XArray for an entry.
1999 * Finds the entry in @xa which matches the @filter, and has the lowest
2001 * If an entry is found, @indexp is updated to be the index of the entry.
2007 * Return: The entry, if found, otherwise %NULL.
2013 void *entry; in xa_find() local
2018 entry = xas_find_marked(&xas, max, filter); in xa_find()
2020 entry = xas_find(&xas, max); in xa_find()
2021 } while (xas_retry(&xas, entry)); in xa_find()
2024 if (entry) in xa_find()
2026 return entry; in xa_find()
2043 * xa_find_after() - Search the XArray for a present entry.
2049 * Finds the entry in @xa which matches the @filter and has the lowest
2051 * If an entry is found, @indexp is updated to be the index of the entry.
2063 void *entry; in xa_find_after() local
2071 entry = xas_find_marked(&xas, max, filter); in xa_find_after()
2073 entry = xas_find(&xas, max); in xa_find_after()
2079 if (!xas_retry(&xas, entry)) in xa_find_after()
2084 if (entry) in xa_find_after()
2086 return entry; in xa_find_after()
2093 void *entry; in xas_extract_present() local
2097 xas_for_each(xas, entry, max) { in xas_extract_present()
2098 if (xas_retry(xas, entry)) in xas_extract_present()
2100 dst[i++] = entry; in xas_extract_present()
2112 void *entry; in xas_extract_marked() local
2116 xas_for_each_marked(xas, entry, max, mark) { in xas_extract_marked()
2117 if (xas_retry(xas, entry)) in xas_extract_marked()
2119 dst[i++] = entry; in xas_extract_marked()
2175 * Context: xa_lock must be held on entry and will not be released.
2207 void *entry; in xa_destroy() local
2211 entry = xa_head_locked(xa); in xa_destroy()
2217 if (xa_is_node(entry)) in xa_destroy()
2218 xas_free_nodes(&xas, xa_to_node(entry)); in xa_destroy()
2256 void xa_dump_entry(const void *entry, unsigned long index, unsigned long shift) in xa_dump_entry() argument
2258 if (!entry) in xa_dump_entry()
2263 if (xa_is_node(entry)) { in xa_dump_entry()
2265 pr_cont("%px\n", entry); in xa_dump_entry()
2268 struct xa_node *node = xa_to_node(entry); in xa_dump_entry()
2274 } else if (xa_is_value(entry)) in xa_dump_entry()
2275 pr_cont("value %ld (0x%lx) [%px]\n", xa_to_value(entry), in xa_dump_entry()
2276 xa_to_value(entry), entry); in xa_dump_entry()
2277 else if (!xa_is_internal(entry)) in xa_dump_entry()
2278 pr_cont("%px\n", entry); in xa_dump_entry()
2279 else if (xa_is_retry(entry)) in xa_dump_entry()
2280 pr_cont("retry (%ld)\n", xa_to_internal(entry)); in xa_dump_entry()
2281 else if (xa_is_sibling(entry)) in xa_dump_entry()
2282 pr_cont("sibling (slot %ld)\n", xa_to_sibling(entry)); in xa_dump_entry()
2283 else if (xa_is_zero(entry)) in xa_dump_entry()
2284 pr_cont("zero (%ld)\n", xa_to_internal(entry)); in xa_dump_entry()
2286 pr_cont("UNKNOWN ENTRY (%px)\n", entry); in xa_dump_entry()
2291 void *entry = xa->xa_head; in xa_dump() local
2294 pr_info("xarray: %px head %px flags %x marks %d %d %d\n", xa, entry, in xa_dump()
2297 if (xa_is_node(entry)) in xa_dump()
2298 shift = xa_to_node(entry)->shift + XA_CHUNK_SHIFT; in xa_dump()
2299 xa_dump_entry(entry, 0, shift); in xa_dump()