All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Peter Zijlstra <peterz@infradead.org>,
	linux-block@vger.kernel.org, linux-nvme@lists.infrdead.org
Subject: [PATCH 12/12] nvme: use blk_mq_complete_request_remote to avoid an indirect function call
Date: Thu, 11 Jun 2020 08:44:52 +0200	[thread overview]
Message-ID: <20200611064452.12353-13-hch@lst.de> (raw)
In-Reply-To: <20200611064452.12353-1-hch@lst.de>

Use the new blk_mq_complete_request_remote helper to avoid an indirect
function call in the completion fast path.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvme/host/fc.c     | 4 +++-
 drivers/nvme/host/nvme.h   | 7 ++++---
 drivers/nvme/host/pci.c    | 3 ++-
 drivers/nvme/host/rdma.c   | 4 +++-
 drivers/nvme/host/tcp.c    | 6 ++++--
 drivers/nvme/target/loop.c | 3 ++-
 6 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index cb0007592c12ad..c04e97b858e54f 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -227,6 +227,7 @@ static DECLARE_COMPLETION(nvme_fc_unload_proceed);
  */
 static struct device *fc_udev_device;
 
+static void nvme_fc_complete_rq(struct request *rq);
 
 /* *********************** FC-NVME Port Management ************************ */
 
@@ -2033,7 +2034,8 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req)
 	}
 
 	__nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate);
-	nvme_end_request(rq, status, result);
+	if (!nvme_end_request(rq, status, result))
+		nvme_fc_complete_rq(rq);
 
 check_error:
 	if (terminate_assoc)
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index cb500d51c3a968..6f3a9e49f6b6b3 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -472,7 +472,7 @@ static inline u32 nvme_bytes_to_numd(size_t len)
 	return (len >> 2) - 1;
 }
 
-static inline void nvme_end_request(struct request *req, __le16 status,
+static inline bool nvme_end_request(struct request *req, __le16 status,
 		union nvme_result result)
 {
 	struct nvme_request *rq = nvme_req(req);
@@ -481,8 +481,9 @@ static inline void nvme_end_request(struct request *req, __le16 status,
 	rq->result = result;
 	/* inject error when permitted by fault injection framework */
 	nvme_should_fail(req);
-	if (likely(!blk_should_fake_timeout(req->q)))
-		blk_mq_complete_request(req);
+	if (unlikely(blk_should_fake_timeout(req->q)))
+		return true;
+	return blk_mq_complete_request_remote(req);
 }
 
 static inline void nvme_get_ctrl(struct nvme_ctrl *ctrl)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index d690d5593a8095..6a44d5874c7945 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -963,7 +963,8 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq, u16 idx)
 
 	req = blk_mq_tag_to_rq(nvme_queue_tagset(nvmeq), cqe->command_id);
 	trace_nvme_sq(req, cqe->sq_head, nvmeq->sq_tail);
-	nvme_end_request(req, cqe->status, cqe->result);
+	if (!nvme_end_request(req, cqe->status, cqe->result))
+		nvme_pci_complete_rq(req);
 }
 
 static inline void nvme_update_cq_head(struct nvme_queue *nvmeq)
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index 9c02cf494a8257..97b1054efb8409 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -149,6 +149,7 @@ MODULE_PARM_DESC(register_always,
 static int nvme_rdma_cm_handler(struct rdma_cm_id *cm_id,
 		struct rdma_cm_event *event);
 static void nvme_rdma_recv_done(struct ib_cq *cq, struct ib_wc *wc);
+static void nvme_rdma_complete_rq(struct request *rq);
 
 static const struct blk_mq_ops nvme_rdma_mq_ops;
 static const struct blk_mq_ops nvme_rdma_admin_mq_ops;
@@ -1155,7 +1156,8 @@ static void nvme_rdma_end_request(struct nvme_rdma_request *req)
 
 	if (!refcount_dec_and_test(&req->ref))
 		return;
-	nvme_end_request(rq, req->status, req->result);
+	if (!nvme_end_request(rq, req->status, req->result))
+		nvme_rdma_complete_rq(rq);
 }
 
 static void nvme_rdma_wr_error(struct ib_cq *cq, struct ib_wc *wc,
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 1843110ec34f8a..1b5c24624df167 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -464,7 +464,8 @@ static int nvme_tcp_process_nvme_cqe(struct nvme_tcp_queue *queue,
 		return -EINVAL;
 	}
 
-	nvme_end_request(rq, cqe->status, cqe->result);
+	if (!nvme_end_request(rq, cqe->status, cqe->result))
+		nvme_complete_rq(rq);
 	queue->nr_cqe++;
 
 	return 0;
@@ -654,7 +655,8 @@ static inline void nvme_tcp_end_request(struct request *rq, u16 status)
 {
 	union nvme_result res = {};
 
-	nvme_end_request(rq, cpu_to_le16(status << 1), res);
+	if (!nvme_end_request(rq, cpu_to_le16(status << 1), res))
+		nvme_complete_rq(rq);
 }
 
 static int nvme_tcp_recv_data(struct nvme_tcp_queue *queue, struct sk_buff *skb,
diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c
index 0d54e730cbf2a7..1b9c246a849bc3 100644
--- a/drivers/nvme/target/loop.c
+++ b/drivers/nvme/target/loop.c
@@ -116,7 +116,8 @@ static void nvme_loop_queue_response(struct nvmet_req *req)
 			return;
 		}
 
-		nvme_end_request(rq, cqe->status, cqe->result);
+		if (!nvme_end_request(rq, cqe->status, cqe->result))
+			nvme_loop_complete_rq(rq);
 	}
 }
 
-- 
2.26.2


  parent reply	other threads:[~2020-06-11  6:45 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-11  6:44 blk_mq_complete_request overhaul Christoph Hellwig
2020-06-11  6:44 ` [PATCH 01/12] blk-mq: merge blk-softirq.c into blk-mq.c Christoph Hellwig
2020-06-18 14:35   ` Daniel Wagner
2020-06-11  6:44 ` [PATCH 02/12] blk-mq: factor out a helper to reise the block softirq Christoph Hellwig
2020-06-18 14:34   ` Daniel Wagner
2020-06-18 14:37     ` Daniel Wagner
2020-06-18 14:37       ` Daniel Wagner
2020-06-18 14:50   ` Daniel Wagner
2020-06-18 14:50     ` Daniel Wagner
2020-06-11  6:44 ` [PATCH 03/12] blk-mq: remove raise_blk_irq Christoph Hellwig
2020-06-18 15:02   ` Daniel Wagner
2020-06-18 15:02     ` Daniel Wagner
2020-06-11  6:44 ` [PATCH 04/12] blk-mq: complete polled requests directly Christoph Hellwig
2020-06-18 15:50   ` Daniel Wagner
2020-06-18 15:50     ` Daniel Wagner
2020-06-11  6:44 ` [PATCH 05/12] blk-mq: short cut the IPI path in blk_mq_force_complete_rq for !SMP Christoph Hellwig
2020-06-18 15:52   ` Daniel Wagner
2020-06-18 15:52     ` Daniel Wagner
2020-06-11  6:44 ` [PATCH 06/12] blk-mq: merge the softirq vs non-softirq IPI logic Christoph Hellwig
2020-06-18 16:12   ` Daniel Wagner
2020-06-18 16:12     ` Daniel Wagner
2020-06-11  6:44 ` [PATCH 07/12] blk-mq: move failure injection out of blk_mq_complete_request Christoph Hellwig
2020-06-18 16:18   ` Daniel Wagner
2020-06-11  6:44 ` [PATCH 08/12] blk-mq: remove the get_cpu/put_cpu pair in blk_mq_complete_request Christoph Hellwig
2020-06-18 16:24   ` Daniel Wagner
2020-06-11  6:44 ` [PATCH 09/12] blk-mq: factor out a blk_mq_complete_need_ipi helper Christoph Hellwig
2020-06-18 16:33   ` Daniel Wagner
2020-06-18 16:33     ` Daniel Wagner
2020-06-11  6:44 ` [PATCH 10/12] blk-mq: add a new blk_mq_complete_request_remote API Christoph Hellwig
2020-06-18 16:39   ` Daniel Wagner
2020-06-18 16:39     ` Daniel Wagner
2020-06-11  6:44 ` [PATCH 11/12] nvme-rdma: factor out a nvme_rdma_end_request helper Christoph Hellwig
2020-06-18 16:42   ` Daniel Wagner
2020-06-11  6:44 ` Christoph Hellwig [this message]
2020-06-18 16:47   ` [PATCH 12/12] nvme: use blk_mq_complete_request_remote to avoid an indirect function call Daniel Wagner
2020-06-18 16:47     ` Daniel Wagner
2020-06-18 14:11 ` blk_mq_complete_request overhaul Christoph Hellwig
2020-06-18 14:11   ` Christoph Hellwig
2020-06-18 14:54   ` Jens Axboe
2020-06-18 14:54     ` Jens Axboe

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=20200611064452.12353-13-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infrdead.org \
    --cc=peterz@infradead.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.