summaryrefslogtreecommitdiffstats
path: root/Documentation/core-api/xarray.rst
Commit message (Collapse)AuthorAgeFilesLines
* XArray: Add xa_for_each_rangeMatthew Wilcox (Oracle)2020-01-171-4/+6
| | | | | | | This function supports iterating over a range of an array. Also add documentation links for xa_for_each_start(). Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
* XArray: Improve documentation of search marksMatthew Wilcox (Oracle)2019-11-081-24/+36
| | | | | | | | Move most of the mark-related documentation to its own section to make it easier to understand. Add clarification that you can't search for an unset mark, and you can't yet search for combinations of marks. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
* docs: remove :c:func: annotations from xarray.rstJonathan Corbet2019-06-261-135/+135
| | | | | | | | | | | Now that the build system automatically marks up function references, we don't have to clutter the source files, so take it out. [Some paragraphs could now benefit from refilling, but that was left out to avoid obscuring the real changes.] Acked-by: Matthew Wilcox <willy@infradead.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
* XArray: Use xa_cmpxchg to implement xa_reserveMatthew Wilcox2019-02-201-1/+0
| | | | | | | | Jason feels this is clearer, and it saves a function and an exported symbol. Suggested-by: Jason Gunthorpe <jgg@ziepe.ca> Signed-off-by: Matthew Wilcox <willy@infradead.org>
* XArray: Add cyclic allocationMatthew Wilcox2019-02-061-1/+3
| | | | | | | | | | | | | | | | | | This differs slightly from the IDR equivalent in five ways. 1. It can allocate up to UINT_MAX instead of being limited to INT_MAX, like xa_alloc(). Also like xa_alloc(), it will write to the 'id' pointer before placing the entry in the XArray. 2. The 'next' cursor is allocated separately from the XArray instead of being part of the IDR. This saves memory for all the users which do not use the cyclic allocation API and suits some users better. 3. It returns -EBUSY instead of -ENOSPC. 4. It will attempt to wrap back to the minimum value on memory allocation failure as well as on an -EBUSY error, assuming that a user would rather allocate a small ID than suffer an ID allocation failure. 5. It reports whether it has wrapped, which is important to some users. Signed-off-by: Matthew Wilcox <willy@infradead.org>
* XArray: Add support for 1s-based allocationMatthew Wilcox2019-02-061-3/+7
| | | | | | | | | | | A lot of places want to allocate IDs starting at 1 instead of 0. While the xa_alloc() API supports this, it's not very efficient if lots of IDs are allocated, due to having to walk down to the bottom of the tree to see if ID 1 is available, then all the way over to the next non-allocated ID. This method marks ID 0 as being occupied which wastes one slot in the XArray, but preserves xa_empty() as working. Signed-off-by: Matthew Wilcox <willy@infradead.org>
* XArray: Change xa_insert to return -EBUSYMatthew Wilcox2019-02-061-1/+1
| | | | | | | | Userspace translates EEXIST to "File exists" which isn't a very good error message for the problem. "Device or resource busy" is a better indication of what went wrong. Signed-off-by: Matthew Wilcox <willy@infradead.org>
* XArray: Honour reserved entries in xa_insertMatthew Wilcox2019-01-061-6/+9
| | | | | | | | | xa_insert() should treat reserved entries as occupied, not as available. Also, it should treat requests to insert a NULL pointer as a request to reserve the slot. Add xa_insert_bh() and xa_insert_irq() for completeness. Signed-off-by: Matthew Wilcox <willy@infradead.org>
* XArray: Add xa_cmpxchg_irq and xa_cmpxchg_bhMatthew Wilcox2018-12-061-1/+4
| | | | | | | | These convenience wrappers match the other _irq and _bh wrappers we already have. It turns out I'd already open-coded xa_cmpxchg_irq() in the shmem code, so convert that. Signed-off-by: Matthew Wilcox <willy@infradead.org>
* XArray: Fix DocumentationMatthew Wilcox2018-11-051-1/+5
| | | | | | Minor fixes. Signed-off-by: Matthew Wilcox <willy@infradead.org>
* XArray: Handle NULL pointers differently for allocationMatthew Wilcox2018-11-051-9/+19
| | | | | | | | | For allocating XArrays, it makes sense to distinguish beteen erasing an entry and storing NULL. Storing NULL keeps the index allocated with a NULL pointer associated with it while xa_erase() frees the index. Some existing IDR users rely on this ability. Signed-off-by: Matthew Wilcox <willy@infradead.org>
* XArray: Add xa_store_bh() and xa_store_irq()Matthew Wilcox2018-11-051-1/+4
| | | | | | | These convenience wrappers disable interrupts while taking the spinlock. A number of drivers would otherwise have to open-code these functions. Signed-off-by: Matthew Wilcox <willy@infradead.org>
* XArray: Regularise xa_reserveMatthew Wilcox2018-11-051-0/+13
| | | | | | | | The xa_reserve() function was a little unusual in that it attempted to be callable for all kinds of locking scenarios. Make it look like the other APIs with __xa_reserve, xa_reserve_bh and xa_reserve_irq variants. Signed-off-by: Matthew Wilcox <willy@infradead.org>
* xarray: Add range store functionalityMatthew Wilcox2018-10-211-0/+8
| | | | | | | | | This version of xa_store_range() really only supports load and store. Our only user only needs basic load and store functionality, so there's no need to do the extra work to support marking and overlapping stores correctly yet. Signed-off-by: Matthew Wilcox <willy@infradead.org>
* xarray: Track free entries in an XArrayMatthew Wilcox2018-10-211-3/+20
| | | | | | | Add the optional ability to track which entries in an XArray are free and provide xa_alloc() to replace most of the functionality of the IDR. Signed-off-by: Matthew Wilcox <willy@infradead.org>
* xarray: Add xa_reserve and xa_releaseMatthew Wilcox2018-10-211-0/+6
| | | | | | | | This function reserves a slot in the XArray for users which need to acquire multiple locks before storing their entry in the tree and so cannot use a plain xa_store(). Signed-off-by: Matthew Wilcox <willy@infradead.org>
* xarray: Add documentationMatthew Wilcox2018-10-211-0/+404
This is documentation on how to use the XArray, not details about its internal implementation. Signed-off-by: Matthew Wilcox <willy@infradead.org> Acked-by: Josef Bacik <jbacik@fb.com>