linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: sagi@grimberg.me (Sagi Grimberg)
Subject: [PATCH v3 9/9] nvmet-rdma: assign cq completion vector based on the port allowed cpus
Date: Wed,  8 Nov 2017 11:57:42 +0200	[thread overview]
Message-ID: <20171108095742.25365-10-sagi@grimberg.me> (raw)
In-Reply-To: <20171108095742.25365-1-sagi@grimberg.me>

We take a cpu assignment from the port configured cpulist
(spread uniformly accross them) and pass it to the queue pair
as an affinity hint.

Note that if the rdma device does not expose a vector affinity mask,
or the core couldn't find a match, it will fallback to the old behavior
as we don't have sufficient information to do the "correct" vector
assignment.

Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
---
 drivers/nvme/target/rdma.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c
index d9cdfd2bd623..98d7f2ded511 100644
--- a/drivers/nvme/target/rdma.c
+++ b/drivers/nvme/target/rdma.c
@@ -892,7 +892,8 @@ static int nvmet_rdma_create_queue_ib(struct nvmet_rdma_queue *queue)
 {
 	struct ib_qp_init_attr qp_attr;
 	struct nvmet_rdma_device *ndev = queue->dev;
-	int ret, i;
+	struct nvmet_port *port = queue->port;
+	int ret, cpu, i;
 
 	memset(&qp_attr, 0, sizeof(qp_attr));
 	qp_attr.create_flags = IB_QP_CREATE_ASSIGN_CQS;
@@ -916,6 +917,14 @@ static int nvmet_rdma_create_queue_ib(struct nvmet_rdma_queue *queue)
 	else
 		qp_attr.cap.max_recv_sge = 2;
 
+	/*
+	 * Spread the io queues across port cpus,
+	 * but still keep all admin queues on cpu 0.
+	 */
+	cpu = !queue->host_qid ? 0 : port->cpus[queue->idx % port->nr_cpus];
+	qp_attr.affinity_hint = cpu;
+	qp_attr.create_flags |= IB_QP_CREATE_AFFINITY_HINT;
+
 	ret = rdma_create_qp(queue->cm_id, ndev->pd, &qp_attr);
 	if (ret) {
 		pr_err("failed to create_qp ret= %d\n", ret);
@@ -1052,6 +1061,7 @@ nvmet_rdma_alloc_queue(struct nvmet_rdma_device *ndev,
 	INIT_WORK(&queue->release_work, nvmet_rdma_release_queue_work);
 	queue->dev = ndev;
 	queue->cm_id = cm_id;
+	queue->port = cm_id->context;
 
 	spin_lock_init(&queue->state_lock);
 	queue->state = NVMET_RDMA_Q_CONNECTING;
@@ -1170,7 +1180,6 @@ static int nvmet_rdma_queue_connect(struct rdma_cm_id *cm_id,
 		ret = -ENOMEM;
 		goto put_device;
 	}
-	queue->port = cm_id->context;
 
 	if (queue->host_qid == 0) {
 		/* Let inflight controller teardown complete */
-- 
2.14.1

  parent reply	other threads:[~2017-11-08  9:57 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-08  9:57 [PATCH v3 0/9] Introduce per-device completion queue pools Sagi Grimberg
2017-11-08  9:57 ` [PATCH v3 1/9] RDMA/core: Add implicit " Sagi Grimberg
2017-11-09 10:45   ` Max Gurtovoy
2017-11-09 17:31     ` Sagi Grimberg
2017-11-09 17:33       ` Bart Van Assche
2017-11-13 20:28         ` Sagi Grimberg
2017-11-14 16:28   ` Bart Van Assche
2017-11-20 12:31     ` Sagi Grimberg
2017-12-11 23:50   ` [v3,1/9] " Jason Gunthorpe
2018-01-03 17:47     ` Jason Gunthorpe
2017-11-08  9:57 ` [PATCH v3 2/9] IB/isert: use implicit CQ allocation Sagi Grimberg
2017-11-08 10:27   ` Nicholas A. Bellinger
2017-11-14  9:14   ` Max Gurtovoy
2017-11-08  9:57 ` [PATCH v3 3/9] IB/iser: " Sagi Grimberg
2017-11-08 10:25   ` Nicholas A. Bellinger
2017-11-08  9:57 ` [PATCH v3 4/9] IB/srpt: " Sagi Grimberg
2017-11-08  9:57 ` [PATCH v3 5/9] svcrdma: Use RDMA core " Sagi Grimberg
2017-11-08  9:57 ` [PATCH v3 6/9] nvme-rdma: use " Sagi Grimberg
2017-11-08  9:57 ` [PATCH v3 7/9] nvmet-rdma: " Sagi Grimberg
2017-11-08  9:57 ` [PATCH v3 8/9] nvmet: allow assignment of a cpulist for each nvmet port Sagi Grimberg
2017-11-08  9:57 ` Sagi Grimberg [this message]
2017-11-08 16:42 ` [PATCH v3 0/9] Introduce per-device completion queue pools Chuck Lever
2017-11-09 17:06   ` Sagi Grimberg
2017-11-10 19:27     ` Chuck Lever
2017-11-13 20:47       ` Sagi Grimberg
2017-11-13 22:15         ` Chuck Lever
2017-11-20 12:08           ` Sagi Grimberg
2017-11-20 15:54             ` Chuck Lever
2017-11-09 16:42 ` Bart Van Assche
2017-11-09 17:22   ` Sagi Grimberg
2017-11-09 17:31     ` Bart Van Assche
2017-11-13 20:31       ` Sagi Grimberg
2017-11-13 20:34         ` Jason Gunthorpe
2017-11-13 20:48           ` Sagi Grimberg
2017-11-14  2:48             ` Jason Gunthorpe
2017-11-20 12:10               ` Sagi Grimberg
2017-11-20 19:24                 ` Jason Gunthorpe
2017-11-20 21:29                   ` Bart Van Assche
2017-11-14 16:21         ` Bart Van Assche
2017-11-20 12:26           ` Sagi Grimberg
2017-11-14 10:06       ` Max Gurtovoy
2017-11-20 12:20         ` Sagi Grimberg
2017-11-09 18:52     ` Leon Romanovsky
2017-11-13 20:32       ` Sagi Grimberg
2017-11-13 22:11 ` Doug Ledford

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=20171108095742.25365-10-sagi@grimberg.me \
    --to=sagi@grimberg.me \
    /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;
as well as URLs for NNTP newsgroup(s).