RDMA/rxe: Convert read side locking to rcu
Use rcu_read_lock() for protecting read side operations in rxe_pool.c. Link: https://lore.kernel.org/r/20220612223434.31462-3-rpearsonhpe@gmail.com Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
This commit is contained in:
parent
215d0a755e
commit
b54c2a25ac
1 changed files with 7 additions and 15 deletions
|
@ -197,16 +197,15 @@ void *rxe_pool_get_index(struct rxe_pool *pool, u32 index)
|
||||||
{
|
{
|
||||||
struct rxe_pool_elem *elem;
|
struct rxe_pool_elem *elem;
|
||||||
struct xarray *xa = &pool->xa;
|
struct xarray *xa = &pool->xa;
|
||||||
unsigned long flags;
|
|
||||||
void *obj;
|
void *obj;
|
||||||
|
|
||||||
xa_lock_irqsave(xa, flags);
|
rcu_read_lock();
|
||||||
elem = xa_load(xa, index);
|
elem = xa_load(xa, index);
|
||||||
if (elem && kref_get_unless_zero(&elem->ref_cnt))
|
if (elem && kref_get_unless_zero(&elem->ref_cnt))
|
||||||
obj = elem->obj;
|
obj = elem->obj;
|
||||||
else
|
else
|
||||||
obj = NULL;
|
obj = NULL;
|
||||||
xa_unlock_irqrestore(xa, flags);
|
rcu_read_unlock();
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
@ -223,7 +222,6 @@ int __rxe_cleanup(struct rxe_pool_elem *elem, bool sleepable)
|
||||||
struct rxe_pool *pool = elem->pool;
|
struct rxe_pool *pool = elem->pool;
|
||||||
struct xarray *xa = &pool->xa;
|
struct xarray *xa = &pool->xa;
|
||||||
static int timeout = RXE_POOL_TIMEOUT;
|
static int timeout = RXE_POOL_TIMEOUT;
|
||||||
unsigned long flags;
|
|
||||||
int ret, err = 0;
|
int ret, err = 0;
|
||||||
void *xa_ret;
|
void *xa_ret;
|
||||||
|
|
||||||
|
@ -233,9 +231,7 @@ int __rxe_cleanup(struct rxe_pool_elem *elem, bool sleepable)
|
||||||
/* erase xarray entry to prevent looking up
|
/* erase xarray entry to prevent looking up
|
||||||
* the pool elem from its index
|
* the pool elem from its index
|
||||||
*/
|
*/
|
||||||
xa_lock_irqsave(xa, flags);
|
xa_ret = xa_erase(xa, elem->index);
|
||||||
xa_ret = __xa_erase(xa, elem->index);
|
|
||||||
xa_unlock_irqrestore(xa, flags);
|
|
||||||
WARN_ON(xa_err(xa_ret));
|
WARN_ON(xa_err(xa_ret));
|
||||||
|
|
||||||
/* if this is the last call to rxe_put complete the
|
/* if this is the last call to rxe_put complete the
|
||||||
|
@ -280,7 +276,7 @@ int __rxe_cleanup(struct rxe_pool_elem *elem, bool sleepable)
|
||||||
pool->cleanup(elem);
|
pool->cleanup(elem);
|
||||||
|
|
||||||
if (pool->type == RXE_TYPE_MR)
|
if (pool->type == RXE_TYPE_MR)
|
||||||
kfree(elem->obj);
|
kfree_rcu(elem->obj);
|
||||||
|
|
||||||
atomic_dec(&pool->num_elem);
|
atomic_dec(&pool->num_elem);
|
||||||
|
|
||||||
|
@ -299,12 +295,8 @@ int __rxe_put(struct rxe_pool_elem *elem)
|
||||||
|
|
||||||
void __rxe_finalize(struct rxe_pool_elem *elem)
|
void __rxe_finalize(struct rxe_pool_elem *elem)
|
||||||
{
|
{
|
||||||
struct xarray *xa = &elem->pool->xa;
|
void *xa_ret;
|
||||||
unsigned long flags;
|
|
||||||
void *ret;
|
|
||||||
|
|
||||||
xa_lock_irqsave(xa, flags);
|
xa_ret = xa_store(&elem->pool->xa, elem->index, elem, GFP_KERNEL);
|
||||||
ret = __xa_store(&elem->pool->xa, elem->index, elem, GFP_KERNEL);
|
WARN_ON(xa_err(xa_ret));
|
||||||
xa_unlock_irqrestore(xa, flags);
|
|
||||||
WARN_ON(xa_err(ret));
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue