Message ID | 20180613123403.25233-2-willy@infradead.org (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Jason Gunthorpe |
Headers | show |
On Wed, Jun 13, 2018 at 05:34:02AM -0700, Matthew Wilcox wrote: > 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> > include/linux/idr.h | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/include/linux/idr.h b/include/linux/idr.h > index e856f4e0ab35..109d7a3c8d56 100644 > +++ 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_xa) > +#define idr_unlock(idr) xa_unlock(&(idr)->idr_xa) > +#define idr_lock_bh(idr) xa_lock_bh(&(idr)->idr_xa) > +#define idr_unlock_bh(idr) xa_unlock_bh(&(idr)->idr_xa) > +#define idr_lock_irq(idr) xa_lock_irq(&(idr)->idr_xa) > +#define idr_unlock_irq(idr) xa_unlock_irq(&(idr)->idr_xa) > +#define idr_lock_irqsave(idr, flags) \ > + xa_lock_irqsave(&(idr)->idr_xa, flags) > +#define idr_unlock_irqrestore(idr, flags) \ > + xa_unlock_irqrestore(&(idr)->idr_xa, flags) > + > void idr_preload(gfp_t gfp_mask); Hmm, what do I need to apply this? drivers/infiniband/core/mad.c: In function ‘ib_register_mad_agent’: drivers/infiniband/core/mad.c:387:34: error: ‘struct idr’ has no member named ‘idr_xa’; did you mean ‘idr_rt’? idr_lock(&ib_mad_clients); ^ idr_rt Linus's master (be779f03d563981) doesn't seem to have idr_xa? Jason -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Jun 13, 2018 at 11:30:57AM -0600, Jason Gunthorpe wrote: > Hmm, what do I need to apply this? > > drivers/infiniband/core/mad.c: In function ‘ib_register_mad_agent’: > drivers/infiniband/core/mad.c:387:34: error: ‘struct idr’ has no member named ‘idr_xa’; did you mean ‘idr_rt’? > idr_lock(&ib_mad_clients); > ^ > idr_rt > > Linus's master (be779f03d563981) doesn't seem to have idr_xa? *groan*. My fault. I just sent a replacement 1/2. Sorry! -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/include/linux/idr.h b/include/linux/idr.h index e856f4e0ab35..109d7a3c8d56 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_xa) +#define idr_unlock(idr) xa_unlock(&(idr)->idr_xa) +#define idr_lock_bh(idr) xa_lock_bh(&(idr)->idr_xa) +#define idr_unlock_bh(idr) xa_unlock_bh(&(idr)->idr_xa) +#define idr_lock_irq(idr) xa_lock_irq(&(idr)->idr_xa) +#define idr_unlock_irq(idr) xa_unlock_irq(&(idr)->idr_xa) +#define idr_lock_irqsave(idr, flags) \ + xa_lock_irqsave(&(idr)->idr_xa, flags) +#define idr_unlock_irqrestore(idr, flags) \ + xa_unlock_irqrestore(&(idr)->idr_xa, flags) + void idr_preload(gfp_t gfp_mask); int idr_alloc(struct idr *, void *ptr, int start, int end, gfp_t);
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> --- include/linux/idr.h | 11 +++++++++++ 1 file changed, 11 insertions(+)