Skip to contentSkip to conversation

nvme-pci: add and use print io-queues helper

PATCH In review Chaitanya Kulkarni 3 participants 5 messages Apr 26, 2023 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 nvme-pci: add and use print io-queues helper

Instaed of duplicating same code in every transport, add helper in the core to print the ctrl->io_queues, since all the transports are using same format to print the information we can safely replace repetative code by a centralize helper.

Use that helper for nvme-pci transport.

---
 drivers/nvme/host/core.c | 10 ++++++++++
 drivers/nvme/host/nvme.h |  1 +
 drivers/nvme/host/pci.c  |  5 +----
 3 files changed, 12 insertions(+), 4 deletions(-)
drivers/nvme/host/core.c +10 -0
index 518c759346f0..ec430947aaf7 100644
@@ -249,6 +249,16 @@ static void nvme_delete_ctrl_sync(struct nvme_ctrl *ctrl)
 	nvme_put_ctrl(ctrl);
 }
 
+void nvme_ctrl_print_io_queues(struct nvme_ctrl *ctrl, int io_queues[])
+{
+	dev_info(ctrl->device,
+		"mapped %d/%d/%d default/read/poll queues.\n",
+		io_queues[HCTX_TYPE_DEFAULT],
+		io_queues[HCTX_TYPE_READ],
+		io_queues[HCTX_TYPE_POLL]);
+}
+EXPORT_SYMBOL_GPL(nvme_ctrl_print_io_queues);
+
 static blk_status_t nvme_error_status(u16 status)
 {
 	switch (status & 0x7ff) {
drivers/nvme/host/nvme.h +1 -0
index bf46f122e9e1..4000526cbca0 100644
@@ -767,6 +767,7 @@ void nvme_unfreeze(struct nvme_ctrl *ctrl);
 void nvme_wait_freeze(struct nvme_ctrl *ctrl);
 int nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout);
 void nvme_start_freeze(struct nvme_ctrl *ctrl);
+void nvme_ctrl_print_io_queues(struct nvme_ctrl *ctrl, int io_queues[]);
 
 static inline enum req_op nvme_req_op(struct nvme_command *cmd)
 {
drivers/nvme/host/pci.c +1 -4
index 593f86323e25..771d2bf5f402 100644
@@ -2356,10 +2356,7 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
 		nvme_suspend_io_queues(dev);
 		goto retry;
 	}
-	dev_info(dev->ctrl.device, "%d/%d/%d default/read/poll queues\n",
-					dev->io_queues[HCTX_TYPE_DEFAULT],
-					dev->io_queues[HCTX_TYPE_READ],
-					dev->io_queues[HCTX_TYPE_POLL]);
+	nvme_ctrl_print_io_queues(&dev->ctrl, dev->io_queues);
 	return 0;
 out_unlock:
 	mutex_unlock(&dev->shutdown_lock);
Signature · 1 line
2.40.0
#1 lore raw

PATCH 2/3 nvme-rdma: use helper to reduce common code

Instaed of duplicating same code in every transport to print ctrl->io_queues, use helper for nvme-rdma transport to remove repetative code.

---
 drivers/nvme/host/rdma.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/nvme/host/rdma.c +1 -6
index 0eb79696fb73..7dbf50d02b1e 100644
@@ -2170,12 +2170,7 @@ static void nvme_rdma_map_queues(struct blk_mq_tag_set *set)
 			ctrl->io_queues[HCTX_TYPE_READ];
 		blk_mq_map_queues(&set->map[HCTX_TYPE_POLL]);
 	}
-
-	dev_info(ctrl->ctrl.device,
-		"mapped %d/%d/%d default/read/poll queues.\n",
-		ctrl->io_queues[HCTX_TYPE_DEFAULT],
-		ctrl->io_queues[HCTX_TYPE_READ],
-		ctrl->io_queues[HCTX_TYPE_POLL]);
+	nvme_ctrl_print_io_queues(&ctrl->ctrl, ctrl->io_queues);
 }
 
 static const struct blk_mq_ops nvme_rdma_mq_ops = {
Signature · 1 line
2.40.0
#2 lore raw

PATCH 3/3 nvme-tcp: use helper to reduce common code

In reply to Chaitanya Kulkarni

Instaed of duplicating same code in every transport to print ctrl->io_queues, use helper for nvme-tcp transport to remove repetative code.

---
 drivers/nvme/host/tcp.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/nvme/host/tcp.c +1 -5
index 273c1f2760a4..1d775ecc6aa4 100644
@@ -2464,11 +2464,7 @@ static void nvme_tcp_map_queues(struct blk_mq_tag_set *set)
 		blk_mq_map_queues(&set->map[HCTX_TYPE_POLL]);
 	}
 
-	dev_info(ctrl->ctrl.device,
-		"mapped %d/%d/%d default/read/poll queues.\n",
-		ctrl->io_queues[HCTX_TYPE_DEFAULT],
-		ctrl->io_queues[HCTX_TYPE_READ],
-		ctrl->io_queues[HCTX_TYPE_POLL]);
+	nvme_ctrl_print_io_queues(&ctrl->ctrl, ctrl->io_queues);
 }
 
 static int nvme_tcp_poll(struct blk_mq_hw_ctx *hctx, struct io_comp_batch *iob)
Signature · 1 line
2.40.0
#3 lore raw
In reply to Chaitanya Kulkarni
Quoted 10 lines · Chaitanya Kulkarni

Instaed of duplicating same code in every transport, add helper in the core to print the ctrl->io_queues, since all the transports are using same format to print the information we can safely replace repetative code by a centralize helper.

Use that helper for nvme-pci transport.

---

forgot cover-letter, will send V2 with that, meanwhile any comments are welcome.

-ck

#4 lore raw
In reply to Chaitanya Kulkarni

Hello Chaitanya,

Quoted 1 line · Chaitanya Kulkarni

Instaed of duplicating same code in every transport, add helper in the

s/Instaed/Instead/
in all three patches

Quoted 2 lines

core to print the ctrl->io_queues, since all the transports are using same format to print the information we can safely replace repetative

s/repetative/repetitive/
in all three patches

Quoted 16 lines

code by a centralize helper.

Use that helper for nvme-pci transport.

---
 drivers/nvme/host/core.c | 10 ++++++++++
 drivers/nvme/host/nvme.h |  1 +
 drivers/nvme/host/pci.c  |  5 +----
 3 files changed, 12 insertions(+), 4 deletions(-)
drivers/nvme/host/core.c +0 -0
index 518c759346f0..ec430947aaf7 100644

drivers/nvme/host/core.c static void nvme_delete_ctrl_sync(struct nvme_ctrl *ctrl) · line 255

Quoted 7 lines
drivers/nvme/host/core.c +4 -0
@@ -249,6 +249,16 @@ static void nvme_delete_ctrl_sync(struct nvme_ctrl *ctrl)
 	nvme_put_ctrl(ctrl);
 }
 
+void nvme_ctrl_print_io_queues(struct nvme_ctrl *ctrl, int io_queues[])
+{
+	dev_info(ctrl->device,
+		"mapped %d/%d/%d default/read/poll queues.\n",

Here you have a full stop before the newline.
In the PCI print below, there is no full stop.

Looking at TCP and RDMA prints, they do have a full stop.

Which version do we want?

I think I prefer the version without full stop, probably because I'm used to seeing that print, but looking at core.c it seems to be 50/50 if a full stop is used or not at the end of a print.

Kind regards,
Niklas

Quoted 41 lines
drivers/nvme/host/core.c +6 -0
+		io_queues[HCTX_TYPE_DEFAULT],
+		io_queues[HCTX_TYPE_READ],
+		io_queues[HCTX_TYPE_POLL]);
+}
+EXPORT_SYMBOL_GPL(nvme_ctrl_print_io_queues);
+
 static blk_status_t nvme_error_status(u16 status)
 {
 	switch (status & 0x7ff) {
drivers/nvme/host/nvme.h +1 -0
index bf46f122e9e1..4000526cbca0 100644
@@ -767,6 +767,7 @@ void nvme_unfreeze(struct nvme_ctrl *ctrl);
 void nvme_wait_freeze(struct nvme_ctrl *ctrl);
 int nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout);
 void nvme_start_freeze(struct nvme_ctrl *ctrl);
+void nvme_ctrl_print_io_queues(struct nvme_ctrl *ctrl, int io_queues[]);
 
 static inline enum req_op nvme_req_op(struct nvme_command *cmd)
 {
drivers/nvme/host/pci.c +1 -4
index 593f86323e25..771d2bf5f402 100644
@@ -2356,10 +2356,7 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
 		nvme_suspend_io_queues(dev);
 		goto retry;
 	}
-	dev_info(dev->ctrl.device, "%d/%d/%d default/read/poll queues\n",
-					dev->io_queues[HCTX_TYPE_DEFAULT],
-					dev->io_queues[HCTX_TYPE_READ],
-					dev->io_queues[HCTX_TYPE_POLL]);
+	nvme_ctrl_print_io_queues(&dev->ctrl, dev->io_queues);
 	return 0;
 out_unlock:
 	mutex_unlock(&dev->shutdown_lock);
Signature · 1 line
2.40.0