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
184 void *entry; in xas_start() local
191 entry = xa_head(xas->xa); in xas_start()
192 if (!xa_is_node(entry)) { in xas_start()
196 if ((xas->xa_index >> xa_to_node(entry)->shift) > XA_CHUNK_MASK) in xas_start()
201 return entry; in xas_start()
208 void *entry = xa_entry(xas->xa, node, offset); in xas_descend() local
211 while (xa_is_sibling(entry)) { in xas_descend()
212 offset = xa_to_sibling(entry); in xas_descend()
213 entry = xa_entry(xas->xa, node, offset); in xas_descend()
214 if (node->shift && xa_is_node(entry)) in xas_descend()
215 entry = XA_RETRY_ENTRY; in xas_descend()
219 return entry; in xas_descend()
223 * xas_load() - Load an entry from the XArray (advanced).
226 * Usually walks the @xas to the appropriate state to load the entry
230 * If the xa_state is set up to operate on a multi-index entry, xas_load()
231 * may return %NULL or an internal entry, even if there are entries
235 * Return: Usually an entry in the XArray, but see description for exceptions.
239 void *entry = xas_start(xas); in xas_load() local
241 while (xa_is_node(entry)) { in xas_load()
242 struct xa_node *node = xa_to_node(entry); in xas_load()
246 entry = xas_descend(xas, node); in xas_load()
250 return entry; in xas_load()
412 * in order to add the entry described by @xas. Because we cannot store a
413 * multi-index entry at index 0, the calculation is a little more complex
433 static unsigned long max_index(void *entry) in max_index() argument
435 if (!xa_is_node(entry)) in max_index()
437 return (XA_CHUNK_SIZE << xa_to_node(entry)->shift) - 1; in max_index()
440 static inline void *xa_zero_to_null(void *entry) in xa_zero_to_null() argument
442 return xa_is_zero(entry) ? NULL : entry; in xa_zero_to_null()
451 void *entry; in xas_shrink() local
456 entry = xa_entry_locked(xa, node, 0); in xas_shrink()
457 if (!entry) in xas_shrink()
459 if (!xa_is_node(entry) && node->shift) in xas_shrink()
462 entry = xa_zero_to_null(entry); in xas_shrink()
465 RCU_INIT_POINTER(xa->xa_head, entry); in xas_shrink()
471 if (!xa_is_node(entry)) in xas_shrink()
475 if (!xa_is_node(entry)) in xas_shrink()
477 node = xa_to_node(entry); in xas_shrink()
537 void *entry = xa_entry_locked(xas->xa, node, offset); in xas_free_nodes() local
539 if (node->shift && xa_is_node(entry)) { in xas_free_nodes()
540 node = xa_to_node(entry); in xas_free_nodes()
544 if (entry) in xas_free_nodes()
635 * xas_create() - Create a slot to store an entry in.
637 * @allow_root: %true if we can store the entry in the root directly
650 void *entry; in xas_create() local
657 entry = xa_head_locked(xa); in xas_create()
659 if (!entry && xa_zero_busy(xa)) in xas_create()
660 entry = XA_ZERO_ENTRY; in xas_create()
661 shift = xas_expand(xas, entry); in xas_create()
666 entry = xa_head_locked(xa); in xas_create()
674 entry = xa_entry_locked(xa, node, offset); in xas_create()
678 entry = xa_head_locked(xa); in xas_create()
684 if (!entry) { in xas_create()
691 } else if (xa_is_node(entry)) { in xas_create()
692 node = xa_to_node(entry); in xas_create()
696 entry = xas_descend(xas, node); in xas_create()
700 return entry; in xas_create()
771 * xas_store() - Store this entry in the XArray.
773 * @entry: New entry.
775 * If @xas is operating on a multi-index entry, the entry returned by this
776 * function is essentially meaningless (it may be an internal entry or it
781 * Return: The old entry at this index.
783 void *xas_store(struct xa_state *xas, void *entry) in xas_store() argument
791 bool value = xa_is_value(entry); in xas_store()
793 if (entry) { in xas_store()
794 bool allow_root = !xa_is_node(entry) && !xa_is_zero(entry); in xas_store()
805 if ((first == entry) && !xas->xa_sibs) in xas_store()
816 if (!entry) in xas_store()
821 * Must clear the marks before setting the entry to NULL, in xas_store()
822 * otherwise xas_for_each_marked may find a NULL entry and in xas_store()
825 * entry is set to NULL. in xas_store()
827 rcu_assign_pointer(*slot, entry); in xas_store()
832 count += !next - !entry; in xas_store()
834 if (entry) { in xas_store()
837 if (!xa_is_sibling(entry)) in xas_store()
838 entry = xa_mk_sibling(xas->xa_offset); in xas_store()
845 if (!entry && (offset > max)) in xas_store()
876 * xas_set_mark() - Sets the mark on this entry and its parents.
880 * Sets the specified mark on this entry, and walks up the tree setting it
882 * an entry, or is in an error state.
905 * xas_clear_mark() - Clears the mark on this entry and its parents.
909 * Clears the specified mark on this entry, and walks back to the head
911 * @xas has not been walked to an entry, or is in an error state.
937 * xas_init_marks() - Initialise all marks for the entry
940 * Initialise all marks for the entry specified by @xas. If we're tracking
1012 struct xa_node *node, void *entry) in __xas_init_node_for_split() argument
1023 RCU_INIT_POINTER(node->slots[i], entry); in __xas_init_node_for_split()
1032 * xas_split_alloc() - Allocate memory for splitting an entry.
1034 * @entry: New entry which will be stored in the array.
1035 * @order: Current entry order.
1039 * If necessary, it will allocate new nodes (and fill them with @entry)
1040 * to prepare for the upcoming split of an entry of @order size into
1045 void xas_split_alloc(struct xa_state *xas, void *entry, unsigned int order, in xas_split_alloc() argument
1063 __xas_init_node_for_split(xas, node, entry); in xas_split_alloc()
1076 * xas_split() - Split a multi-index entry into smaller entries.
1078 * @entry: New entry to store in the array.
1079 * @order: Current entry order.
1081 * The size of the new entries is set in @xas. The value in @entry is
1086 void xas_split(struct xa_state *xas, void *entry, unsigned int order) in xas_split() argument
1109 child->nr_values = xa_is_value(entry) ? in xas_split()
1123 rcu_assign_pointer(node->slots[canon], entry); in xas_split()
1127 values += (xa_is_value(entry) - xa_is_value(curr)) * in xas_split()
1139 * @order: Current entry order.
1141 * xas_try_split() can split a multi-index entry to smaller than @order - 1 if
1160 * xas_try_split() - Try to split a multi-index entry.
1162 * @entry: New entry to store in the array.
1163 * @order: Current entry order.
1165 * The size of the new entries is set in @xas. The value in @entry is
1175 void xas_try_split(struct xa_state *xas, void *entry, unsigned int order) in xas_try_split() argument
1223 __xas_init_node_for_split(xas, child, entry); in xas_try_split()
1229 child->nr_values = xa_is_value(entry) ? in xas_try_split()
1245 rcu_assign_pointer(node->slots[canon], entry); in xas_try_split()
1249 values += (xa_is_value(entry) - xa_is_value(curr)) * in xas_try_split()
1266 * on an entry. Those users should call this function before they drop
1300 * __xas_prev() - Find the previous entry in the XArray.
1308 void *entry; in __xas_prev() local
1328 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in __xas_prev()
1329 if (!xa_is_node(entry)) in __xas_prev()
1330 return entry; in __xas_prev()
1332 xas->xa_node = xa_to_node(entry); in __xas_prev()
1339 * __xas_next() - Find the next entry in the XArray.
1347 void *entry; in __xas_next() local
1367 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in __xas_next()
1368 if (!xa_is_node(entry)) in __xas_next()
1369 return entry; in __xas_next()
1371 xas->xa_node = xa_to_node(entry); in __xas_next()
1378 * xas_find() - Find the next present entry in the XArray.
1382 * If the @xas has not yet been walked to an entry, return the entry
1383 * which has an index >= xas.xa_index. If it has been walked, the entry
1385 * next entry.
1387 * If no entry is found and the array is smaller than @max, the iterator
1391 * Return: The entry, if found, otherwise %NULL.
1395 void *entry; in xas_find() local
1406 entry = xas_load(xas); in xas_find()
1407 if (entry || xas_not_node(xas->xa_node)) in xas_find()
1408 return entry; in xas_find()
1423 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find()
1424 if (xa_is_node(entry)) { in xas_find()
1425 xas->xa_node = xa_to_node(entry); in xas_find()
1429 if (entry && !xa_is_sibling(entry)) in xas_find()
1430 return entry; in xas_find()
1442 * xas_find_marked() - Find the next marked entry in the XArray.
1447 * If the @xas has not yet been walked to an entry, return the marked entry
1448 * which has an index >= xas.xa_index. If it has been walked, the entry
1450 * first marked entry with an index > xas.xa_index.
1452 * If no marked entry is found and the array is smaller than @max, @xas is
1457 * If no entry is found before @max is reached, @xas is set to the restart
1460 * Return: The entry, if found, otherwise %NULL.
1466 void *entry; in xas_find_marked() local
1478 entry = xa_head(xas->xa); in xas_find_marked()
1480 if (xas->xa_index > max_index(entry)) in xas_find_marked()
1482 if (!xa_is_node(entry)) { in xas_find_marked()
1484 return entry; in xas_find_marked()
1488 xas->xa_node = xa_to_node(entry); in xas_find_marked()
1503 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find_marked()
1504 if (xa_is_sibling(entry)) { in xas_find_marked()
1505 xas->xa_offset = xa_to_sibling(entry); in xas_find_marked()
1522 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find_marked()
1523 if (!entry && !(xa_track_free(xas->xa) && mark == XA_FREE_MARK)) in xas_find_marked()
1525 if (xa_is_sibling(entry)) in xas_find_marked()
1527 if (!xa_is_node(entry)) in xas_find_marked()
1528 return entry; in xas_find_marked()
1529 xas->xa_node = xa_to_node(entry); in xas_find_marked()
1544 * xas_find_conflict() - Find the next present entry in a range.
1550 * Return: The next entry in the range covered by @xas or %NULL.
1605 * xa_load() - Load an entry from an XArray.
1610 * Return: The entry at @index in @xa.
1615 void *entry; in xa_load() local
1619 entry = xa_zero_to_null(xas_load(&xas)); in xa_load()
1620 } while (xas_retry(&xas, entry)); in xa_load()
1623 return entry; in xa_load()
1635 * __xa_erase() - Erase this entry from the XArray while locked.
1640 * If the index is part of a multi-index entry, all indices will be erased
1641 * and none of the entries will be part of a multi-index entry.
1643 * Context: Any context. Expects xa_lock to be held on entry.
1644 * Return: The entry which used to be at this index.
1654 * xa_erase() - Erase this entry from the XArray.
1656 * @index: Index of entry.
1659 * If the index is part of a multi-index entry, all indices will be erased
1660 * and none of the entries will be part of a multi-index entry.
1663 * Return: The entry which used to be at this index.
1667 void *entry; in xa_erase() local
1670 entry = __xa_erase(xa, index); in xa_erase()
1673 return entry; in xa_erase()
1678 * __xa_store() - Store this entry in the XArray.
1681 * @entry: New entry.
1688 * Context: Any context. Expects xa_lock to be held on entry. May
1690 * Return: The old entry at this index or xa_err() if an error happened.
1692 void *__xa_store(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in __xa_store() argument
1697 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_store()
1699 if (xa_track_free(xa) && !entry) in __xa_store()
1700 entry = XA_ZERO_ENTRY; in __xa_store()
1703 curr = xas_store(&xas, entry); in __xa_store()
1713 * xa_store() - Store this entry in the XArray.
1716 * @entry: New entry.
1719 * After this function returns, loads from this index will return @entry.
1720 * Storing into an existing multi-index entry updates the entry of every index.
1721 * The marks associated with @index are unaffected unless @entry is %NULL.
1725 * Return: The old entry at this index on success, xa_err(-EINVAL) if @entry
1729 void *xa_store(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in xa_store() argument
1734 curr = __xa_store(xa, index, entry, gfp); in xa_store()
1742 void *old, void *entry, gfp_t gfp);
1745 * __xa_cmpxchg() - Store this entry in the XArray.
1749 * @entry: New entry.
1756 * Context: Any context. Expects xa_lock to be held on entry. May
1758 * Return: The old entry at this index or xa_err() if an error happened.
1761 void *old, void *entry, gfp_t gfp) in __xa_cmpxchg() argument
1763 return xa_zero_to_null(__xa_cmpxchg_raw(xa, index, old, entry, gfp)); in __xa_cmpxchg()
1768 void *old, void *entry, gfp_t gfp) in __xa_cmpxchg_raw() argument
1773 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_cmpxchg_raw()
1779 xas_store(&xas, entry); in __xa_cmpxchg_raw()
1780 if (xa_track_free(xa) && entry && !curr) in __xa_cmpxchg_raw()
1789 * __xa_insert() - Store this entry in the XArray if no entry is present.
1792 * @entry: New entry.
1795 * Inserting a NULL entry will store a reserved entry (like xa_reserve())
1796 * if no entry is present. Inserting will fail if a reserved entry is
1799 * Context: Any context. Expects xa_lock to be held on entry. May
1801 * Return: 0 if the store succeeded. -EBUSY if another entry was present.
1804 int __xa_insert(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in __xa_insert() argument
1809 if (!entry) in __xa_insert()
1810 entry = XA_ZERO_ENTRY; in __xa_insert()
1811 curr = __xa_cmpxchg_raw(xa, index, NULL, entry, gfp); in __xa_insert()
1852 * xa_store_range() - Store this entry at a range of indices in the XArray.
1856 * @entry: New entry.
1860 * inclusive will return @entry.
1861 * Storing into an existing multi-index entry updates the entry of every index.
1862 * The marks associated with @index are unaffected unless @entry is %NULL.
1866 * Return: %NULL on success, xa_err(-EINVAL) if @entry cannot be stored in
1870 unsigned long last, void *entry, gfp_t gfp) in xa_store_range() argument
1874 if (WARN_ON_ONCE(xa_is_internal(entry))) in xa_store_range()
1881 if (entry) { in xa_store_range()
1892 xas_store(&xas, entry); in xa_store_range()
1906 * xas_get_order() - Get the order of an entry.
1911 * Return: A number between 0 and 63 indicating the order of the entry.
1936 * xa_get_order() - Get the order of an entry.
1938 * @index: Index of the entry.
1940 * Return: A number between 0 and 63 indicating the order of the entry.
1946 void *entry; in xa_get_order() local
1949 entry = xas_load(&xas); in xa_get_order()
1950 if (entry) in xa_get_order()
1960 * __xa_alloc() - Find somewhere to store this entry in the XArray.
1964 * @entry: New entry.
1967 * Finds an empty entry in @xa between @limit.min and @limit.max,
1968 * stores the index into the @id pointer, then stores the entry at
1974 * Context: Any context. Expects xa_lock to be held on entry. May
1979 int __xa_alloc(struct xarray *xa, u32 *id, void *entry, in __xa_alloc() argument
1984 if (WARN_ON_ONCE(xa_is_advanced(entry))) in __xa_alloc()
1989 if (!entry) in __xa_alloc()
1990 entry = XA_ZERO_ENTRY; in __xa_alloc()
1999 xas_store(&xas, entry); in __xa_alloc()
2008 * __xa_alloc_cyclic() - Find somewhere to store this entry in the XArray.
2011 * @entry: New entry.
2016 * Finds an empty entry in @xa between @limit.min and @limit.max,
2017 * stores the index into the @id pointer, then stores the entry at
2019 * The search for an empty entry will start at @next and will wrap
2025 * Context: Any context. Expects xa_lock to be held on entry. May
2031 int __xa_alloc_cyclic(struct xarray *xa, u32 *id, void *entry, in __xa_alloc_cyclic() argument
2038 ret = __xa_alloc(xa, id, entry, limit, gfp); in __xa_alloc_cyclic()
2046 ret = __xa_alloc(xa, id, entry, limit, gfp); in __xa_alloc_cyclic()
2061 * __xa_set_mark() - Set this mark on this entry while locked.
2063 * @index: Index of entry.
2066 * Attempting to set a mark on a %NULL entry does not succeed.
2068 * Context: Any context. Expects xa_lock to be held on entry.
2073 void *entry = xas_load(&xas); in __xa_set_mark() local
2075 if (entry) in __xa_set_mark()
2081 * __xa_clear_mark() - Clear this mark on this entry while locked.
2083 * @index: Index of entry.
2086 * Context: Any context. Expects xa_lock to be held on entry.
2091 void *entry = xas_load(&xas); in __xa_clear_mark() local
2093 if (entry) in __xa_clear_mark()
2099 * xa_get_mark() - Inquire whether this mark is set on this entry.
2101 * @index: Index of entry.
2108 * Return: True if the entry at @index has this mark set, false if it doesn't.
2113 void *entry; in xa_get_mark() local
2116 entry = xas_start(&xas); in xa_get_mark()
2118 if (!xa_is_node(entry)) in xa_get_mark()
2120 entry = xas_descend(&xas, xa_to_node(entry)); in xa_get_mark()
2131 * xa_set_mark() - Set this mark on this entry.
2133 * @index: Index of entry.
2136 * Attempting to set a mark on a %NULL entry does not succeed.
2149 * xa_clear_mark() - Clear this mark on this entry.
2151 * @index: Index of entry.
2167 * xa_find() - Search the XArray for an entry.
2173 * Finds the entry in @xa which matches the @filter, and has the lowest
2175 * If an entry is found, @indexp is updated to be the index of the entry.
2181 * Return: The entry, if found, otherwise %NULL.
2187 void *entry; in xa_find() local
2192 entry = xas_find_marked(&xas, max, filter); in xa_find()
2194 entry = xas_find(&xas, max); in xa_find()
2195 } while (xas_retry(&xas, entry)); in xa_find()
2198 if (entry) in xa_find()
2200 return entry; in xa_find()
2217 * xa_find_after() - Search the XArray for a present entry.
2223 * Finds the entry in @xa which matches the @filter and has the lowest
2225 * If an entry is found, @indexp is updated to be the index of the entry.
2237 void *entry; in xa_find_after() local
2245 entry = xas_find_marked(&xas, max, filter); in xa_find_after()
2247 entry = xas_find(&xas, max); in xa_find_after()
2253 if (!xas_retry(&xas, entry)) in xa_find_after()
2258 if (entry) in xa_find_after()
2260 return entry; in xa_find_after()
2267 void *entry; in xas_extract_present() local
2271 xas_for_each(xas, entry, max) { in xas_extract_present()
2272 if (xas_retry(xas, entry)) in xas_extract_present()
2274 dst[i++] = entry; in xas_extract_present()
2286 void *entry; in xas_extract_marked() local
2290 xas_for_each_marked(xas, entry, max, mark) { in xas_extract_marked()
2291 if (xas_retry(xas, entry)) in xas_extract_marked()
2293 dst[i++] = entry; in xas_extract_marked()
2349 * Context: xa_lock must be held on entry and will not be released.
2381 void *entry; in xa_destroy() local
2385 entry = xa_head_locked(xa); in xa_destroy()
2391 if (xa_is_node(entry)) in xa_destroy()
2392 xas_free_nodes(&xas, xa_to_node(entry)); in xa_destroy()
2430 void xa_dump_entry(const void *entry, unsigned long index, unsigned long shift) in xa_dump_entry() argument
2432 if (!entry) in xa_dump_entry()
2437 if (xa_is_node(entry)) { in xa_dump_entry()
2439 pr_cont("%px\n", entry); in xa_dump_entry()
2442 struct xa_node *node = xa_to_node(entry); in xa_dump_entry()
2448 } else if (xa_is_value(entry)) in xa_dump_entry()
2449 pr_cont("value %ld (0x%lx) [%px]\n", xa_to_value(entry), in xa_dump_entry()
2450 xa_to_value(entry), entry); in xa_dump_entry()
2451 else if (!xa_is_internal(entry)) in xa_dump_entry()
2452 pr_cont("%px\n", entry); in xa_dump_entry()
2453 else if (xa_is_retry(entry)) in xa_dump_entry()
2454 pr_cont("retry (%ld)\n", xa_to_internal(entry)); in xa_dump_entry()
2455 else if (xa_is_sibling(entry)) in xa_dump_entry()
2456 pr_cont("sibling (slot %ld)\n", xa_to_sibling(entry)); in xa_dump_entry()
2457 else if (xa_is_zero(entry)) in xa_dump_entry()
2458 pr_cont("zero (%ld)\n", xa_to_internal(entry)); in xa_dump_entry()
2460 pr_cont("UNKNOWN ENTRY (%px)\n", entry); in xa_dump_entry()
2465 void *entry = xa->xa_head; in xa_dump() local
2468 pr_info("xarray: %px head %px flags %x marks %d %d %d\n", xa, entry, in xa_dump()
2471 if (xa_is_node(entry)) in xa_dump()
2472 shift = xa_to_node(entry)->shift + XA_CHUNK_SHIFT; in xa_dump()
2473 xa_dump_entry(entry, 0, shift); in xa_dump()