From: Bob Pearson <rpearsonhpe@gmail.com>
To: jgg@nvidia.com, zyjzyj2000@gmail.com, frank.zago@hpe.com,
ian.ziemba@hpe.com, jhack@hpe.com, linux-rdma@vger.kernel.org
Cc: Bob Pearson <rpearsonhpe@gmail.com>
Subject: [PATCH v16 2/2] RDMA/rxe: Convert read side locking to rcu
Date: Sun, 12 Jun 2022 17:34:35 -0500 [thread overview]
Message-ID: <20220612223434.31462-3-rpearsonhpe@gmail.com> (raw)
In-Reply-To: <20220612223434.31462-1-rpearsonhpe@gmail.com>
Use rcu_read_lock() for protecting read side operations in rxe_pool.c.
Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
---
drivers/infiniband/sw/rxe/rxe_pool.c | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c
index 8d8f5e409585..f50620f5a0a1 100644
--- a/drivers/infiniband/sw/rxe/rxe_pool.c
+++ b/drivers/infiniband/sw/rxe/rxe_pool.c
@@ -197,16 +197,15 @@ void *rxe_pool_get_index(struct rxe_pool *pool, u32 index)
{
struct rxe_pool_elem *elem;
struct xarray *xa = &pool->xa;
- unsigned long flags;
void *obj;
- xa_lock_irqsave(xa, flags);
+ rcu_read_lock();
elem = xa_load(xa, index);
if (elem && kref_get_unless_zero(&elem->ref_cnt))
obj = elem->obj;
else
obj = NULL;
- xa_unlock_irqrestore(xa, flags);
+ rcu_read_unlock();
return obj;
}
@@ -223,16 +222,16 @@ int __rxe_cleanup(struct rxe_pool_elem *elem, bool sleepable)
struct rxe_pool *pool = elem->pool;
struct xarray *xa = &pool->xa;
static int timeout = RXE_POOL_TIMEOUT;
- unsigned long flags;
int ret, err = 0;
void *xa_ret;
+ if (sleepable)
+ might_sleep();
+
/* erase xarray entry to prevent looking up
* the pool elem from its index
*/
- xa_lock_irqsave(xa, flags);
- xa_ret = __xa_erase(xa, elem->index);
- xa_unlock_irqrestore(xa, flags);
+ xa_ret = xa_erase(xa, elem->index);
WARN_ON(xa_err(xa_ret));
/* if this is the last call to rxe_put complete the
@@ -277,7 +276,7 @@ int __rxe_cleanup(struct rxe_pool_elem *elem, bool sleepable)
pool->cleanup(elem);
if (pool->type == RXE_TYPE_MR)
- kfree(elem->obj);
+ kfree_rcu(elem->obj);
atomic_dec(&pool->num_elem);
@@ -296,12 +295,8 @@ int __rxe_put(struct rxe_pool_elem *elem)
void __rxe_finalize(struct rxe_pool_elem *elem)
{
- struct xarray *xa = &elem->pool->xa;
- unsigned long flags;
- void *ret;
-
- xa_lock_irqsave(xa, flags);
- ret = __xa_store(&elem->pool->xa, elem->index, elem, GFP_KERNEL);
- xa_unlock_irqrestore(xa, flags);
- WARN_ON(xa_err(ret));
+ void *xa_ret;
+
+ xa_ret = xa_store(&elem->pool->xa, elem->index, elem, GFP_KERNEL);
+ WARN_ON(xa_err(xa_ret));
}
--
2.34.1
next prev parent reply other threads:[~2022-06-12 22:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-12 22:34 [PATCH for-next v16 0/2] Fix race conditions in rxe_pool Bob Pearson
2022-06-12 22:34 ` [PATCH v16 1/2] RDMA/rxe: Stop lookup of partially built objects Bob Pearson
2022-06-12 22:34 ` Bob Pearson [this message]
2022-06-30 13:58 ` [PATCH for-next v16 0/2] Fix race conditions in rxe_pool Jason Gunthorpe
2022-06-30 16:58 ` Bob Pearson
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=20220612223434.31462-3-rpearsonhpe@gmail.com \
--to=rpearsonhpe@gmail.com \
--cc=frank.zago@hpe.com \
--cc=ian.ziemba@hpe.com \
--cc=jgg@nvidia.com \
--cc=jhack@hpe.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