LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: hans.westgaard.ry@oracle.com, Doug Ledford <dledford@redhat.com>,
	Jason Gunthorpe <jgg@mellanox.com>
Cc: "Matthew Wilcox" <willy@infradead.org>,
	linux-rdma@vger.kernel.org,
	"Håkon Bugge" <haakon.bugge@oracle.com>,
	"Parav Pandit" <parav@mellanox.com>,
	"Jack Morgenstein" <jackm@dev.mellanox.co.il>,
	"Pravin Shedge" <pravin.shedge4linux@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] IDR: Expose the XArray lock
Date: Wed, 13 Jun 2018 11:45:55 -0700	[thread overview]
Message-ID: <20180613184555.4503-1-willy@infradead.org> (raw)
In-Reply-To: <20180613123403.25233-2-willy@infradead.org>

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..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);
-- 
2.17.1


  parent reply	other threads:[~2018-06-13 18:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-13 12:34 [PATCH v3 0/2] Convert IB/mad to use an IDR for agent IDs Matthew Wilcox
2018-06-13 12:34 ` [PATCH v3 1/2] IDR: Expose the XArray lock Matthew Wilcox
2018-06-13 17:30   ` Jason Gunthorpe
2018-06-13 18:49     ` Matthew Wilcox
2018-06-13 18:45   ` Matthew Wilcox [this message]
2018-06-13 12:34 ` [PATCH v3 2/2] IB/mad: Use IDR for agent IDs Matthew Wilcox
2018-06-18 17:26   ` Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180613184555.4503-1-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=dledford@redhat.com \
    --cc=haakon.bugge@oracle.com \
    --cc=hans.westgaard.ry@oracle.com \
    --cc=jackm@dev.mellanox.co.il \
    --cc=jgg@mellanox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=parav@mellanox.com \
    --cc=pravin.shedge4linux@gmail.com \
    --subject='Re: [PATCH 1/2] IDR: Expose the XArray lock' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).