Lines Matching +full:0 +full:xa

18  * @xa is used to refer to the entire xarray.
31 static inline unsigned int xa_lock_type(const struct xarray *xa) in xa_lock_type() argument
33 return (__force unsigned int)xa->xa_flags & 3; in xa_lock_type()
56 static inline bool xa_track_free(const struct xarray *xa) in xa_track_free() argument
58 return xa->xa_flags & XA_FLAGS_TRACK_FREE; in xa_track_free()
61 static inline bool xa_zero_busy(const struct xarray *xa) in xa_zero_busy() argument
63 return xa->xa_flags & XA_FLAGS_ZERO_BUSY; in xa_zero_busy()
66 static inline void xa_mark_set(struct xarray *xa, xa_mark_t mark) in xa_mark_set() argument
68 if (!(xa->xa_flags & XA_FLAGS_MARK(mark))) in xa_mark_set()
69 xa->xa_flags |= XA_FLAGS_MARK(mark); in xa_mark_set()
72 static inline void xa_mark_clear(struct xarray *xa, xa_mark_t mark) in xa_mark_clear() argument
74 if (xa->xa_flags & XA_FLAGS_MARK(mark)) in xa_mark_clear()
75 xa->xa_flags &= ~(XA_FLAGS_MARK(mark)); in xa_mark_clear()
115 } while (0)
126 unsigned int mark = 0; in xas_squash_marks()
188 entry = xa_head(xas->xa); in xas_start()
204 void *entry = xa_entry(xas->xa, node, offset); in xas_descend()
209 entry = xa_entry(xas->xa, node, offset); in xas_descend()
241 if (node->shift == 0) in xas_load()
303 if (xas->xa->xa_flags & XA_FLAGS_ACCOUNT) in xas_nomem()
325 __must_hold(xas->xa->xa_lock) in __xas_nomem()
327 unsigned int lock_type = xa_lock_type(xas->xa); in __xas_nomem()
333 if (xas->xa->xa_flags & XA_FLAGS_ACCOUNT) in __xas_nomem()
371 if (xas->xa->xa_flags & XA_FLAGS_ACCOUNT) in xas_alloc()
390 node->count = 0; in xas_alloc()
391 node->nr_values = 0; in xas_alloc()
393 node->array = xas->xa; in xas_alloc()
409 * multi-index entry at index 0, the calculation is a little more complex
432 return 0; in max_index()
438 struct xarray *xa = xas->xa; in xas_shrink() local
447 entry = xa_entry_locked(xa, node, 0); in xas_shrink()
452 if (xa_is_zero(entry) && xa_zero_busy(xa)) in xas_shrink()
456 RCU_INIT_POINTER(xa->xa_head, entry); in xas_shrink()
457 if (xa_track_free(xa) && !node_get_mark(node, 0, XA_FREE_MARK)) in xas_shrink()
458 xa_mark_clear(xa, XA_FREE_MARK); in xas_shrink()
460 node->count = 0; in xas_shrink()
461 node->nr_values = 0; in xas_shrink()
463 RCU_INIT_POINTER(node->slots[0], XA_RETRY_ENTRY); in xas_shrink()
477 * Attempts to delete the @xas->xa_node. This will fail if xa->node has
491 parent = xa_parent_locked(xas->xa, node); in xas_delete_node()
497 xas->xa->xa_head = NULL; in xas_delete_node()
524 unsigned int offset = 0; in xas_free_nodes()
528 void *entry = xa_entry_locked(xas->xa, node, offset); in xas_free_nodes()
532 offset = 0; in xas_free_nodes()
541 parent = xa_parent_locked(xas->xa, node); in xas_free_nodes()
543 node->count = 0; in xas_free_nodes()
544 node->nr_values = 0; in xas_free_nodes()
560 struct xarray *xa = xas->xa; in xas_expand() local
562 unsigned int shift = 0; in xas_expand()
566 if (max == 0) in xas_expand()
567 return 0; in xas_expand()
578 xa_mark_t mark = 0; in xas_expand()
588 RCU_INIT_POINTER(node->slots[0], head); in xas_expand()
592 if (xa_track_free(xa) && mark == XA_FREE_MARK) { in xas_expand()
594 if (!xa_marked(xa, XA_FREE_MARK)) { in xas_expand()
595 node_clear_mark(node, 0, XA_FREE_MARK); in xas_expand()
596 xa_mark_set(xa, XA_FREE_MARK); in xas_expand()
598 } else if (xa_marked(xa, mark)) { in xas_expand()
599 node_set_mark(node, 0, mark); in xas_expand()
611 xa_to_node(head)->offset = 0; in xas_expand()
615 rcu_assign_pointer(xa->xa_head, head); in xas_expand()
640 struct xarray *xa = xas->xa; in xas_create() local
648 entry = xa_head_locked(xa); in xas_create()
650 if (!entry && xa_zero_busy(xa)) in xas_create()
653 if (shift < 0) in xas_create()
657 entry = xa_head_locked(xa); in xas_create()
658 slot = &xa->xa_head; in xas_create()
665 entry = xa_entry_locked(xa, node, offset); in xas_create()
668 shift = 0; in xas_create()
669 entry = xa_head_locked(xa); in xas_create()
670 slot = &xa->xa_head; in xas_create()
679 if (xa_track_free(xa)) in xas_create()
712 xas->xa_shift = 0; in xas_create_range()
713 xas->xa_sibs = 0; in xas_create_range()
725 xas->xa_node = xa_parent_locked(xas->xa, node); in xas_create_range()
727 if (node->offset != 0) in xas_create_range()
755 if (count < 0) in update_node()
775 void __rcu **slot = &xas->xa->xa_head; in xas_store()
777 int count = 0; in xas_store()
778 int values = 0; in xas_store()
793 xas->xa_sibs = 0; in xas_store()
832 next = xa_entry_locked(xas->xa, node, ++offset); in xas_store()
859 return xa_marked(xas->xa, mark); in xas_get_mark()
885 node = xa_parent_locked(xas->xa, node); in xas_set_mark()
888 if (!xa_marked(xas->xa, mark)) in xas_set_mark()
889 xa_mark_set(xas->xa, mark); in xas_set_mark()
917 node = xa_parent_locked(xas->xa, node); in xas_clear_mark()
920 if (xa_marked(xas->xa, mark)) in xas_clear_mark()
921 xa_mark_clear(xas->xa, mark); in xas_clear_mark()
938 xa_mark_t mark = 0; in xas_init_marks()
941 if (xa_track_free(xas->xa) && mark == XA_FREE_MARK) in xas_init_marks()
955 unsigned int marks = 0; in node_get_marks()
1020 node->array = xas->xa; in xas_split_alloc()
1021 for (i = 0; i < XA_CHUNK_SIZE; i++) { in xas_split_alloc()
1022 if ((i & mask) == 0) { in xas_split_alloc()
1024 sibling = xa_mk_sibling(0); in xas_split_alloc()
1031 } while (sibs-- > 0); in xas_split_alloc()
1056 int values = 0; in xas_split()
1074 XA_CHUNK_SIZE : 0; in xas_split()
1125 if (!xa_is_sibling(xa_entry(xas->xa, node, offset))) in xas_pause()
1129 if (xas->xa_index == 0) in xas_pause()
1160 xas->xa_node = xa_parent(xas->xa, xas->xa_node); in __xas_prev()
1166 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in __xas_prev()
1199 xas->xa_node = xa_parent(xas->xa, xas->xa_node); in __xas_next()
1205 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in __xas_next()
1257 xas->xa_node = xa_parent(xas->xa, xas->xa_node); in xas_find()
1261 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find()
1264 xas->xa_offset = 0; in xas_find()
1316 entry = xa_head(xas->xa); in xas_find_marked()
1321 if (xa_marked(xas->xa, mark)) in xas_find_marked()
1333 xas->xa_node = xa_parent(xas->xa, xas->xa_node); in xas_find_marked()
1341 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find_marked()
1360 entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); in xas_find_marked()
1361 if (!entry && !(xa_track_free(xas->xa) && mark == XA_FREE_MARK)) in xas_find_marked()
1419 xas->xa_node = xa_parent_locked(xas->xa, xas->xa_node); in xas_find_conflict()
1424 curr = xa_entry_locked(xas->xa, xas->xa_node, ++xas->xa_offset); in xas_find_conflict()
1429 xas->xa_offset = 0; in xas_find_conflict()
1430 curr = xa_entry_locked(xas->xa, xas->xa_node, 0); in xas_find_conflict()
1442 * @xa: XArray.
1446 * Return: The entry at @index in @xa.
1448 void *xa_load(struct xarray *xa, unsigned long index) in xa_load() argument
1450 XA_STATE(xas, xa, index); in xa_load()
1476 * @xa: XArray.
1486 void *__xa_erase(struct xarray *xa, unsigned long index) in __xa_erase() argument
1488 XA_STATE(xas, xa, index); in __xa_erase()
1495 * @xa: XArray.
1505 void *xa_erase(struct xarray *xa, unsigned long index) in xa_erase() argument
1509 xa_lock(xa); in xa_erase()
1510 entry = __xa_erase(xa, index); in xa_erase()
1511 xa_unlock(xa); in xa_erase()
1519 * @xa: XArray.
1532 void *__xa_store(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in __xa_store() argument
1534 XA_STATE(xas, xa, index); in __xa_store()
1539 if (xa_track_free(xa) && !entry) in __xa_store()
1544 if (xa_track_free(xa)) in __xa_store()
1554 * @xa: XArray.
1569 void *xa_store(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in xa_store() argument
1573 xa_lock(xa); in xa_store()
1574 curr = __xa_store(xa, index, entry, gfp); in xa_store()
1575 xa_unlock(xa); in xa_store()
1583 * @xa: XArray.
1597 void *__xa_cmpxchg(struct xarray *xa, unsigned long index, in __xa_cmpxchg() argument
1600 XA_STATE(xas, xa, index); in __xa_cmpxchg()
1610 if (xa_track_free(xa) && entry && !curr) in __xa_cmpxchg()
1621 * @xa: XArray.
1632 * Return: 0 if the store succeeded. -EBUSY if another entry was present.
1635 int __xa_insert(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp) in __xa_insert() argument
1637 XA_STATE(xas, xa, index); in __xa_insert()
1649 if (xa_track_free(xa)) in __xa_insert()
1664 unsigned int shift = 0; in xas_set_range()
1670 while ((first & XA_CHUNK_MASK) == 0) { in xas_set_range()
1694 * @xa: XArray.
1710 void *xa_store_range(struct xarray *xa, unsigned long first, in xa_store_range() argument
1713 XA_STATE(xas, xa, 0); in xa_store_range()
1748 * @xa: XArray.
1751 * Return: A number between 0 and 63 indicating the order of the entry.
1753 int xa_get_order(struct xarray *xa, unsigned long index) in xa_get_order() argument
1755 XA_STATE(xas, xa, index); in xa_get_order()
1757 int order = 0; in xa_get_order()
1789 * @xa: XArray.
1795 * Finds an empty entry in @xa between @limit.min and @limit.max,
1801 * Return: 0 on success, -ENOMEM if memory could not be allocated or
1804 int __xa_alloc(struct xarray *xa, u32 *id, void *entry, in __xa_alloc() argument
1807 XA_STATE(xas, xa, 0); in __xa_alloc()
1811 if (WARN_ON_ONCE(!xa_track_free(xa))) in __xa_alloc()
1834 * @xa: XArray.
1841 * Finds an empty entry in @xa between @limit.min and @limit.max,
1849 * Return: 0 if the allocation succeeded without wrapping. 1 if the
1853 int __xa_alloc_cyclic(struct xarray *xa, u32 *id, void *entry, in __xa_alloc_cyclic() argument
1860 ret = __xa_alloc(xa, id, entry, limit, gfp); in __xa_alloc_cyclic()
1861 if ((xa->xa_flags & XA_FLAGS_ALLOC_WRAPPED) && ret == 0) { in __xa_alloc_cyclic()
1862 xa->xa_flags &= ~XA_FLAGS_ALLOC_WRAPPED; in __xa_alloc_cyclic()
1866 if (ret < 0 && limit.min > min) { in __xa_alloc_cyclic()
1868 ret = __xa_alloc(xa, id, entry, limit, gfp); in __xa_alloc_cyclic()
1869 if (ret == 0) in __xa_alloc_cyclic()
1873 if (ret >= 0) { in __xa_alloc_cyclic()
1875 if (*next == 0) in __xa_alloc_cyclic()
1876 xa->xa_flags |= XA_FLAGS_ALLOC_WRAPPED; in __xa_alloc_cyclic()
1884 * @xa: XArray.
1892 void __xa_set_mark(struct xarray *xa, unsigned long index, xa_mark_t mark) in __xa_set_mark() argument
1894 XA_STATE(xas, xa, index); in __xa_set_mark()
1904 * @xa: XArray.
1910 void __xa_clear_mark(struct xarray *xa, unsigned long index, xa_mark_t mark) in __xa_clear_mark() argument
1912 XA_STATE(xas, xa, index); in __xa_clear_mark()
1922 * @xa: XArray.
1932 bool xa_get_mark(struct xarray *xa, unsigned long index, xa_mark_t mark) in xa_get_mark() argument
1934 XA_STATE(xas, xa, index); in xa_get_mark()
1954 * @xa: XArray.
1962 void xa_set_mark(struct xarray *xa, unsigned long index, xa_mark_t mark) in xa_set_mark() argument
1964 xa_lock(xa); in xa_set_mark()
1965 __xa_set_mark(xa, index, mark); in xa_set_mark()
1966 xa_unlock(xa); in xa_set_mark()
1972 * @xa: XArray.
1980 void xa_clear_mark(struct xarray *xa, unsigned long index, xa_mark_t mark) in xa_clear_mark() argument
1982 xa_lock(xa); in xa_clear_mark()
1983 __xa_clear_mark(xa, index, mark); in xa_clear_mark()
1984 xa_unlock(xa); in xa_clear_mark()
1990 * @xa: XArray.
1995 * Finds the entry in @xa which matches the @filter, and has the lowest
2005 void *xa_find(struct xarray *xa, unsigned long *indexp, in xa_find() argument
2008 XA_STATE(xas, xa, *indexp); in xa_find()
2040 * @xa: XArray.
2045 * Finds the entry in @xa which matches the @filter and has the lowest
2055 void *xa_find_after(struct xarray *xa, unsigned long *indexp, in xa_find_after() argument
2058 XA_STATE(xas, xa, *indexp + 1); in xa_find_after()
2061 if (xas.xa_index == 0) in xa_find_after()
2090 unsigned int i = 0; in xas_extract_present()
2109 unsigned int i = 0; in xas_extract_marked()
2126 * @xa: The source XArray to copy from.
2152 unsigned int xa_extract(struct xarray *xa, void **dst, unsigned long start, in xa_extract() argument
2155 XA_STATE(xas, xa, start); in xa_extract()
2158 return 0; in xa_extract()
2176 .xa = node->array, in xa_delete_node()
2191 * @xa: XArray.
2199 void xa_destroy(struct xarray *xa) in xa_destroy() argument
2201 XA_STATE(xas, xa, 0); in xa_destroy()
2207 entry = xa_head_locked(xa); in xa_destroy()
2208 RCU_INIT_POINTER(xa->xa_head, NULL); in xa_destroy()
2210 if (xa_zero_busy(xa)) in xa_destroy()
2211 xa_mark_clear(xa, XA_FREE_MARK); in xa_destroy()
2236 for (i = 0; i < XA_MAX_MARKS; i++) in xa_dump_node()
2237 for (j = 0; j < XA_MARK_LONGS; j++) in xa_dump_node()
2247 pr_info("0-%lu: ", ~0UL); in xa_dump_index()
2260 if (shift == 0) { in xa_dump_entry()
2266 for (i = 0; i < XA_CHUNK_SIZE; i++) in xa_dump_entry()
2271 pr_cont("value %ld (0x%lx) [%px]\n", xa_to_value(entry), in xa_dump_entry()
2285 void xa_dump(const struct xarray *xa) in xa_dump() argument
2287 void *entry = xa->xa_head; in xa_dump()
2288 unsigned int shift = 0; in xa_dump()
2290 pr_info("xarray: %px head %px flags %x marks %d %d %d\n", xa, entry, in xa_dump()
2291 xa->xa_flags, xa_marked(xa, XA_MARK_0), in xa_dump()
2292 xa_marked(xa, XA_MARK_1), xa_marked(xa, XA_MARK_2)); in xa_dump()
2295 xa_dump_entry(entry, 0, shift); in xa_dump()