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: Current 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: Current entry order.
1046 * The size of the new entries is set in @xas. The value in @entry is
1051 void xas_split(struct xa_state *xas, void *entry, unsigned int order) in xas_split() argument
1074 child->nr_values = xa_is_value(entry) ? in xas_split()
1086 rcu_assign_pointer(node->slots[canon], entry); in xas_split()
1090 values += (xa_is_value(entry) - xa_is_value(curr)) * in xas_split()
1106 * on an entry. Those users should call this function before they drop
1139 * __xas_prev() - Find the previous entry in the XArray.
1147 void *entry; in __xas_prev() local
1167 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in __xas_prev()
1168 if (!xa_is_node(entry)) in __xas_prev()
1169 return entry; in __xas_prev()
1171 xas->xa_node = xa_to_node(entry); in __xas_prev()
1178 * __xas_next() - Find the next entry in the XArray.
1186 void *entry; in __xas_next() local
1206 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in __xas_next()
1207 if (!xa_is_node(entry)) in __xas_next()
1208 return entry; in __xas_next()
1210 xas->xa_node = xa_to_node(entry); in __xas_next()
1217 * xas_find() - Find the next present entry in the XArray.
1221 * If the @xas has not yet been walked to an entry, return the entry
1222 * which has an index >= xas.xa_index. If it has been walked, the entry
1224 * next entry.
1226 * If no entry is found and the array is smaller than @max, the iterator
1230 * Return: The entry, if found, otherwise %NULL.
1234 void *entry; in xas_find() local
1245 entry = xas_load(xas); in xas_find()
1246 if (entry || xas_not_node(xas->xa_node)) in xas_find()
1247 return entry; in xas_find()
1262 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find()
1263 if (xa_is_node(entry)) { in xas_find()
1264 xas->xa_node = xa_to_node(entry); in xas_find()
1268 if (entry && !xa_is_sibling(entry)) in xas_find()
1269 return entry; in xas_find()
1281 * xas_find_marked() - Find the next marked entry in the XArray.
1286 * If the @xas has not yet been walked to an entry, return the marked entry
1287 * which has an index >= xas.xa_index. If it has been walked, the entry
1289 * first marked entry with an index > xas.xa_index.
1291 * If no marked entry is found and the array is smaller than @max, @xas is
1296 * If no entry is found before @max is reached, @xas is set to the restart
1299 * Return: The entry, if found, otherwise %NULL.
1305 void *entry; in xas_find_marked() local
1317 entry = xa_head(xas->xa); in xas_find_marked()
1319 if (xas->xa_index > max_index(entry)) in xas_find_marked()
1321 if (!xa_is_node(entry)) { in xas_find_marked()
1323 return entry; in xas_find_marked()
1327 xas->xa_node = xa_to_node(entry); in xas_find_marked()
1342 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find_marked()
1343 if (xa_is_sibling(entry)) { in xas_find_marked()
1344 xas->xa_offset = xa_to_sibling(entry); in xas_find_marked()
1361 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find_marked()
1362 if (!entry && !(xa_track_free(xas->xa) && mark == XA_FREE_MARK)) in xas_find_marked()
1364 if (!xa_is_node(entry)) in xas_find_marked()
1365 return entry; in xas_find_marked()
1366 xas->xa_node = xa_to_node(entry); in xas_find_marked()
1381 * xas_find_conflict() - Find the next present entry in a range.
1387 * Return: The next entry in the range covered by @xas or %NULL.
1442 * xa_load() - Load an entry from an XArray.
1447 * Return: The entry at @index in @xa.
1452 void *entry; in xa_load() local
1456 entry = xas_load(&xas); in xa_load()
1457 if (xa_is_zero(entry)) in xa_load()
1458 entry = NULL; in xa_load()
1459 } while (xas_retry(&xas, entry)); in xa_load()
1462 return entry; in xa_load()
1476 * __xa_erase() - Erase this entry from the XArray while locked.
1481 * If the index is part of a multi-index entry, all indices will be erased
1482 * and none of the entries will be part of a multi-index entry.
1484 * Context: Any context. Expects xa_lock to be held on entry.
1485 * Return: The entry which used to be at this index.
1495 * xa_erase() - Erase this entry from the XArray.
1497 * @index: Index of entry.
1500 * If the index is part of a multi-index entry, all indices will be erased
1501 * and none of the entries will be part of a multi-index entry.
1504 * Return: The entry which used to be at this index.
1508 void *entry; in xa_erase() local
1511 entry = __xa_erase(xa, index); in xa_erase()
1514 return entry; in xa_erase()
1519 * __xa_store() - Store this entry in the XArray.
1522 * @entry: New entry.
1529 * Context: Any context. Expects xa_lock to be held on entry. May
1531 * Return: The old entry at this index or xa_err() if an error happened.
1533 void *__xa_store(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in __xa_store() argument
1538 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_store()
1540 if (xa_track_free(xa) && !entry) in __xa_store()
1541 entry = XA_ZERO_ENTRY; in __xa_store()
1544 curr = xas_store(&xas, entry); in __xa_store()
1554 * xa_store() - Store this entry in the XArray.
1557 * @entry: New entry.
1560 * After this function returns, loads from this index will return @entry.
1561 * Storing into an existing multi-index entry updates the entry of every index.
1562 * The marks associated with @index are unaffected unless @entry is %NULL.
1566 * Return: The old entry at this index on success, xa_err(-EINVAL) if @entry
1570 void *xa_store(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in xa_store() argument
1575 curr = __xa_store(xa, index, entry, gfp); in xa_store()
1583 * __xa_cmpxchg() - Store this entry in the XArray.
1587 * @entry: New entry.
1594 * Context: Any context. Expects xa_lock to be held on entry. May
1596 * Return: The old entry at this index or xa_err() if an error happened.
1599 void *old, void *entry, gfp_t gfp) in __xa_cmpxchg() argument
1604 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_cmpxchg()
1610 xas_store(&xas, entry); in __xa_cmpxchg()
1611 if (xa_track_free(xa) && entry && !curr) in __xa_cmpxchg()
1621 * __xa_insert() - Store this entry in the XArray if no entry is present.
1624 * @entry: New entry.
1627 * Inserting a NULL entry will store a reserved entry (like xa_reserve())
1628 * if no entry is present. Inserting will fail if a reserved entry is
1631 * Context: Any context. Expects xa_lock to be held on entry. May
1633 * Return: 0 if the store succeeded. -EBUSY if another entry was present.
1636 int __xa_insert(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in __xa_insert() argument
1641 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_insert()
1643 if (!entry) in __xa_insert()
1644 entry = XA_ZERO_ENTRY; in __xa_insert()
1649 xas_store(&xas, entry); in __xa_insert()
1694 * xa_store_range() - Store this entry at a range of indices in the XArray.
1698 * @entry: New entry.
1702 * inclusive will return @entry.
1703 * Storing into an existing multi-index entry updates the entry of every index.
1704 * The marks associated with @index are unaffected unless @entry is %NULL.
1708 * Return: %NULL on success, xa_err(-EINVAL) if @entry cannot be stored in
1712 unsigned long last, void *entry, gfp_t gfp) in xa_store_range() argument
1716 if (WARN_ON_ONCE(xa_is_internal(entry))) in xa_store_range()
1723 if (entry) { in xa_store_range()
1734 xas_store(&xas, entry); in xa_store_range()
1748 * xa_get_order() - Get the order of an entry.
1750 * @index: Index of the entry.
1752 * Return: A number between 0 and 63 indicating the order of the entry.
1757 void *entry; in xa_get_order() local
1761 entry = xas_load(&xas); in xa_get_order()
1763 if (!entry) in xa_get_order()
1789 * __xa_alloc() - Find somewhere to store this entry in the XArray.
1793 * @entry: New entry.
1796 * Finds an empty entry in @xa between @limit.min and @limit.max,
1797 * stores the index into the @id pointer, then stores the entry at
1800 * Context: Any context. Expects xa_lock to be held on entry. May
1805 int __xa_alloc(struct xarray *xa, u32 *id, void *entry, in __xa_alloc() argument
1810 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_alloc()
1815 if (!entry) in __xa_alloc()
1816 entry = XA_ZERO_ENTRY; in __xa_alloc()
1825 xas_store(&xas, entry); in __xa_alloc()
1834 * __xa_alloc_cyclic() - Find somewhere to store this entry in the XArray.
1837 * @entry: New entry.
1842 * Finds an empty entry in @xa between @limit.min and @limit.max,
1843 * stores the index into the @id pointer, then stores the entry at
1845 * The search for an empty entry will start at @next and will wrap
1848 * Context: Any context. Expects xa_lock to be held on entry. May
1854 int __xa_alloc_cyclic(struct xarray *xa, u32 *id, void *entry, in __xa_alloc_cyclic() argument
1861 ret = __xa_alloc(xa, id, entry, limit, gfp); in __xa_alloc_cyclic()
1869 ret = __xa_alloc(xa, id, entry, limit, gfp); in __xa_alloc_cyclic()
1884 * __xa_set_mark() - Set this mark on this entry while locked.
1886 * @index: Index of entry.
1889 * Attempting to set a mark on a %NULL entry does not succeed.
1891 * Context: Any context. Expects xa_lock to be held on entry.
1896 void *entry = xas_load(&xas); in __xa_set_mark() local
1898 if (entry) in __xa_set_mark()
1904 * __xa_clear_mark() - Clear this mark on this entry while locked.
1906 * @index: Index of entry.
1909 * Context: Any context. Expects xa_lock to be held on entry.
1914 void *entry = xas_load(&xas); in __xa_clear_mark() local
1916 if (entry) in __xa_clear_mark()
1922 * xa_get_mark() - Inquire whether this mark is set on this entry.
1924 * @index: Index of entry.
1931 * Return: True if the entry at @index has this mark set, false if it doesn't.
1936 void *entry; in xa_get_mark() local
1939 entry = xas_start(&xas); in xa_get_mark()
1941 if (!xa_is_node(entry)) in xa_get_mark()
1943 entry = xas_descend(&xas, xa_to_node(entry)); in xa_get_mark()
1954 * xa_set_mark() - Set this mark on this entry.
1956 * @index: Index of entry.
1959 * Attempting to set a mark on a %NULL entry does not succeed.
1972 * xa_clear_mark() - Clear this mark on this entry.
1974 * @index: Index of entry.
1990 * xa_find() - Search the XArray for an entry.
1996 * Finds the entry in @xa which matches the @filter, and has the lowest
1998 * If an entry is found, @indexp is updated to be the index of the entry.
2004 * Return: The entry, if found, otherwise %NULL.
2010 void *entry; in xa_find() local
2015 entry = xas_find_marked(&xas, max, filter); in xa_find()
2017 entry = xas_find(&xas, max); in xa_find()
2018 } while (xas_retry(&xas, entry)); in xa_find()
2021 if (entry) in xa_find()
2023 return entry; in xa_find()
2040 * xa_find_after() - Search the XArray for a present entry.
2046 * Finds the entry in @xa which matches the @filter and has the lowest
2048 * If an entry is found, @indexp is updated to be the index of the entry.
2060 void *entry; in xa_find_after() local
2068 entry = xas_find_marked(&xas, max, filter); in xa_find_after()
2070 entry = xas_find(&xas, max); in xa_find_after()
2076 if (!xas_retry(&xas, entry)) in xa_find_after()
2081 if (entry) in xa_find_after()
2083 return entry; in xa_find_after()
2090 void *entry; in xas_extract_present() local
2094 xas_for_each(xas, entry, max) { in xas_extract_present()
2095 if (xas_retry(xas, entry)) in xas_extract_present()
2097 dst[i++] = entry; in xas_extract_present()
2109 void *entry; in xas_extract_marked() local
2113 xas_for_each_marked(xas, entry, max, mark) { in xas_extract_marked()
2114 if (xas_retry(xas, entry)) in xas_extract_marked()
2116 dst[i++] = entry; in xas_extract_marked()
2172 * Context: xa_lock must be held on entry and will not be released.
2204 void *entry; in xa_destroy() local
2208 entry = xa_head_locked(xa); in xa_destroy()
2214 if (xa_is_node(entry)) in xa_destroy()
2215 xas_free_nodes(&xas, xa_to_node(entry)); in xa_destroy()
2253 void xa_dump_entry(const void *entry, unsigned long index, unsigned long shift) in xa_dump_entry() argument
2255 if (!entry) in xa_dump_entry()
2260 if (xa_is_node(entry)) { in xa_dump_entry()
2262 pr_cont("%px\n", entry); in xa_dump_entry()
2265 struct xa_node *node = xa_to_node(entry); in xa_dump_entry()
2271 } else if (xa_is_value(entry)) in xa_dump_entry()
2272 pr_cont("value %ld (0x%lx) [%px]\n", xa_to_value(entry), in xa_dump_entry()
2273 xa_to_value(entry), entry); in xa_dump_entry()
2274 else if (!xa_is_internal(entry)) in xa_dump_entry()
2275 pr_cont("%px\n", entry); in xa_dump_entry()
2276 else if (xa_is_retry(entry)) in xa_dump_entry()
2277 pr_cont("retry (%ld)\n", xa_to_internal(entry)); in xa_dump_entry()
2278 else if (xa_is_sibling(entry)) in xa_dump_entry()
2279 pr_cont("sibling (slot %ld)\n", xa_to_sibling(entry)); in xa_dump_entry()
2280 else if (xa_is_zero(entry)) in xa_dump_entry()
2281 pr_cont("zero (%ld)\n", xa_to_internal(entry)); in xa_dump_entry()
2283 pr_cont("UNKNOWN ENTRY (%px)\n", entry); in xa_dump_entry()
2288 void *entry = xa->xa_head; in xa_dump() local
2291 pr_info("xarray: %px head %px flags %x marks %d %d %d\n", xa, entry, in xa_dump()
2294 if (xa_is_node(entry)) in xa_dump()
2295 shift = xa_to_node(entry)->shift + XA_CHUNK_SHIFT; in xa_dump()
2296 xa_dump_entry(entry, 0, shift); in xa_dump()