Skip to contentSkip to conversation

nvmet: Add get_mdts op for controllers

PATCH Superseded Max Gurtovoy 2 participants 9 messages Mar 5, 2020 – Mar 6, 2020

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 nvmet: Add get_mdts op for controllers

Some transports, such as RDMA, would like to set the Maximum Data Transfer Size (MDTS) according to device/port/ctrl characteristics. This will enable the transport to set the optimal MDTS according to controller needs and device capabilities. Add a new nvmet transport op that is called during ctrl identification. This will not effect transports that don't implement this option. The return value of the new op is according to the NVMe spec definition for MDTS.

---

changes from V1:
- renamed set_mdts to get_mdts (Bart)
- added const for ctrl argument (Bart)
- updated commit message to explain return value of the new op (Bart)

---
 drivers/nvme/target/admin-cmd.c | 8 ++++++--
 drivers/nvme/target/nvmet.h     | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/nvme/target/admin-cmd.c +6 -2
index c0aa9c3..b9ec489 100644
@@ -369,8 +369,12 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
 	/* we support multiple ports, multiples hosts and ANA: */
 	id->cmic = (1 << 0) | (1 << 1) | (1 << 3);
 
-	/* no limit on data transfer sizes for now */
-	id->mdts = 0;
+	/* Limit MDTS according to transport capability */
+	if (ctrl->ops->get_mdts)
+		id->mdts = ctrl->ops->get_mdts(ctrl);
+	else
+		id->mdts = 0;
+
 	id->cntlid = cpu_to_le16(ctrl->cntlid);
 	id->ver = cpu_to_le32(ctrl->subsys->ver);
 
drivers/nvme/target/nvmet.h +1 -0
index 42ba2dd..421dff3 100644
@@ -289,6 +289,7 @@ struct nvmet_fabrics_ops {
 			struct nvmet_port *port, char *traddr);
 	u16 (*install_queue)(struct nvmet_sq *nvme_sq);
 	void (*discovery_chg)(struct nvmet_port *port);
+	u8 (*get_mdts)(const struct nvmet_ctrl *ctrl);
 };
 
 #define NVMET_MAX_INLINE_BIOVEC	8
Signature · 7 lines
1.8.3.1


_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
#1 lore raw

PATCH v2 2/3 nvmet-rdma: Implement get_mdts controller op

Set the maximal data transfer size to be 1MB (currently mdts is unlimited). This will allow calculating the amount of MR's that one ctrl should allocate to fulfill it's capabilities.

---

changes from V1:
- renamed nvmet_rdma_set_mdts to nvmet_rdma_get_mdts
- align to get_mdts callback changes

---
 drivers/nvme/target/rdma.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/nvme/target/rdma.c +8 -0
index 37d262a..d12ef0d 100644
@@ -30,6 +30,7 @@
 #define NVMET_RDMA_DEFAULT_INLINE_DATA_SIZE	PAGE_SIZE
 #define NVMET_RDMA_MAX_INLINE_SGE		4
 #define NVMET_RDMA_MAX_INLINE_DATA_SIZE		max_t(int, SZ_16K, PAGE_SIZE)
+#define NVMET_RDMA_MAX_MDTS			8
 
 struct nvmet_rdma_cmd {
 	struct ib_sge		sge[NVMET_RDMA_MAX_INLINE_SGE + 1];
@@ -1602,6 +1603,12 @@ static void nvmet_rdma_disc_port_addr(struct nvmet_req *req,
 	}
 }
 
+static u8 nvmet_rdma_get_mdts(const struct nvmet_ctrl *ctrl)
+{
+	/* Assume mpsmin == device_page_size == 4KB */
+	return NVMET_RDMA_MAX_MDTS;
+}
+
 static const struct nvmet_fabrics_ops nvmet_rdma_ops = {
 	.owner			= THIS_MODULE,
 	.type			= NVMF_TRTYPE_RDMA,
@@ -1612,6 +1619,7 @@ static void nvmet_rdma_disc_port_addr(struct nvmet_req *req,
 	.queue_response		= nvmet_rdma_queue_response,
 	.delete_ctrl		= nvmet_rdma_delete_ctrl,
 	.disc_traddr		= nvmet_rdma_disc_port_addr,
+	.get_mdts		= nvmet_rdma_get_mdts,
 };
 
 static void nvmet_rdma_remove_one(struct ib_device *ib_device, void *client_data)
Signature · 7 lines
1.8.3.1


_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
maintainer
#2 lore raw

Re: [PATCH V2 2/3] nvmet-rdma: Implement get_mdts controller op

Quoted 28 lines · Max Gurtovoy

Set the maximal data transfer size to be 1MB (currently mdts is unlimited). This will allow calculating the amount of MR's that one ctrl should allocate to fulfill it's capabilities.

---

changes from V1:
- renamed nvmet_rdma_set_mdts to nvmet_rdma_get_mdts
- align to get_mdts callback changes

---
  drivers/nvme/target/rdma.c | 8 ++++++++
  1 file changed, 8 insertions(+)
drivers/nvme/target/rdma.c +1 -0
index 37d262a..d12ef0d 100644
@@ -30,6 +30,7 @@
  #define NVMET_RDMA_DEFAULT_INLINE_DATA_SIZE	PAGE_SIZE
  #define NVMET_RDMA_MAX_INLINE_SGE		4
  #define NVMET_RDMA_MAX_INLINE_DATA_SIZE		max_t(int, SZ_16K, PAGE_SIZE)
+#define NVMET_RDMA_MAX_MDTS			8
 
  struct nvmet_rdma_cmd {
  	struct ib_sge		sge[NVMET_RDMA_MAX_INLINE_SGE + 1];

drivers/nvme/target/rdma.c static void nvmet_rdma_disc_port_addr(struct nvmet_req *req, · line 1608

Quoted 6 lines
drivers/nvme/target/rdma.c +3 -0
@@ -1602,6 +1603,12 @@ static void nvmet_rdma_disc_port_addr(struct nvmet_req *req,
  	}
  }
 
+static u8 nvmet_rdma_get_mdts(const struct nvmet_ctrl *ctrl)
+{
+	/* Assume mpsmin == device_page_size == 4KB */

This comment should come at the define entry.

Quoted 8 lines
drivers/nvme/target/rdma.c +3 -0
+	return NVMET_RDMA_MAX_MDTS;
+}
+
  static const struct nvmet_fabrics_ops nvmet_rdma_ops = {
  	.owner			= THIS_MODULE,
  	.type			= NVMF_TRTYPE_RDMA,

drivers/nvme/target/rdma.c static void nvmet_rdma_disc_port_addr(struct nvmet_req *req, · line 1625

Quoted 7 lines
drivers/nvme/target/rdma.c +1 -0
@@ -1612,6 +1619,7 @@ static void nvmet_rdma_disc_port_addr(struct nvmet_req *req,
  	.queue_response		= nvmet_rdma_queue_response,
  	.delete_ctrl		= nvmet_rdma_delete_ctrl,
  	.disc_traddr		= nvmet_rdma_disc_port_addr,
+	.get_mdts		= nvmet_rdma_get_mdts,
  };
 
  static void nvmet_rdma_remove_one(struct ib_device *ib_device, void *client_data)

_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

#3 lore raw

Re: [PATCH V2 2/3] nvmet-rdma: Implement get_mdts controller op

Quoted 30 lines · Sagi Grimberg
Quoted 27 lines · Max Gurtovoy

Set the maximal data transfer size to be 1MB (currently mdts is unlimited). This will allow calculating the amount of MR's that one ctrl should allocate to fulfill it's capabilities.

---

changes from V1:
  - renamed nvmet_rdma_set_mdts to nvmet_rdma_get_mdts
  - align to get_mdts callback changes

---
  drivers/nvme/target/rdma.c | 8 ++++++++

  1 file changed, 8 insertions(+)
drivers/nvme/target/rdma.c +1 -0
index 37d262a..d12ef0d 100644
@@ -30,6 +30,7 @@
   #define NVMET_RDMA_DEFAULT_INLINE_DATA_SIZE    PAGE_SIZE
   #define NVMET_RDMA_MAX_INLINE_SGE        4
   #define NVMET_RDMA_MAX_INLINE_DATA_SIZE        max_t(int, SZ_16K, PAGE_SIZE)
+#define NVMET_RDMA_MAX_MDTS            8
     struct nvmet_rdma_cmd {
       struct ib_sge        sge[NVMET_RDMA_MAX_INLINE_SGE + 1];
@@ -1602,6 +1603,12 @@ static void nvmet_rdma_disc_port_addr(struct 
Quoted 8 lines

drivers/nvme/target/rdma.c static void nvmet_rdma_disc_port_addr(struct nvmet_req *req, · line 1608

Quoted 6 lines
drivers/nvme/target/rdma.c +2 -0
 nvmet_req *req,
       }
   }
   +static u8 nvmet_rdma_get_mdts(const struct nvmet_ctrl *ctrl)
+{
+    /* Assume mpsmin == device_page_size == 4KB */

This comment should come at the define entry.

Sure, no problem.

Quoted 16 lines
Quoted 9 lines
drivers/nvme/target/rdma.c +3 -0
+    return NVMET_RDMA_MAX_MDTS;
+}
+
   static const struct nvmet_fabrics_ops nvmet_rdma_ops = {
       .owner            = THIS_MODULE,

      .type            = NVMF_TRTYPE_RDMA,

drivers/nvme/target/rdma.c static void nvmet_rdma_disc_port_addr(struct · line 1625

Quoted 7 lines
drivers/nvme/target/rdma.c +1 -0
@@ -1612,6 +1619,7 @@ static void nvmet_rdma_disc_port_addr(struct 
 nvmet_req *req,
       .queue_response        = nvmet_rdma_queue_response,
       .delete_ctrl        = nvmet_rdma_delete_ctrl,
       .disc_traddr        = nvmet_rdma_disc_port_addr,
+    .get_mdts        = nvmet_rdma_get_mdts,
   };
     static void nvmet_rdma_remove_one(struct ib_device *ib_device, void *client_data)

_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

#4 lore raw

PATCH v2 3/3 nvmet-rdma: allocate RW ctxs according to mdts

In reply to Max Gurtovoy

Current nvmet-rdma code allocates MR pool budget based on queue size, assuming both host and target use the same "max_pages_per_mr" count. After limiting the mdts value for RDMA controllers, we know the factor of maximum MR's per IO operation. Thus, make sure MR pool will be sufficient for the required IO depth and IO size.

That is, say host's SQ size is 100, then the MR pool budget allocated currently at target will also be 100 MRs. But 100 IO WRITE Requests with 256 sg_count(IO size above 1MB) require 200 MRs when target's "max_pages_per_mr" is 128.

---

changes from V1:
- added "Reviewed-by" signature (Christoph)

---
 drivers/nvme/target/rdma.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/nvme/target/rdma.c +4 -2
index d12ef0d..daab656 100644
@@ -976,7 +976,7 @@ 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 comp_vector, nr_cqe, ret, i;
+	int comp_vector, nr_cqe, ret, i, factor;
 
 	/*
 	 * Spread the io queues across completion vectors,
@@ -1009,7 +1009,9 @@ static int nvmet_rdma_create_queue_ib(struct nvmet_rdma_queue *queue)
 	qp_attr.qp_type = IB_QPT_RC;
 	/* +1 for drain */
 	qp_attr.cap.max_send_wr = queue->send_queue_size + 1;
-	qp_attr.cap.max_rdma_ctxs = queue->send_queue_size;
+	factor = rdma_rw_mr_factor(ndev->device, queue->cm_id->port_num,
+				   1 << NVMET_RDMA_MAX_MDTS);
+	qp_attr.cap.max_rdma_ctxs = queue->send_queue_size * factor;
 	qp_attr.cap.max_send_sge = max(ndev->device->attrs.max_sge_rd,
 					ndev->device->attrs.max_send_sge);
 
Signature · 7 lines
1.8.3.1


_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
maintainer
#5 lore raw

Re: [PATCH V2 3/3] nvmet-rdma: allocate RW ctxs according to mdts

Quoted 15 lines
drivers/nvme/target/rdma.c +1 -1
index d12ef0d..daab656 100644
@@ -976,7 +976,7 @@ 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 comp_vector, nr_cqe, ret, i;
+	int comp_vector, nr_cqe, ret, i, factor;
 
  	/*
  	 * Spread the io queues across completion vectors,

drivers/nvme/target/rdma.c static int nvmet_rdma_create_queue_ib(struct nvmet_rdma_queue *queue) · line 1013

Quoted 6 lines
drivers/nvme/target/rdma.c +2 -1
@@ -1009,7 +1009,9 @@ static int nvmet_rdma_create_queue_ib(struct nvmet_rdma_queue *queue)
  	qp_attr.qp_type = IB_QPT_RC;
  	/* +1 for drain */
  	qp_attr.cap.max_send_wr = queue->send_queue_size + 1;
-	qp_attr.cap.max_rdma_ctxs = queue->send_queue_size;
+	factor = rdma_rw_mr_factor(ndev->device, queue->cm_id->port_num,
+				   1 << NVMET_RDMA_MAX_MDTS);

Maybe I'm missing something, but aren't you missing the mpsmin multiplier? your maxpages is not (1 << 8) but rather (1 << 20) isn't it?

_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

#6 lore raw

Re: [PATCH V2 3/3] nvmet-rdma: allocate RW ctxs according to mdts

Quoted 17 lines · Sagi Grimberg
Quoted 17 lines
drivers/nvme/target/rdma.c +1 -1
index d12ef0d..daab656 100644
@@ -976,7 +976,7 @@ 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 comp_vector, nr_cqe, ret, i;
+    int comp_vector, nr_cqe, ret, i, factor;
         /*
        * Spread the io queues across completion vectors,
@@ -1009,7 +1009,9 @@ static int nvmet_rdma_create_queue_ib(struct 
 nvmet_rdma_queue *queue)
       qp_attr.qp_type = IB_QPT_RC;
Quoted 8 lines

drivers/nvme/target/rdma.c static int nvmet_rdma_create_queue_ib(struct nvmet_rdma_queue *queue) · line 1013

Quoted 5 lines
drivers/nvme/target/rdma.c +2 -1
       /* +1 for drain */
       qp_attr.cap.max_send_wr = queue->send_queue_size + 1;
-    qp_attr.cap.max_rdma_ctxs = queue->send_queue_size;
+    factor = rdma_rw_mr_factor(ndev->device, queue->cm_id->port_num,
+                   1 << NVMET_RDMA_MAX_MDTS);

Maybe I'm missing something, but aren't you missing the mpsmin multiplier? your maxpages is not (1 << 8) but rather (1 << 20) isn't it?

why ?

we support 256 pages with 4KB size each to get 1MB "mdts".

The factor is in units of RW api context (that might limit the size of the MRs according to some logic).

_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

maintainer Reviewed-by
#7 lore raw

Re: [PATCH V2 3/3] nvmet-rdma: allocate RW ctxs according to mdts

Quoted 26 lines
Quoted 17 lines
Quoted 17 lines
drivers/nvme/target/rdma.c +1 -1
index d12ef0d..daab656 100644
@@ -976,7 +976,7 @@ 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 comp_vector, nr_cqe, ret, i;
+    int comp_vector, nr_cqe, ret, i, factor;
         /*
        * Spread the io queues across completion vectors,
@@ -1009,7 +1009,9 @@ static int nvmet_rdma_create_queue_ib(struct 
 nvmet_rdma_queue *queue)
       qp_attr.qp_type = IB_QPT_RC;
Quoted 8 lines

drivers/nvme/target/rdma.c static int nvmet_rdma_create_queue_ib(struct nvmet_rdma_queue *queue) · line 1013

Quoted 5 lines
drivers/nvme/target/rdma.c +2 -1
       /* +1 for drain */
       qp_attr.cap.max_send_wr = queue->send_queue_size + 1;
-    qp_attr.cap.max_rdma_ctxs = queue->send_queue_size;
+    factor = rdma_rw_mr_factor(ndev->device, queue->cm_id->port_num,
+                   1 << NVMET_RDMA_MAX_MDTS);

Maybe I'm missing something, but aren't you missing the mpsmin multiplier? your maxpages is not (1 << 8) but rather (1 << 20) isn't it?

Quoted 5 lines

why ?

we support 256 pages with 4KB size each to get 1MB "mdts".

The factor is in units of RW api context (that might limit the size of the MRs according to some logic).

You're right, never mind...

_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme