Skip to content

Commit ff02945

Browse files
Christoph Hellwigaxboe
authored andcommitted
nvme: use blk_mq_complete_request_remote to avoid an indirect function call
Use the new blk_mq_complete_request_remote helper to avoid an indirect function call in the completion fast path. Reviewed-by: Daniel Wagner <dwagner@suse.de> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 8446546 commit ff02945

File tree

6 files changed

+18
-9
lines changed

6 files changed

+18
-9
lines changed

drivers/nvme/host/fc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ static DECLARE_COMPLETION(nvme_fc_unload_proceed);
227227
*/
228228
static struct device *fc_udev_device;
229229

230+
static void nvme_fc_complete_rq(struct request *rq);
230231

231232
/* *********************** FC-NVME Port Management ************************ */
232233

@@ -2033,7 +2034,8 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req)
20332034
}
20342035

20352036
__nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate);
2036-
nvme_end_request(rq, status, result);
2037+
if (!nvme_end_request(rq, status, result))
2038+
nvme_fc_complete_rq(rq);
20372039

20382040
check_error:
20392041
if (terminate_assoc)

drivers/nvme/host/nvme.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ static inline u32 nvme_bytes_to_numd(size_t len)
472472
return (len >> 2) - 1;
473473
}
474474

475-
static inline void nvme_end_request(struct request *req, __le16 status,
475+
static inline bool nvme_end_request(struct request *req, __le16 status,
476476
union nvme_result result)
477477
{
478478
struct nvme_request *rq = nvme_req(req);
@@ -481,8 +481,9 @@ static inline void nvme_end_request(struct request *req, __le16 status,
481481
rq->result = result;
482482
/* inject error when permitted by fault injection framework */
483483
nvme_should_fail(req);
484-
if (likely(!blk_should_fake_timeout(req->q)))
485-
blk_mq_complete_request(req);
484+
if (unlikely(blk_should_fake_timeout(req->q)))
485+
return true;
486+
return blk_mq_complete_request_remote(req);
486487
}
487488

488489
static inline void nvme_get_ctrl(struct nvme_ctrl *ctrl)

drivers/nvme/host/pci.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,8 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq, u16 idx)
963963

964964
req = blk_mq_tag_to_rq(nvme_queue_tagset(nvmeq), cqe->command_id);
965965
trace_nvme_sq(req, cqe->sq_head, nvmeq->sq_tail);
966-
nvme_end_request(req, cqe->status, cqe->result);
966+
if (!nvme_end_request(req, cqe->status, cqe->result))
967+
nvme_pci_complete_rq(req);
967968
}
968969

969970
static inline void nvme_update_cq_head(struct nvme_queue *nvmeq)

drivers/nvme/host/rdma.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ MODULE_PARM_DESC(register_always,
149149
static int nvme_rdma_cm_handler(struct rdma_cm_id *cm_id,
150150
struct rdma_cm_event *event);
151151
static void nvme_rdma_recv_done(struct ib_cq *cq, struct ib_wc *wc);
152+
static void nvme_rdma_complete_rq(struct request *rq);
152153

153154
static const struct blk_mq_ops nvme_rdma_mq_ops;
154155
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)
11551156

11561157
if (!refcount_dec_and_test(&req->ref))
11571158
return;
1158-
nvme_end_request(rq, req->status, req->result);
1159+
if (!nvme_end_request(rq, req->status, req->result))
1160+
nvme_rdma_complete_rq(rq);
11591161
}
11601162

11611163
static void nvme_rdma_wr_error(struct ib_cq *cq, struct ib_wc *wc,

drivers/nvme/host/tcp.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,8 @@ static int nvme_tcp_process_nvme_cqe(struct nvme_tcp_queue *queue,
464464
return -EINVAL;
465465
}
466466

467-
nvme_end_request(rq, cqe->status, cqe->result);
467+
if (!nvme_end_request(rq, cqe->status, cqe->result))
468+
nvme_complete_rq(rq);
468469
queue->nr_cqe++;
469470

470471
return 0;
@@ -654,7 +655,8 @@ static inline void nvme_tcp_end_request(struct request *rq, u16 status)
654655
{
655656
union nvme_result res = {};
656657

657-
nvme_end_request(rq, cpu_to_le16(status << 1), res);
658+
if (!nvme_end_request(rq, cpu_to_le16(status << 1), res))
659+
nvme_complete_rq(rq);
658660
}
659661

660662
static int nvme_tcp_recv_data(struct nvme_tcp_queue *queue, struct sk_buff *skb,

drivers/nvme/target/loop.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ static void nvme_loop_queue_response(struct nvmet_req *req)
116116
return;
117117
}
118118

119-
nvme_end_request(rq, cqe->status, cqe->result);
119+
if (!nvme_end_request(rq, cqe->status, cqe->result))
120+
nvme_loop_complete_rq(rq);
120121
}
121122
}
122123

0 commit comments

Comments
 (0)