@@ -860,6 +860,8 @@ static inline int __must_check xa_insert_irq(struct xarray *xa,
* stores the index into the @id pointer, then stores the entry at
* that index. A concurrent lookup will not see an uninitialised @id.
*
+ * Always allocates the entry at the smallest possible index.
+ *
* Must only be operated on an xarray initialized with flag XA_FLAGS_ALLOC set
* in xa_init_flags().
*
@@ -893,6 +895,8 @@ static inline __must_check int xa_alloc(struct xarray *xa, u32 *id,
* stores the index into the @id pointer, then stores the entry at
* that index. A concurrent lookup will not see an uninitialised @id.
*
+ * Always allocates the entry at the smallest possible index.
+ *
* Must only be operated on an xarray initialized with flag XA_FLAGS_ALLOC set
* in xa_init_flags().
*
@@ -926,6 +930,8 @@ static inline int __must_check xa_alloc_bh(struct xarray *xa, u32 *id,
* stores the index into the @id pointer, then stores the entry at
* that index. A concurrent lookup will not see an uninitialised @id.
*
+ * Always allocates the entry at the smallest possible index.
+ *
* Must only be operated on an xarray initialized with flag XA_FLAGS_ALLOC set
* in xa_init_flags().
*
@@ -1831,6 +1831,8 @@ EXPORT_SYMBOL(xa_get_order);
* stores the index into the @id pointer, then stores the entry at
* that index. A concurrent lookup will not see an uninitialised @id.
*
+ * Always allocates the entry at the smallest possible index.
+ *
* Must only be operated on an xarray initialized with flag XA_FLAGS_ALLOC set
* in xa_init_flags().
*
The deprecated IDR data structure was used to allocate *small* ids for things, and the property that the ids are small is often desireable for various reasons. However, the IDR interface is deprecated in favor of XArray. Clarify that when replacing IDR with XArray, you do not give up the guarantee that the generated ids are small, even if you use a very large range such as xa_limit_32b. Signed-off-by: Alice Ryhl <aliceryhl@google.com> --- Sent previously here: https://lore.kernel.org/all/20240201084739.1452854-1-aliceryhl@google.com/ include/linux/xarray.h | 6 ++++++ lib/xarray.c | 2 ++ 2 files changed, 8 insertions(+)