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()
210 if (node->shift && xa_is_node(entry)) in xas_descend()
211 entry = XA_RETRY_ENTRY; in xas_descend()
215 return entry; in xas_descend()
219 * xas_load() - Load an entry from the XArray (advanced).
222 * Usually walks the @xas to the appropriate state to load the entry
226 * If the xa_state is set up to operate on a multi-index entry, xas_load()
227 * may return %NULL or an internal entry, even if there are entries
231 * Return: Usually an entry in the XArray, but see description for exceptions.
235 void *entry = xas_start(xas); in xas_load() local
237 while (xa_is_node(entry)) { in xas_load()
238 struct xa_node *node = xa_to_node(entry); in xas_load()
242 entry = xas_descend(xas, node); in xas_load()
246 return entry; in xas_load()
411 * in order to add the entry described by @xas. Because we cannot store a
412 * multi-index entry at index 0, the calculation is a little more complex
432 static unsigned long max_index(void *entry) in max_index() argument
434 if (!xa_is_node(entry)) in max_index()
436 return (XA_CHUNK_SIZE << xa_to_node(entry)->shift) - 1; in max_index()
445 void *entry; in xas_shrink() local
450 entry = xa_entry_locked(xa, node, 0); in xas_shrink()
451 if (!entry) in xas_shrink()
453 if (!xa_is_node(entry) && node->shift) in xas_shrink()
455 if (xa_is_zero(entry) && xa_zero_busy(xa)) in xas_shrink()
456 entry = NULL; in xas_shrink()
459 RCU_INIT_POINTER(xa->xa_head, entry); in xas_shrink()
465 if (!xa_is_node(entry)) in xas_shrink()
469 if (!xa_is_node(entry)) in xas_shrink()
471 node = xa_to_node(entry); in xas_shrink()
531 void *entry = xa_entry_locked(xas->xa, node, offset); in xas_free_nodes() local
533 if (node->shift && xa_is_node(entry)) { in xas_free_nodes()
534 node = xa_to_node(entry); in xas_free_nodes()
538 if (entry) in xas_free_nodes()
629 * xas_create() - Create a slot to store an entry in.
631 * @allow_root: %true if we can store the entry in the root directly
644 void *entry; in xas_create() local
651 entry = xa_head_locked(xa); in xas_create()
653 if (!entry && xa_zero_busy(xa)) in xas_create()
654 entry = XA_ZERO_ENTRY; in xas_create()
655 shift = xas_expand(xas, entry); in xas_create()
660 entry = xa_head_locked(xa); in xas_create()
668 entry = xa_entry_locked(xa, node, offset); in xas_create()
672 entry = xa_head_locked(xa); in xas_create()
678 if (!entry) { in xas_create()
685 } else if (xa_is_node(entry)) { in xas_create()
686 node = xa_to_node(entry); in xas_create()
690 entry = xas_descend(xas, node); in xas_create()
694 return entry; in xas_create()
765 * xas_store() - Store this entry in the XArray.
767 * @entry: New entry.
769 * If @xas is operating on a multi-index entry, the entry returned by this
770 * function is essentially meaningless (it may be an internal entry or it
775 * Return: The old entry at this index.
777 void *xas_store(struct xa_state *xas, void *entry) in xas_store() argument
785 bool value = xa_is_value(entry); in xas_store()
787 if (entry) { in xas_store()
788 bool allow_root = !xa_is_node(entry) && !xa_is_zero(entry); in xas_store()
799 if ((first == entry) && !xas->xa_sibs) in xas_store()
810 if (!entry) in xas_store()
815 * Must clear the marks before setting the entry to NULL, in xas_store()
816 * otherwise xas_for_each_marked may find a NULL entry and in xas_store()
819 * entry is set to NULL. in xas_store()
821 rcu_assign_pointer(*slot, entry); in xas_store()
826 count += !next - !entry; in xas_store()
828 if (entry) { in xas_store()
831 if (!xa_is_sibling(entry)) in xas_store()
832 entry = xa_mk_sibling(xas->xa_offset); in xas_store()
839 if (!entry && (offset > max)) in xas_store()
870 * xas_set_mark() - Sets the mark on this entry and its parents.
874 * Sets the specified mark on this entry, and walks up the tree setting it
876 * an entry, or is in an error state.
899 * xas_clear_mark() - Clears the mark on this entry and its parents.
903 * Clears the specified mark on this entry, and walks back to the head
905 * @xas has not been walked to an entry, or is in an error state.
931 * xas_init_marks() - Initialise all marks for the entry
934 * Initialise all marks for the entry specified by @xas. If we're tracking
992 * xas_split_alloc() - Allocate memory for splitting an entry.
994 * @entry: New entry which will be stored in the array.
995 * @order: Current entry order.
999 * If necessary, it will allocate new nodes (and fill them with @entry)
1000 * to prepare for the upcoming split of an entry of @order size into
1005 void xas_split_alloc(struct xa_state *xas, void *entry, unsigned int order, in xas_split_alloc() argument
1028 RCU_INIT_POINTER(node->slots[i], entry); in xas_split_alloc()
1046 * xas_split() - Split a multi-index entry into smaller entries.
1048 * @entry: New entry to store in the array.
1049 * @order: Current entry order.
1051 * The size of the new entries is set in @xas. The value in @entry is
1056 void xas_split(struct xa_state *xas, void *entry, unsigned int order) in xas_split() argument
1079 child->nr_values = xa_is_value(entry) ? in xas_split()
1092 rcu_assign_pointer(node->slots[canon], entry); in xas_split()
1096 values += (xa_is_value(entry) - xa_is_value(curr)) * in xas_split()
1113 * on an entry. Those users should call this function before they drop
1146 * __xas_prev() - Find the previous entry in the XArray.
1154 void *entry; in __xas_prev() local
1174 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in __xas_prev()
1175 if (!xa_is_node(entry)) in __xas_prev()
1176 return entry; in __xas_prev()
1178 xas->xa_node = xa_to_node(entry); in __xas_prev()
1185 * __xas_next() - Find the next entry in the XArray.
1193 void *entry; in __xas_next() local
1213 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in __xas_next()
1214 if (!xa_is_node(entry)) in __xas_next()
1215 return entry; in __xas_next()
1217 xas->xa_node = xa_to_node(entry); in __xas_next()
1224 * xas_find() - Find the next present entry in the XArray.
1228 * If the @xas has not yet been walked to an entry, return the entry
1229 * which has an index >= xas.xa_index. If it has been walked, the entry
1231 * next entry.
1233 * If no entry is found and the array is smaller than @max, the iterator
1237 * Return: The entry, if found, otherwise %NULL.
1241 void *entry; in xas_find() local
1252 entry = xas_load(xas); in xas_find()
1253 if (entry || xas_not_node(xas->xa_node)) in xas_find()
1254 return entry; in xas_find()
1269 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find()
1270 if (xa_is_node(entry)) { in xas_find()
1271 xas->xa_node = xa_to_node(entry); in xas_find()
1275 if (entry && !xa_is_sibling(entry)) in xas_find()
1276 return entry; in xas_find()
1288 * xas_find_marked() - Find the next marked entry in the XArray.
1293 * If the @xas has not yet been walked to an entry, return the marked entry
1294 * which has an index >= xas.xa_index. If it has been walked, the entry
1296 * first marked entry with an index > xas.xa_index.
1298 * If no marked entry is found and the array is smaller than @max, @xas is
1303 * If no entry is found before @max is reached, @xas is set to the restart
1306 * Return: The entry, if found, otherwise %NULL.
1312 void *entry; in xas_find_marked() local
1324 entry = xa_head(xas->xa); in xas_find_marked()
1326 if (xas->xa_index > max_index(entry)) in xas_find_marked()
1328 if (!xa_is_node(entry)) { in xas_find_marked()
1330 return entry; in xas_find_marked()
1334 xas->xa_node = xa_to_node(entry); in xas_find_marked()
1349 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find_marked()
1350 if (xa_is_sibling(entry)) { in xas_find_marked()
1351 xas->xa_offset = xa_to_sibling(entry); in xas_find_marked()
1368 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find_marked()
1369 if (!entry && !(xa_track_free(xas->xa) && mark == XA_FREE_MARK)) in xas_find_marked()
1371 if (!xa_is_node(entry)) in xas_find_marked()
1372 return entry; in xas_find_marked()
1373 xas->xa_node = xa_to_node(entry); in xas_find_marked()
1388 * xas_find_conflict() - Find the next present entry in a range.
1394 * Return: The next entry in the range covered by @xas or %NULL.
1449 * xa_load() - Load an entry from an XArray.
1454 * Return: The entry at @index in @xa.
1459 void *entry; in xa_load() local
1463 entry = xas_load(&xas); in xa_load()
1464 if (xa_is_zero(entry)) in xa_load()
1465 entry = NULL; in xa_load()
1466 } while (xas_retry(&xas, entry)); in xa_load()
1469 return entry; in xa_load()
1483 * __xa_erase() - Erase this entry from the XArray while locked.
1488 * If the index is part of a multi-index entry, all indices will be erased
1489 * and none of the entries will be part of a multi-index entry.
1491 * Context: Any context. Expects xa_lock to be held on entry.
1492 * Return: The entry which used to be at this index.
1502 * xa_erase() - Erase this entry from the XArray.
1504 * @index: Index of entry.
1507 * If the index is part of a multi-index entry, all indices will be erased
1508 * and none of the entries will be part of a multi-index entry.
1511 * Return: The entry which used to be at this index.
1515 void *entry; in xa_erase() local
1518 entry = __xa_erase(xa, index); in xa_erase()
1521 return entry; in xa_erase()
1526 * __xa_store() - Store this entry in the XArray.
1529 * @entry: New entry.
1536 * Context: Any context. Expects xa_lock to be held on entry. May
1538 * Return: The old entry at this index or xa_err() if an error happened.
1540 void *__xa_store(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in __xa_store() argument
1545 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_store()
1547 if (xa_track_free(xa) && !entry) in __xa_store()
1548 entry = XA_ZERO_ENTRY; in __xa_store()
1551 curr = xas_store(&xas, entry); in __xa_store()
1561 * xa_store() - Store this entry in the XArray.
1564 * @entry: New entry.
1567 * After this function returns, loads from this index will return @entry.
1568 * Storing into an existing multi-index entry updates the entry of every index.
1569 * The marks associated with @index are unaffected unless @entry is %NULL.
1573 * Return: The old entry at this index on success, xa_err(-EINVAL) if @entry
1577 void *xa_store(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in xa_store() argument
1582 curr = __xa_store(xa, index, entry, gfp); in xa_store()
1590 * __xa_cmpxchg() - Store this entry in the XArray.
1594 * @entry: New entry.
1601 * Context: Any context. Expects xa_lock to be held on entry. May
1603 * Return: The old entry at this index or xa_err() if an error happened.
1606 void *old, void *entry, gfp_t gfp) in __xa_cmpxchg() argument
1611 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_cmpxchg()
1617 xas_store(&xas, entry); in __xa_cmpxchg()
1618 if (xa_track_free(xa) && entry && !curr) in __xa_cmpxchg()
1628 * __xa_insert() - Store this entry in the XArray if no entry is present.
1631 * @entry: New entry.
1634 * Inserting a NULL entry will store a reserved entry (like xa_reserve())
1635 * if no entry is present. Inserting will fail if a reserved entry is
1638 * Context: Any context. Expects xa_lock to be held on entry. May
1640 * Return: 0 if the store succeeded. -EBUSY if another entry was present.
1643 int __xa_insert(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in __xa_insert() argument
1648 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_insert()
1650 if (!entry) in __xa_insert()
1651 entry = XA_ZERO_ENTRY; in __xa_insert()
1656 xas_store(&xas, entry); in __xa_insert()
1701 * xa_store_range() - Store this entry at a range of indices in the XArray.
1705 * @entry: New entry.
1709 * inclusive will return @entry.
1710 * Storing into an existing multi-index entry updates the entry of every index.
1711 * The marks associated with @index are unaffected unless @entry is %NULL.
1715 * Return: %NULL on success, xa_err(-EINVAL) if @entry cannot be stored in
1719 unsigned long last, void *entry, gfp_t gfp) in xa_store_range() argument
1723 if (WARN_ON_ONCE(xa_is_internal(entry))) in xa_store_range()
1730 if (entry) { in xa_store_range()
1741 xas_store(&xas, entry); in xa_store_range()
1755 * xa_get_order() - Get the order of an entry.
1757 * @index: Index of the entry.
1759 * Return: A number between 0 and 63 indicating the order of the entry.
1764 void *entry; in xa_get_order() local
1768 entry = xas_load(&xas); in xa_get_order()
1770 if (!entry) in xa_get_order()
1796 * __xa_alloc() - Find somewhere to store this entry in the XArray.
1800 * @entry: New entry.
1803 * Finds an empty entry in @xa between @limit.min and @limit.max,
1804 * stores the index into the @id pointer, then stores the entry at
1807 * Context: Any context. Expects xa_lock to be held on entry. May
1812 int __xa_alloc(struct xarray *xa, u32 *id, void *entry, in __xa_alloc() argument
1817 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_alloc()
1822 if (!entry) in __xa_alloc()
1823 entry = XA_ZERO_ENTRY; in __xa_alloc()
1832 xas_store(&xas, entry); in __xa_alloc()
1841 * __xa_alloc_cyclic() - Find somewhere to store this entry in the XArray.
1844 * @entry: New entry.
1849 * Finds an empty entry in @xa between @limit.min and @limit.max,
1850 * stores the index into the @id pointer, then stores the entry at
1852 * The search for an empty entry will start at @next and will wrap
1855 * Context: Any context. Expects xa_lock to be held on entry. May
1861 int __xa_alloc_cyclic(struct xarray *xa, u32 *id, void *entry, in __xa_alloc_cyclic() argument
1868 ret = __xa_alloc(xa, id, entry, limit, gfp); in __xa_alloc_cyclic()
1876 ret = __xa_alloc(xa, id, entry, limit, gfp); in __xa_alloc_cyclic()
1891 * __xa_set_mark() - Set this mark on this entry while locked.
1893 * @index: Index of entry.
1896 * Attempting to set a mark on a %NULL entry does not succeed.
1898 * Context: Any context. Expects xa_lock to be held on entry.
1903 void *entry = xas_load(&xas); in __xa_set_mark() local
1905 if (entry) in __xa_set_mark()
1911 * __xa_clear_mark() - Clear this mark on this entry while locked.
1913 * @index: Index of entry.
1916 * Context: Any context. Expects xa_lock to be held on entry.
1921 void *entry = xas_load(&xas); in __xa_clear_mark() local
1923 if (entry) in __xa_clear_mark()
1929 * xa_get_mark() - Inquire whether this mark is set on this entry.
1931 * @index: Index of entry.
1938 * Return: True if the entry at @index has this mark set, false if it doesn't.
1943 void *entry; in xa_get_mark() local
1946 entry = xas_start(&xas); in xa_get_mark()
1948 if (!xa_is_node(entry)) in xa_get_mark()
1950 entry = xas_descend(&xas, xa_to_node(entry)); in xa_get_mark()
1961 * xa_set_mark() - Set this mark on this entry.
1963 * @index: Index of entry.
1966 * Attempting to set a mark on a %NULL entry does not succeed.
1979 * xa_clear_mark() - Clear this mark on this entry.
1981 * @index: Index of entry.
1997 * xa_find() - Search the XArray for an entry.
2003 * Finds the entry in @xa which matches the @filter, and has the lowest
2005 * If an entry is found, @indexp is updated to be the index of the entry.
2011 * Return: The entry, if found, otherwise %NULL.
2017 void *entry; in xa_find() local
2022 entry = xas_find_marked(&xas, max, filter); in xa_find()
2024 entry = xas_find(&xas, max); in xa_find()
2025 } while (xas_retry(&xas, entry)); in xa_find()
2028 if (entry) in xa_find()
2030 return entry; in xa_find()
2047 * xa_find_after() - Search the XArray for a present entry.
2053 * Finds the entry in @xa which matches the @filter and has the lowest
2055 * If an entry is found, @indexp is updated to be the index of the entry.
2067 void *entry; in xa_find_after() local
2075 entry = xas_find_marked(&xas, max, filter); in xa_find_after()
2077 entry = xas_find(&xas, max); in xa_find_after()
2083 if (!xas_retry(&xas, entry)) in xa_find_after()
2088 if (entry) in xa_find_after()
2090 return entry; in xa_find_after()
2097 void *entry; in xas_extract_present() local
2101 xas_for_each(xas, entry, max) { in xas_extract_present()
2102 if (xas_retry(xas, entry)) in xas_extract_present()
2104 dst[i++] = entry; in xas_extract_present()
2116 void *entry; in xas_extract_marked() local
2120 xas_for_each_marked(xas, entry, max, mark) { in xas_extract_marked()
2121 if (xas_retry(xas, entry)) in xas_extract_marked()
2123 dst[i++] = entry; in xas_extract_marked()
2179 * Context: xa_lock must be held on entry and will not be released.
2211 void *entry; in xa_destroy() local
2215 entry = xa_head_locked(xa); in xa_destroy()
2221 if (xa_is_node(entry)) in xa_destroy()
2222 xas_free_nodes(&xas, xa_to_node(entry)); in xa_destroy()
2260 void xa_dump_entry(const void *entry, unsigned long index, unsigned long shift) in xa_dump_entry() argument
2262 if (!entry) in xa_dump_entry()
2267 if (xa_is_node(entry)) { in xa_dump_entry()
2269 pr_cont("%px\n", entry); in xa_dump_entry()
2272 struct xa_node *node = xa_to_node(entry); in xa_dump_entry()
2278 } else if (xa_is_value(entry)) in xa_dump_entry()
2279 pr_cont("value %ld (0x%lx) [%px]\n", xa_to_value(entry), in xa_dump_entry()
2280 xa_to_value(entry), entry); in xa_dump_entry()
2281 else if (!xa_is_internal(entry)) in xa_dump_entry()
2282 pr_cont("%px\n", entry); in xa_dump_entry()
2283 else if (xa_is_retry(entry)) in xa_dump_entry()
2284 pr_cont("retry (%ld)\n", xa_to_internal(entry)); in xa_dump_entry()
2285 else if (xa_is_sibling(entry)) in xa_dump_entry()
2286 pr_cont("sibling (slot %ld)\n", xa_to_sibling(entry)); in xa_dump_entry()
2287 else if (xa_is_zero(entry)) in xa_dump_entry()
2288 pr_cont("zero (%ld)\n", xa_to_internal(entry)); in xa_dump_entry()
2290 pr_cont("UNKNOWN ENTRY (%px)\n", entry); in xa_dump_entry()
2295 void *entry = xa->xa_head; in xa_dump() local
2298 pr_info("xarray: %px head %px flags %x marks %d %d %d\n", xa, entry, in xa_dump()
2301 if (xa_is_node(entry)) in xa_dump()
2302 shift = xa_to_node(entry)->shift + XA_CHUNK_SHIFT; in xa_dump()
2303 xa_dump_entry(entry, 0, shift); in xa_dump()