Skip to content

Commit

Permalink
IDR: Expose the XArray lock
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
willy@infradead.org authored and Jason Gunthorpe committed Jun 18, 2018
1 parent 89af969 commit 3c60e86
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions include/linux/idr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3c60e86

Please sign in to comment.