All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jack Wang <jinpu.wang@cloud.ionos.com>
To: linux-rdma@vger.kernel.org
Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com,
	jgg@ziepe.ca, danil.kipnis@cloud.ionos.com,
	jinpu.wang@cloud.ionos.com,
	Md Haris Iqbal <haris.iqbal@cloud.ionos.com>
Subject: [PATCHv2 for-next 05/19] RDMA/rtrs-clt: Set mininum limit when create QP
Date: Thu, 17 Dec 2020 15:19:01 +0100	[thread overview]
Message-ID: <20201217141915.56989-6-jinpu.wang@cloud.ionos.com> (raw)
In-Reply-To: <20201217141915.56989-1-jinpu.wang@cloud.ionos.com>

Currently rtrs when create_qp use a coarse numbers (bigger in general),
which leads to hardware create more resources which only waste memory
with no benefits.

- SERVICE con,
For max_send_wr/max_recv_wr, it's 2 times SERVICE_CON_QUEUE_DEPTH + 2

- IO con
For max_send_wr/max_recv_wr, it's sess->queue_depth * 3 + 1

Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality")
Signed-off-by: Jack Wang <jinpu.wang@cloud.ionos.com>
Reviewed-by: Md Haris Iqbal <haris.iqbal@cloud.ionos.com>
---
 drivers/infiniband/ulp/rtrs/rtrs-clt.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
index 719254fc83a1..b3fb5fb93815 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
@@ -1511,7 +1511,7 @@ static void destroy_con(struct rtrs_clt_con *con)
 static int create_con_cq_qp(struct rtrs_clt_con *con)
 {
 	struct rtrs_clt_sess *sess = to_clt_sess(con->c.sess);
-	u32 wr_queue_size;
+	u32 max_send_wr, max_recv_wr, cq_size;
 	int err, cq_vector;
 	struct rtrs_msg_rkey_rsp *rsp;
 
@@ -1523,7 +1523,8 @@ static int create_con_cq_qp(struct rtrs_clt_con *con)
 		 * + 2 for drain and heartbeat
 		 * in case qp gets into error state
 		 */
-		wr_queue_size = SERVICE_CON_QUEUE_DEPTH * 3 + 2;
+		max_send_wr = SERVICE_CON_QUEUE_DEPTH * 2 + 2;
+		max_recv_wr = SERVICE_CON_QUEUE_DEPTH * 2 + 2;
 		/* We must be the first here */
 		if (WARN_ON(sess->s.dev))
 			return -EINVAL;
@@ -1555,25 +1556,29 @@ static int create_con_cq_qp(struct rtrs_clt_con *con)
 
 		/* Shared between connections */
 		sess->s.dev_ref++;
-		wr_queue_size =
+		max_send_wr =
 			min_t(int, sess->s.dev->ib_dev->attrs.max_qp_wr,
 			      /* QD * (REQ + RSP + FR REGS or INVS) + drain */
 			      sess->queue_depth * 3 + 1);
+		max_recv_wr =
+			min_t(int, sess->s.dev->ib_dev->attrs.max_qp_wr,
+			      sess->queue_depth * 3 + 1);
 	}
 	/* alloc iu to recv new rkey reply when server reports flags set */
 	if (sess->flags == RTRS_MSG_NEW_RKEY_F || con->c.cid == 0) {
-		con->rsp_ius = rtrs_iu_alloc(wr_queue_size, sizeof(*rsp),
+		con->rsp_ius = rtrs_iu_alloc(max_recv_wr, sizeof(*rsp),
 					      GFP_KERNEL, sess->s.dev->ib_dev,
 					      DMA_FROM_DEVICE,
 					      rtrs_clt_rdma_done);
 		if (!con->rsp_ius)
 			return -ENOMEM;
-		con->queue_size = wr_queue_size;
+		con->queue_size = max_recv_wr;
 	}
+	cq_size = max_send_wr + max_recv_wr;
 	cq_vector = con->cpu % sess->s.dev->ib_dev->num_comp_vectors;
 	err = rtrs_cq_qp_create(&sess->s, &con->c, sess->max_send_sge,
-				 cq_vector, wr_queue_size, wr_queue_size,
-				 wr_queue_size, IB_POLL_SOFTIRQ);
+				 cq_vector, cq_size, max_send_wr,
+				 max_recv_wr, IB_POLL_SOFTIRQ);
 	/*
 	 * In case of error we do not bother to clean previous allocations,
 	 * since destroy_con_cq_qp() must be called.
-- 
2.25.1


  parent reply	other threads:[~2020-12-17 14:20 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-17 14:18 [PATCHv2 for-next 00/19] Misc update for rtrs Jack Wang
2020-12-17 14:18 ` [PATCHv2 for-next 01/19] RDMA/rtrs: Extend ibtrs_cq_qp_create Jack Wang
2020-12-17 14:18 ` [PATCHv2 for-next 02/19] RMDA/rtrs-srv: Occasionally flush ongoing session closing Jack Wang
2021-01-12 19:13   ` Jason Gunthorpe
2021-01-13  8:55     ` Jinpu Wang
2020-12-17 14:18 ` [PATCHv2 for-next 03/19] RDMA/rtrs-srv: Release lock before call into close_sess Jack Wang
2020-12-17 14:19 ` [PATCHv2 for-next 04/19] RDMA/rtrs-srv: Use sysfs_remove_file_self for disconnect Jack Wang
2020-12-17 14:19 ` Jack Wang [this message]
2020-12-17 14:19 ` [PATCHv2 for-next 06/19] RDMA/rtrs-srv: Jump to dereg_mr label if allocate iu fails Jack Wang
2020-12-17 14:19 ` [PATCHv2 for-next 07/19] RDMA/rtrs: Call kobject_put in the failure path Jack Wang
2020-12-17 14:19 ` [PATCHv2 for-next 08/19] RDMA/rtrs-clt: Consolidate rtrs_clt_destroy_sysfs_root_{folder,files} Jack Wang
2020-12-17 14:19 ` [PATCHv2 for-next 09/19] RDMA/rtrs-clt: Kill wait_for_inflight_permits Jack Wang
2020-12-17 14:19 ` [PATCHv2 for-next 10/19] RDMA/rtrs-clt: Remove unnecessary 'goto out' Jack Wang
2020-12-17 14:19 ` [PATCHv2 for-next 11/19] RDMA/rtrs-clt: Kill rtrs_clt_change_state Jack Wang
2020-12-17 14:19 ` [PATCHv2 for-next 12/19] RDMA/rtrs-clt: Rename __rtrs_clt_change_state to rtrs_clt_change_state Jack Wang
2020-12-17 14:19 ` [PATCHv2 for-next 13/19] RDMA/rtrs-srv: Fix missing wr_cqe Jack Wang
2020-12-17 14:19 ` [PATCHv2 for-next 14/19] RDMA/rtrs-clt: Refactor the failure cases in alloc_clt Jack Wang
2020-12-17 14:19 ` [PATCHv2 for-next 15/19] RDMA/rtrs: Do not signal for heatbeat Jack Wang
2020-12-17 14:19 ` [PATCHv2 for-next 16/19] RDMA/rtrs-clt: Use bitmask to check sess->flags Jack Wang
2020-12-17 14:19 ` [PATCHv2 for-next 17/19] RDMA/rtrs-srv: Do not signal REG_MR Jack Wang
2020-12-17 14:19 ` [PATCHv2 for-next 18/19] RDMA/rtrs-srv: Init wr_cnt as 1 Jack Wang
2020-12-17 14:19 ` [PATCHv2 for-next 19/19] RDMA/rtrs: Fix KASAN: stack-out-of-bounds bug Jack Wang
2021-01-11  7:04 ` [PATCHv2 for-next 00/19] Misc update for rtrs Jinpu Wang
2021-01-15 19:48 ` Jason Gunthorpe

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=20201217141915.56989-6-jinpu.wang@cloud.ionos.com \
    --to=jinpu.wang@cloud.ionos.com \
    --cc=bvanassche@acm.org \
    --cc=danil.kipnis@cloud.ionos.com \
    --cc=dledford@redhat.com \
    --cc=haris.iqbal@cloud.ionos.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.