aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/idr.h
diff options
context:
space:
mode:
authorwilly@infradead.org <willy@infradead.org>2018-06-13 11:45:55 -0700
committerJason Gunthorpe <jgg@mellanox.com>2018-06-18 11:22:54 -0600
commit3c60e868c31e4ff144776bf53ff0dfe9e9e4ec15 (patch)
tree3d6b7ce8e6569c34ed3cbee7a34fb5e799250283 /include/linux/idr.h
parentRDMA: Convert drivers to use the AH's sgid_attr in post_wr paths (diff)
downloadlinux-dev-3c60e868c31e4ff144776bf53ff0dfe9e9e4ec15.tar.xz
linux-dev-3c60e868c31e4ff144776bf53ff0dfe9e9e4ec15.zip
IDR: Expose the XArray lock
Allow users of the IDR to use the XArray lock for their own synchronisation purposes. The IDR continues to rely on the caller to handle locking, but this lets the caller use the lock embedded in the IDR data structure instead of allocating their own lock. Signed-off-by: Matthew Wilcox <willy@infradead.org> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to '')
-rw-r--r--include/linux/idr.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/idr.h b/include/linux/idr.h
index e856f4e0ab35..3e8215b2c371 100644
--- a/include/linux/idr.h
+++ b/include/linux/idr.h
@@ -98,6 +98,17 @@ static inline void idr_set_cursor(struct idr *idr, unsigned int val)
* period).
*/
+#define idr_lock(idr) xa_lock(&(idr)->idr_rt)
+#define idr_unlock(idr) xa_unlock(&(idr)->idr_rt)
+#define idr_lock_bh(idr) xa_lock_bh(&(idr)->idr_rt)
+#define idr_unlock_bh(idr) xa_unlock_bh(&(idr)->idr_rt)
+#define idr_lock_irq(idr) xa_lock_irq(&(idr)->idr_rt)
+#define idr_unlock_irq(idr) xa_unlock_irq(&(idr)->idr_rt)
+#define idr_lock_irqsave(idr, flags) \
+ xa_lock_irqsave(&(idr)->idr_rt, flags)
+#define idr_unlock_irqrestore(idr, flags) \
+ xa_unlock_irqrestore(&(idr)->idr_rt, flags)
+
void idr_preload(gfp_t gfp_mask);
int idr_alloc(struct idr *, void *ptr, int start, int end, gfp_t);