[PATCH rdma-core 2/2] mlx5: Disable locking on a QP if it is assigned to a thread domain

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



By creating a QP within a thread domain the application is guaranteeing
that the QP will not be accessed concurrently from multiple user threads.
Hence, a lock is not needed for QP that is assigned to a thread domain.

This patch disables locking on the QP if a thread domain is passed during
QP-creation.

Signed-off-by: Rohit Zambre <rzambre@xxxxxxx>
---
 providers/mlx5/verbs.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c
index 9fd765e..f7132e4 100644
--- a/providers/mlx5/verbs.c
+++ b/providers/mlx5/verbs.c
@@ -1607,6 +1607,7 @@ static struct ibv_qp *create_qp(struct ibv_context *context,
 	struct mlx5_create_qp_ex_resp  resp_ex;
 	struct mlx5_qp		       *qp;
 	int				ret;
+	int				thread_safe;
 	struct mlx5_context	       *ctx = to_mctx(context);
 	struct ibv_qp		       *ibqp;
 	int32_t				usr_idx = 0;
@@ -1751,8 +1752,14 @@ static struct ibv_qp *create_qp(struct ibv_context *context,
 
 	mlx5_init_qp_indices(qp);
 
-	if (mlx5_spinlock_init(&qp->sq.lock, !mlx5_single_threaded) ||
-	    mlx5_spinlock_init(&qp->rq.lock, !mlx5_single_threaded))
+	mparent_domain = to_mparent_domain(attr->pd);
+	if (mparent_domain && mparent_domain->mtd)
+		thread_safe = 1;
+	else
+		thread_safe = mlx5_single_threaded;
+
+	if (mlx5_spinlock_init(&qp->sq.lock, !thread_safe) ||
+	    mlx5_spinlock_init(&qp->rq.lock, !thread_safe))
 		goto err_free_qp_buf;
 
 	qp->db = mlx5_alloc_dbrec(ctx);
@@ -1789,7 +1796,6 @@ static struct ibv_qp *create_qp(struct ibv_context *context,
 		cmd.uidx = usr_idx;
 	}
 
-	mparent_domain = to_mparent_domain(attr->pd);
 	if (mparent_domain && mparent_domain->mtd)
 		bf = mparent_domain->mtd->bf;
 
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux