Skip to content

Commit 3c60e86

Browse files
willy@infradead.orgjgunthorpe
authored andcommitted
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 <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 89af969 commit 3c60e86

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

include/linux/idr.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,17 @@ static inline void idr_set_cursor(struct idr *idr, unsigned int val)
9898
* period).
9999
*/
100100

101+
#define idr_lock(idr) xa_lock(&(idr)->idr_rt)
102+
#define idr_unlock(idr) xa_unlock(&(idr)->idr_rt)
103+
#define idr_lock_bh(idr) xa_lock_bh(&(idr)->idr_rt)
104+
#define idr_unlock_bh(idr) xa_unlock_bh(&(idr)->idr_rt)
105+
#define idr_lock_irq(idr) xa_lock_irq(&(idr)->idr_rt)
106+
#define idr_unlock_irq(idr) xa_unlock_irq(&(idr)->idr_rt)
107+
#define idr_lock_irqsave(idr, flags) \
108+
xa_lock_irqsave(&(idr)->idr_rt, flags)
109+
#define idr_unlock_irqrestore(idr, flags) \
110+
xa_unlock_irqrestore(&(idr)->idr_rt, flags)
111+
101112
void idr_preload(gfp_t gfp_mask);
102113

103114
int idr_alloc(struct idr *, void *ptr, int start, int end, gfp_t);

0 commit comments

Comments
 (0)