linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bob Pearson <rpearsonhpe@gmail.com>
To: jgg@nvidia.com, zyjzyj2000@gmail.com, linux-rdma@vger.kernel.org
Cc: Bob Pearson <rpearsonhpe@gmail.com>
Subject: [PATCH for-next 7/7] RDMA/rxe: Rename XARRAY as INDEX
Date: Wed, 20 Oct 2021 17:05:50 -0500	[thread overview]
Message-ID: <20211020220549.36145-8-rpearsonhpe@gmail.com> (raw)
In-Reply-To: <20211020220549.36145-1-rpearsonhpe@gmail.com>

Rename RXE_POOL_XARRAY as RXE_POOL_INDEX and change several function
names .._index_... from .._xarray_.. which completes the process of
replacing red-black trees by xarrays.

Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
---
 drivers/infiniband/sw/rxe/rxe_pool.c | 38 +++++++++-------------------
 drivers/infiniband/sw/rxe/rxe_pool.h |  4 +--
 2 files changed, 14 insertions(+), 28 deletions(-)

diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c
index 6e51483c0494..6367cf68d19d 100644
--- a/drivers/infiniband/sw/rxe/rxe_pool.c
+++ b/drivers/infiniband/sw/rxe/rxe_pool.c
@@ -25,7 +25,7 @@ static const struct rxe_type_info rxe_type_info[RXE_NUM_TYPES] = {
 		.name		= "rxe-ah",
 		.size		= sizeof(struct rxe_ah),
 		.elem_offset	= offsetof(struct rxe_ah, elem),
-		.flags		= RXE_POOL_XARRAY | RXE_POOL_NO_ALLOC,
+		.flags		= RXE_POOL_INDEX | RXE_POOL_NO_ALLOC,
 		.min_index	= RXE_MIN_AH_INDEX,
 		.max_index	= RXE_MAX_AH_INDEX,
 	},
@@ -34,7 +34,7 @@ static const struct rxe_type_info rxe_type_info[RXE_NUM_TYPES] = {
 		.size		= sizeof(struct rxe_srq),
 		.elem_offset	= offsetof(struct rxe_srq, elem),
 		.cleanup	= rxe_srq_cleanup,
-		.flags		= RXE_POOL_XARRAY | RXE_POOL_NO_ALLOC,
+		.flags		= RXE_POOL_INDEX | RXE_POOL_NO_ALLOC,
 		.min_index	= RXE_MIN_SRQ_INDEX,
 		.max_index	= RXE_MAX_SRQ_INDEX,
 	},
@@ -43,7 +43,7 @@ static const struct rxe_type_info rxe_type_info[RXE_NUM_TYPES] = {
 		.size		= sizeof(struct rxe_qp),
 		.elem_offset	= offsetof(struct rxe_qp, elem),
 		.cleanup	= rxe_qp_cleanup,
-		.flags		= RXE_POOL_XARRAY | RXE_POOL_NO_ALLOC,
+		.flags		= RXE_POOL_INDEX | RXE_POOL_NO_ALLOC,
 		.min_index	= RXE_MIN_QP_INDEX,
 		.max_index	= RXE_MAX_QP_INDEX,
 	},
@@ -59,7 +59,7 @@ static const struct rxe_type_info rxe_type_info[RXE_NUM_TYPES] = {
 		.size		= sizeof(struct rxe_mr),
 		.elem_offset	= offsetof(struct rxe_mr, elem),
 		.cleanup	= rxe_mr_cleanup,
-		.flags		= RXE_POOL_XARRAY,
+		.flags		= RXE_POOL_INDEX,
 		.max_index	= RXE_MAX_MR_INDEX,
 		.min_index	= RXE_MIN_MR_INDEX,
 	},
@@ -68,7 +68,7 @@ static const struct rxe_type_info rxe_type_info[RXE_NUM_TYPES] = {
 		.size		= sizeof(struct rxe_mw),
 		.elem_offset	= offsetof(struct rxe_mw, elem),
 		.cleanup	= rxe_mw_cleanup,
-		.flags		= RXE_POOL_XARRAY | RXE_POOL_NO_ALLOC,
+		.flags		= RXE_POOL_INDEX | RXE_POOL_NO_ALLOC,
 		.max_index	= RXE_MAX_MW_INDEX,
 		.min_index	= RXE_MIN_MW_INDEX,
 	},
@@ -103,7 +103,7 @@ void rxe_pool_init(
 
 	atomic_set(&pool->num_elem, 0);
 
-	if (info->flags & RXE_POOL_XARRAY) {
+	if (info->flags & RXE_POOL_INDEX) {
 		xa_init_flags(&pool->xarray.xa, XA_FLAGS_ALLOC);
 		pool->xarray.limit.max = info->max_index;
 		pool->xarray.limit.min = info->min_index;
@@ -173,7 +173,7 @@ static void *__rxe_alloc_locked(struct rxe_pool *pool)
 	elem->pool = pool;
 	elem->obj = obj;
 
-	if (pool->flags & RXE_POOL_XARRAY) {
+	if (pool->flags & RXE_POOL_INDEX) {
 		err = __xa_alloc_cyclic(&pool->xarray.xa, &elem->index, elem,
 					pool->xarray.limit,
 					&pool->xarray.next, GFP_KERNEL);
@@ -264,7 +264,7 @@ int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem)
 	elem->pool = pool;
 	elem->obj = (u8 *)elem - pool->elem_offset;
 
-	if (pool->flags & RXE_POOL_XARRAY) {
+	if (pool->flags & RXE_POOL_INDEX) {
 		err = __xa_alloc_cyclic(&pool->xarray.xa, &elem->index, elem,
 					pool->xarray.limit,
 					&pool->xarray.next, GFP_KERNEL);
@@ -283,7 +283,7 @@ int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem)
 	return -EINVAL;
 }
 
-static void *__rxe_get_xarray_locked(struct rxe_pool *pool, u32 index)
+void *rxe_pool_get_index_locked(struct rxe_pool *pool, u32 index)
 {
 	struct rxe_pool_elem *elem;
 	void *obj = NULL;
@@ -295,31 +295,17 @@ static void *__rxe_get_xarray_locked(struct rxe_pool *pool, u32 index)
 	return obj;
 }
 
-static void *__rxe_get_xarray(struct rxe_pool *pool, u32 index)
+void *rxe_pool_get_index(struct rxe_pool *pool, u32 index)
 {
 	void *obj;
 
 	xa_lock_bh(&pool->xarray.xa);
-	obj = __rxe_get_xarray_locked(pool, index);
+	obj = rxe_pool_get_index_locked(pool, index);
 	xa_unlock_bh(&pool->xarray.xa);
 
 	return obj;
 }
 
-void *rxe_pool_get_index_locked(struct rxe_pool *pool, u32 index)
-{
-	if (pool->flags & RXE_POOL_XARRAY)
-		return __rxe_get_xarray_locked(pool, index);
-	return NULL;
-}
-
-void *rxe_pool_get_index(struct rxe_pool *pool, u32 index)
-{
-	if (pool->flags & RXE_POOL_XARRAY)
-		return __rxe_get_xarray(pool, index);
-	return NULL;
-}
-
 void *rxe_pool_get_key_locked(struct rxe_pool *pool, void *key)
 {
 	struct rb_node *node;
@@ -413,7 +399,7 @@ static int __rxe_fini(struct rxe_pool_elem *elem)
 
 	done = refcount_dec_if_one(&elem->refcnt);
 	if (done) {
-		if (pool->flags & RXE_POOL_XARRAY)
+		if (pool->flags & RXE_POOL_INDEX)
 			__xa_erase(&pool->xarray.xa, elem->index);
 		if (pool->flags & RXE_POOL_KEY)
 			rb_erase(&elem->key_node, &pool->key.tree);
diff --git a/drivers/infiniband/sw/rxe/rxe_pool.h b/drivers/infiniband/sw/rxe/rxe_pool.h
index 191e5aea454f..95a6b1e5232f 100644
--- a/drivers/infiniband/sw/rxe/rxe_pool.h
+++ b/drivers/infiniband/sw/rxe/rxe_pool.h
@@ -14,8 +14,8 @@
 #define RXE_POOL_CACHE_FLAGS	(0)
 
 enum rxe_pool_flags {
+	RXE_POOL_INDEX		= BIT(1),
 	RXE_POOL_KEY		= BIT(2),
-	RXE_POOL_XARRAY		= BIT(3),
 	RXE_POOL_NO_ALLOC	= BIT(4),
 };
 
@@ -72,7 +72,7 @@ struct rxe_pool {
 	size_t			elem_size;
 	size_t			elem_offset;
 
-	/* only used if xarray */
+	/* only used if indexed */
 	struct {
 		struct xarray		xa;
 		struct xa_limit		limit;
-- 
2.30.2


      parent reply	other threads:[~2021-10-20 22:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-20 22:05 [PATCH for-next 0/7] Replace red-black tree by xarray Bob Pearson
2021-10-20 22:05 ` [PATCH for-next 1/7] RDMA/rxe: Replace irqsave locks with bh locks Bob Pearson
2021-10-20 22:05 ` [PATCH for-next 2/7] RDMA/rxe: Cleanup rxe_pool_entry Bob Pearson
2021-10-20 22:05 ` [PATCH for-next 3/7] RDMA/rxe: Add xarray support to rxe_pool.c Bob Pearson
2021-10-21 11:53   ` Dennis Dalessandro
2021-10-21 17:02     ` Bob Pearson
2021-10-20 22:05 ` [PATCH for-next 4/7] RDMA/rxe: Replace pool_lock by xa_lock Bob Pearson
2021-10-20 22:05 ` [PATCH for-next 5/7] RDMA/rxe: Convert remaining pools to xarrays Bob Pearson
2021-10-20 22:05 ` [PATCH for-next 6/7] RDMA/rxe: Remove old index code from rxe_pool.c Bob Pearson
2021-10-20 22:05 ` Bob Pearson [this message]

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=20211020220549.36145-8-rpearsonhpe@gmail.com \
    --to=rpearsonhpe@gmail.com \
    --cc=jgg@nvidia.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=zyjzyj2000@gmail.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).