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()
207 void *entry = xa_entry(xas->xa, node, offset); in xas_descend() local
210 while (xa_is_sibling(entry)) { in xas_descend()
211 offset = xa_to_sibling(entry); in xas_descend()
212 entry = xa_entry(xas->xa, node, offset); in xas_descend()
213 if (node->shift && xa_is_node(entry)) in xas_descend()
214 entry = XA_RETRY_ENTRY; in xas_descend()
218 return entry; in xas_descend()
222 * xas_load() - Load an entry from the XArray (advanced).
225 * Usually walks the @xas to the appropriate state to load the entry
229 * If the xa_state is set up to operate on a multi-index entry, xas_load()
230 * may return %NULL or an internal entry, even if there are entries
234 * Return: Usually an entry in the XArray, but see description for exceptions.
238 void *entry = xas_start(xas); in xas_load() local
240 while (xa_is_node(entry)) { in xas_load()
241 struct xa_node *node = xa_to_node(entry); in xas_load()
245 entry = xas_descend(xas, node); in xas_load()
249 return entry; in xas_load()
410 * in order to add the entry described by @xas. Because we cannot store a
411 * multi-index entry at index 0, the calculation is a little more complex
431 static unsigned long max_index(void *entry) in max_index() argument
433 if (!xa_is_node(entry)) in max_index()
435 return (XA_CHUNK_SIZE << xa_to_node(entry)->shift) - 1; in max_index()
444 void *entry; in xas_shrink() local
449 entry = xa_entry_locked(xa, node, 0); in xas_shrink()
450 if (!entry) in xas_shrink()
452 if (!xa_is_node(entry) && node->shift) in xas_shrink()
454 if (xa_is_zero(entry) && xa_zero_busy(xa)) in xas_shrink()
455 entry = NULL; in xas_shrink()
458 RCU_INIT_POINTER(xa->xa_head, entry); in xas_shrink()
464 if (!xa_is_node(entry)) in xas_shrink()
468 if (!xa_is_node(entry)) in xas_shrink()
470 node = xa_to_node(entry); in xas_shrink()
530 void *entry = xa_entry_locked(xas->xa, node, offset); in xas_free_nodes() local
532 if (node->shift && xa_is_node(entry)) { in xas_free_nodes()
533 node = xa_to_node(entry); in xas_free_nodes()
537 if (entry) in xas_free_nodes()
628 * xas_create() - Create a slot to store an entry in.
630 * @allow_root: %true if we can store the entry in the root directly
643 void *entry; in xas_create() local
650 entry = xa_head_locked(xa); in xas_create()
652 if (!entry && xa_zero_busy(xa)) in xas_create()
653 entry = XA_ZERO_ENTRY; in xas_create()
654 shift = xas_expand(xas, entry); in xas_create()
659 entry = xa_head_locked(xa); in xas_create()
667 entry = xa_entry_locked(xa, node, offset); in xas_create()
671 entry = xa_head_locked(xa); in xas_create()
677 if (!entry) { in xas_create()
684 } else if (xa_is_node(entry)) { in xas_create()
685 node = xa_to_node(entry); in xas_create()
689 entry = xas_descend(xas, node); in xas_create()
693 return entry; in xas_create()
764 * xas_store() - Store this entry in the XArray.
766 * @entry: New entry.
768 * If @xas is operating on a multi-index entry, the entry returned by this
769 * function is essentially meaningless (it may be an internal entry or it
774 * Return: The old entry at this index.
776 void *xas_store(struct xa_state *xas, void *entry) in xas_store() argument
784 bool value = xa_is_value(entry); in xas_store()
786 if (entry) { in xas_store()
787 bool allow_root = !xa_is_node(entry) && !xa_is_zero(entry); in xas_store()
798 if ((first == entry) && !xas->xa_sibs) in xas_store()
809 if (!entry) in xas_store()
814 * Must clear the marks before setting the entry to NULL, in xas_store()
815 * otherwise xas_for_each_marked may find a NULL entry and in xas_store()
818 * entry is set to NULL. in xas_store()
820 rcu_assign_pointer(*slot, entry); in xas_store()
825 count += !next - !entry; in xas_store()
827 if (entry) { in xas_store()
830 if (!xa_is_sibling(entry)) in xas_store()
831 entry = xa_mk_sibling(xas->xa_offset); in xas_store()
838 if (!entry && (offset > max)) in xas_store()
869 * xas_set_mark() - Sets the mark on this entry and its parents.
873 * Sets the specified mark on this entry, and walks up the tree setting it
875 * an entry, or is in an error state.
898 * xas_clear_mark() - Clears the mark on this entry and its parents.
902 * Clears the specified mark on this entry, and walks back to the head
904 * @xas has not been walked to an entry, or is in an error state.
930 * xas_init_marks() - Initialise all marks for the entry
933 * Initialise all marks for the entry specified by @xas. If we're tracking
1005 * xas_split_alloc() - Allocate memory for splitting an entry.
1007 * @entry: New entry which will be stored in the array.
1008 * @order: Current entry order.
1012 * If necessary, it will allocate new nodes (and fill them with @entry)
1013 * to prepare for the upcoming split of an entry of @order size into
1018 void xas_split_alloc(struct xa_state *xas, void *entry, unsigned int order, in xas_split_alloc() argument
1041 RCU_INIT_POINTER(node->slots[i], entry); in xas_split_alloc()
1059 * xas_split() - Split a multi-index entry into smaller entries.
1061 * @entry: New entry to store in the array.
1062 * @order: Current entry order.
1064 * The size of the new entries is set in @xas. The value in @entry is
1069 void xas_split(struct xa_state *xas, void *entry, unsigned int order) in xas_split() argument
1092 child->nr_values = xa_is_value(entry) ? in xas_split()
1106 rcu_assign_pointer(node->slots[canon], entry); in xas_split()
1110 values += (xa_is_value(entry) - xa_is_value(curr)) * in xas_split()
1127 * on an entry. Those users should call this function before they drop
1160 * __xas_prev() - Find the previous entry in the XArray.
1168 void *entry; in __xas_prev() local
1188 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in __xas_prev()
1189 if (!xa_is_node(entry)) in __xas_prev()
1190 return entry; in __xas_prev()
1192 xas->xa_node = xa_to_node(entry); in __xas_prev()
1199 * __xas_next() - Find the next entry in the XArray.
1207 void *entry; in __xas_next() local
1227 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in __xas_next()
1228 if (!xa_is_node(entry)) in __xas_next()
1229 return entry; in __xas_next()
1231 xas->xa_node = xa_to_node(entry); in __xas_next()
1238 * xas_find() - Find the next present entry in the XArray.
1242 * If the @xas has not yet been walked to an entry, return the entry
1243 * which has an index >= xas.xa_index. If it has been walked, the entry
1245 * next entry.
1247 * If no entry is found and the array is smaller than @max, the iterator
1251 * Return: The entry, if found, otherwise %NULL.
1255 void *entry; in xas_find() local
1266 entry = xas_load(xas); in xas_find()
1267 if (entry || xas_not_node(xas->xa_node)) in xas_find()
1268 return entry; in xas_find()
1283 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find()
1284 if (xa_is_node(entry)) { in xas_find()
1285 xas->xa_node = xa_to_node(entry); in xas_find()
1289 if (entry && !xa_is_sibling(entry)) in xas_find()
1290 return entry; in xas_find()
1302 * xas_find_marked() - Find the next marked entry in the XArray.
1307 * If the @xas has not yet been walked to an entry, return the marked entry
1308 * which has an index >= xas.xa_index. If it has been walked, the entry
1310 * first marked entry with an index > xas.xa_index.
1312 * If no marked entry is found and the array is smaller than @max, @xas is
1317 * If no entry is found before @max is reached, @xas is set to the restart
1320 * Return: The entry, if found, otherwise %NULL.
1326 void *entry; in xas_find_marked() local
1338 entry = xa_head(xas->xa); in xas_find_marked()
1340 if (xas->xa_index > max_index(entry)) in xas_find_marked()
1342 if (!xa_is_node(entry)) { in xas_find_marked()
1344 return entry; in xas_find_marked()
1348 xas->xa_node = xa_to_node(entry); in xas_find_marked()
1363 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find_marked()
1364 if (xa_is_sibling(entry)) { in xas_find_marked()
1365 xas->xa_offset = xa_to_sibling(entry); in xas_find_marked()
1382 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find_marked()
1383 if (!entry && !(xa_track_free(xas->xa) && mark == XA_FREE_MARK)) in xas_find_marked()
1385 if (!xa_is_node(entry)) in xas_find_marked()
1386 return entry; in xas_find_marked()
1387 xas->xa_node = xa_to_node(entry); in xas_find_marked()
1402 * xas_find_conflict() - Find the next present entry in a range.
1408 * Return: The next entry in the range covered by @xas or %NULL.
1463 * xa_load() - Load an entry from an XArray.
1468 * Return: The entry at @index in @xa.
1473 void *entry; in xa_load() local
1477 entry = xas_load(&xas); in xa_load()
1478 if (xa_is_zero(entry)) in xa_load()
1479 entry = NULL; in xa_load()
1480 } while (xas_retry(&xas, entry)); in xa_load()
1483 return entry; in xa_load()
1497 * __xa_erase() - Erase this entry from the XArray while locked.
1502 * If the index is part of a multi-index entry, all indices will be erased
1503 * and none of the entries will be part of a multi-index entry.
1505 * Context: Any context. Expects xa_lock to be held on entry.
1506 * Return: The entry which used to be at this index.
1516 * xa_erase() - Erase this entry from the XArray.
1518 * @index: Index of entry.
1521 * If the index is part of a multi-index entry, all indices will be erased
1522 * and none of the entries will be part of a multi-index entry.
1525 * Return: The entry which used to be at this index.
1529 void *entry; in xa_erase() local
1532 entry = __xa_erase(xa, index); in xa_erase()
1535 return entry; in xa_erase()
1540 * __xa_store() - Store this entry in the XArray.
1543 * @entry: New entry.
1550 * Context: Any context. Expects xa_lock to be held on entry. May
1552 * Return: The old entry at this index or xa_err() if an error happened.
1554 void *__xa_store(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in __xa_store() argument
1559 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_store()
1561 if (xa_track_free(xa) && !entry) in __xa_store()
1562 entry = XA_ZERO_ENTRY; in __xa_store()
1565 curr = xas_store(&xas, entry); in __xa_store()
1575 * xa_store() - Store this entry in the XArray.
1578 * @entry: New entry.
1581 * After this function returns, loads from this index will return @entry.
1582 * Storing into an existing multi-index entry updates the entry of every index.
1583 * The marks associated with @index are unaffected unless @entry is %NULL.
1587 * Return: The old entry at this index on success, xa_err(-EINVAL) if @entry
1591 void *xa_store(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in xa_store() argument
1596 curr = __xa_store(xa, index, entry, gfp); in xa_store()
1604 * __xa_cmpxchg() - Store this entry in the XArray.
1608 * @entry: New entry.
1615 * Context: Any context. Expects xa_lock to be held on entry. May
1617 * Return: The old entry at this index or xa_err() if an error happened.
1620 void *old, void *entry, gfp_t gfp) in __xa_cmpxchg() argument
1625 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_cmpxchg()
1631 xas_store(&xas, entry); in __xa_cmpxchg()
1632 if (xa_track_free(xa) && entry && !curr) in __xa_cmpxchg()
1642 * __xa_insert() - Store this entry in the XArray if no entry is present.
1645 * @entry: New entry.
1648 * Inserting a NULL entry will store a reserved entry (like xa_reserve())
1649 * if no entry is present. Inserting will fail if a reserved entry is
1652 * Context: Any context. Expects xa_lock to be held on entry. May
1654 * Return: 0 if the store succeeded. -EBUSY if another entry was present.
1657 int __xa_insert(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in __xa_insert() argument
1662 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_insert()
1664 if (!entry) in __xa_insert()
1665 entry = XA_ZERO_ENTRY; in __xa_insert()
1670 xas_store(&xas, entry); in __xa_insert()
1715 * xa_store_range() - Store this entry at a range of indices in the XArray.
1719 * @entry: New entry.
1723 * inclusive will return @entry.
1724 * Storing into an existing multi-index entry updates the entry of every index.
1725 * The marks associated with @index are unaffected unless @entry is %NULL.
1729 * Return: %NULL on success, xa_err(-EINVAL) if @entry cannot be stored in
1733 unsigned long last, void *entry, gfp_t gfp) in xa_store_range() argument
1737 if (WARN_ON_ONCE(xa_is_internal(entry))) in xa_store_range()
1744 if (entry) { in xa_store_range()
1755 xas_store(&xas, entry); in xa_store_range()
1769 * xas_get_order() - Get the order of an entry.
1774 * Return: A number between 0 and 63 indicating the order of the entry.
1799 * xa_get_order() - Get the order of an entry.
1801 * @index: Index of the entry.
1803 * Return: A number between 0 and 63 indicating the order of the entry.
1809 void *entry; in xa_get_order() local
1812 entry = xas_load(&xas); in xa_get_order()
1813 if (entry) in xa_get_order()
1823 * __xa_alloc() - Find somewhere to store this entry in the XArray.
1827 * @entry: New entry.
1830 * Finds an empty entry in @xa between @limit.min and @limit.max,
1831 * stores the index into the @id pointer, then stores the entry at
1837 * Context: Any context. Expects xa_lock to be held on entry. May
1842 int __xa_alloc(struct xarray *xa, u32 *id, void *entry, in __xa_alloc() argument
1847 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_alloc()
1852 if (!entry) in __xa_alloc()
1853 entry = XA_ZERO_ENTRY; in __xa_alloc()
1862 xas_store(&xas, entry); in __xa_alloc()
1871 * __xa_alloc_cyclic() - Find somewhere to store this entry in the XArray.
1874 * @entry: New entry.
1879 * Finds an empty entry in @xa between @limit.min and @limit.max,
1880 * stores the index into the @id pointer, then stores the entry at
1882 * The search for an empty entry will start at @next and will wrap
1888 * Context: Any context. Expects xa_lock to be held on entry. May
1894 int __xa_alloc_cyclic(struct xarray *xa, u32 *id, void *entry, in __xa_alloc_cyclic() argument
1901 ret = __xa_alloc(xa, id, entry, limit, gfp); in __xa_alloc_cyclic()
1909 ret = __xa_alloc(xa, id, entry, limit, gfp); in __xa_alloc_cyclic()
1924 * __xa_set_mark() - Set this mark on this entry while locked.
1926 * @index: Index of entry.
1929 * Attempting to set a mark on a %NULL entry does not succeed.
1931 * Context: Any context. Expects xa_lock to be held on entry.
1936 void *entry = xas_load(&xas); in __xa_set_mark() local
1938 if (entry) in __xa_set_mark()
1944 * __xa_clear_mark() - Clear this mark on this entry while locked.
1946 * @index: Index of entry.
1949 * Context: Any context. Expects xa_lock to be held on entry.
1954 void *entry = xas_load(&xas); in __xa_clear_mark() local
1956 if (entry) in __xa_clear_mark()
1962 * xa_get_mark() - Inquire whether this mark is set on this entry.
1964 * @index: Index of entry.
1971 * Return: True if the entry at @index has this mark set, false if it doesn't.
1976 void *entry; in xa_get_mark() local
1979 entry = xas_start(&xas); in xa_get_mark()
1981 if (!xa_is_node(entry)) in xa_get_mark()
1983 entry = xas_descend(&xas, xa_to_node(entry)); in xa_get_mark()
1994 * xa_set_mark() - Set this mark on this entry.
1996 * @index: Index of entry.
1999 * Attempting to set a mark on a %NULL entry does not succeed.
2012 * xa_clear_mark() - Clear this mark on this entry.
2014 * @index: Index of entry.
2030 * xa_find() - Search the XArray for an entry.
2036 * Finds the entry in @xa which matches the @filter, and has the lowest
2038 * If an entry is found, @indexp is updated to be the index of the entry.
2044 * Return: The entry, if found, otherwise %NULL.
2050 void *entry; in xa_find() local
2055 entry = xas_find_marked(&xas, max, filter); in xa_find()
2057 entry = xas_find(&xas, max); in xa_find()
2058 } while (xas_retry(&xas, entry)); in xa_find()
2061 if (entry) in xa_find()
2063 return entry; in xa_find()
2080 * xa_find_after() - Search the XArray for a present entry.
2086 * Finds the entry in @xa which matches the @filter and has the lowest
2088 * If an entry is found, @indexp is updated to be the index of the entry.
2100 void *entry; in xa_find_after() local
2108 entry = xas_find_marked(&xas, max, filter); in xa_find_after()
2110 entry = xas_find(&xas, max); in xa_find_after()
2116 if (!xas_retry(&xas, entry)) in xa_find_after()
2121 if (entry) in xa_find_after()
2123 return entry; in xa_find_after()
2130 void *entry; in xas_extract_present() local
2134 xas_for_each(xas, entry, max) { in xas_extract_present()
2135 if (xas_retry(xas, entry)) in xas_extract_present()
2137 dst[i++] = entry; in xas_extract_present()
2149 void *entry; in xas_extract_marked() local
2153 xas_for_each_marked(xas, entry, max, mark) { in xas_extract_marked()
2154 if (xas_retry(xas, entry)) in xas_extract_marked()
2156 dst[i++] = entry; in xas_extract_marked()
2212 * Context: xa_lock must be held on entry and will not be released.
2244 void *entry; in xa_destroy() local
2248 entry = xa_head_locked(xa); in xa_destroy()
2254 if (xa_is_node(entry)) in xa_destroy()
2255 xas_free_nodes(&xas, xa_to_node(entry)); in xa_destroy()
2293 void xa_dump_entry(const void *entry, unsigned long index, unsigned long shift) in xa_dump_entry() argument
2295 if (!entry) in xa_dump_entry()
2300 if (xa_is_node(entry)) { in xa_dump_entry()
2302 pr_cont("%px\n", entry); in xa_dump_entry()
2305 struct xa_node *node = xa_to_node(entry); in xa_dump_entry()
2311 } else if (xa_is_value(entry)) in xa_dump_entry()
2312 pr_cont("value %ld (0x%lx) [%px]\n", xa_to_value(entry), in xa_dump_entry()
2313 xa_to_value(entry), entry); in xa_dump_entry()
2314 else if (!xa_is_internal(entry)) in xa_dump_entry()
2315 pr_cont("%px\n", entry); in xa_dump_entry()
2316 else if (xa_is_retry(entry)) in xa_dump_entry()
2317 pr_cont("retry (%ld)\n", xa_to_internal(entry)); in xa_dump_entry()
2318 else if (xa_is_sibling(entry)) in xa_dump_entry()
2319 pr_cont("sibling (slot %ld)\n", xa_to_sibling(entry)); in xa_dump_entry()
2320 else if (xa_is_zero(entry)) in xa_dump_entry()
2321 pr_cont("zero (%ld)\n", xa_to_internal(entry)); in xa_dump_entry()
2323 pr_cont("UNKNOWN ENTRY (%px)\n", entry); in xa_dump_entry()
2328 void *entry = xa->xa_head; in xa_dump() local
2331 pr_info("xarray: %px head %px flags %x marks %d %d %d\n", xa, entry, in xa_dump()
2334 if (xa_is_node(entry)) in xa_dump()
2335 shift = xa_to_node(entry)->shift + XA_CHUNK_SHIFT; in xa_dump()
2336 xa_dump_entry(entry, 0, shift); in xa_dump()