summaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/sw
diff options
context:
space:
mode:
authorParav Pandit <parav@mellanox.com>2018-08-27 08:44:16 +0300
committerDoug Ledford <dledford@redhat.com>2018-08-30 16:31:50 -0400
commit536a631d1ec1de6ed51453954407068c10473eea (patch)
tree8b760910b1fef572ecd431229ce5c8ebb8c3b970 /drivers/infiniband/sw
parent3ccf19e25adf2d3b9c5f1e65b950b6d223e1c4c0 (diff)
downloadlinux-536a631d1ec1de6ed51453954407068c10473eea.tar.bz2
IB/rxe: Avoid NULL check when search is successful
While performing lookup in a pool, if entry is found, take the reference right there, instead of checking again outside the loop and save one branch. Signed-off-by: Parav Pandit <parav@mellanox.com> Reviewed-by: Daniel Jurgens <danielj@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/infiniband/sw')
-rw-r--r--drivers/infiniband/sw/rxe/rxe_pool.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c
index c8598b91e454..36b53fb94a49 100644
--- a/drivers/infiniband/sw/rxe/rxe_pool.c
+++ b/drivers/infiniband/sw/rxe/rxe_pool.c
@@ -450,13 +450,12 @@ void *rxe_pool_get_index(struct rxe_pool *pool, u32 index)
node = node->rb_left;
else if (elem->index < index)
node = node->rb_right;
- else
+ else {
+ kref_get(&elem->ref_cnt);
break;
+ }
}
- if (node)
- kref_get(&elem->ref_cnt);
-
out:
read_unlock_irqrestore(&pool->pool_lock, flags);
return node ? elem : NULL;