nvme: Cache the cb_fn and cb_arg in the tracker

This avoids a data dependent load to find which
callback to call in the completion path.

Change-Id: Ifa20790a7af3332a74bc45037e589668744af797
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450558
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Ben Walker 2019-04-08 15:31:46 -07:00 committed by Jim Harris
parent f7d3dd9bd6
commit d02950e6f5
7 changed files with 19 additions and 16 deletions

View File

@ -529,7 +529,7 @@ spdk_nvme_ctrlr_cmd_abort_cpl(void *ctx, const struct spdk_nvme_cpl *cpl)
next->cpl.status.sct = SPDK_NVME_SCT_GENERIC;
next->cpl.status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR;
next->cpl.status.dnr = 1;
nvme_complete_request(next, &req->cpl);
nvme_complete_request(next->cb_fn, next->cb_arg, next, &req->cpl);
nvme_free_request(next);
} else {
/* If the first abort succeeds, stop iterating. */

View File

@ -908,7 +908,8 @@ struct nvme_request *nvme_allocate_request_user_copy(struct spdk_nvme_qpair *qpa
spdk_nvme_cmd_cb cb_fn, void *cb_arg, bool host_to_controller);
static inline void
nvme_complete_request(struct nvme_request *req, struct spdk_nvme_cpl *cpl)
nvme_complete_request(spdk_nvme_cmd_cb cb_fn, void *cb_arg,
struct nvme_request *req, struct spdk_nvme_cpl *cpl)
{
struct spdk_nvme_qpair *qpair = req->qpair;
struct spdk_nvme_cpl err_cpl;
@ -938,8 +939,8 @@ nvme_complete_request(struct nvme_request *req, struct spdk_nvme_cpl *cpl)
}
}
if (req->cb_fn) {
req->cb_fn(req->cb_arg, cpl);
if (cb_fn) {
cb_fn(cb_arg, cpl);
}
}

View File

@ -70,7 +70,7 @@ nvme_cb_complete_child(void *child_arg, const struct spdk_nvme_cpl *cpl)
}
if (parent->num_children == 0) {
nvme_complete_request(parent, &parent->parent_status);
nvme_complete_request(parent->cb_fn, parent->cb_arg, parent, &parent->parent_status);
nvme_free_request(parent);
}
}

View File

@ -55,9 +55,9 @@
* NVME_MAX_SGL_DESCRIPTORS defines the maximum number of descriptors in one SGL
* segment.
*/
#define NVME_MAX_SGL_DESCRIPTORS (253)
#define NVME_MAX_SGL_DESCRIPTORS (251)
#define NVME_MAX_PRP_LIST_ENTRIES (506)
#define NVME_MAX_PRP_LIST_ENTRIES (505)
struct nvme_pcie_enum_ctx {
struct spdk_nvme_probe_ctx *probe_ctx;
@ -114,11 +114,11 @@ struct nvme_tracker {
struct nvme_request *req;
uint16_t cid;
uint16_t rsvd1;
uint16_t rsvd0;
uint32_t rsvd1;
uint32_t rsvd2;
uint64_t rsvd3;
spdk_nvme_cmd_cb cb_fn;
void *cb_arg;
uint64_t prp_sgl_bus_addr;
@ -1153,7 +1153,7 @@ nvme_pcie_qpair_complete_pending_admin_request(struct spdk_nvme_qpair *qpair)
assert(req->pid == pid);
nvme_complete_request(req, &req->cpl);
nvme_complete_request(req->cb_fn, req->cb_arg, req, &req->cpl);
nvme_free_request(req);
}
}
@ -1286,7 +1286,7 @@ nvme_pcie_qpair_complete_tracker(struct spdk_nvme_qpair *qpair, struct nvme_trac
req_from_current_proc = false;
nvme_pcie_qpair_insert_pending_admin_request(qpair, req, cpl);
} else {
nvme_complete_request(req, cpl);
nvme_complete_request(tr->cb_fn, tr->cb_arg, req, cpl);
}
if (req_from_current_proc == true) {
@ -2003,6 +2003,8 @@ nvme_pcie_qpair_submit_request(struct spdk_nvme_qpair *qpair, struct nvme_reques
TAILQ_REMOVE(&pqpair->free_tr, tr, tq_list); /* remove tr from free_tr */
TAILQ_INSERT_TAIL(&pqpair->outstanding_tr, tr, tq_list);
tr->req = req;
tr->cb_fn = req->cb_fn;
tr->cb_arg = req->cb_arg;
req->cmd.cid = tr->cid;
if (req->payload_size && req->payload.md) {

View File

@ -382,7 +382,7 @@ nvme_qpair_manual_complete_request(struct spdk_nvme_qpair *qpair,
nvme_qpair_print_completion(qpair, &cpl);
}
nvme_complete_request(req, &cpl);
nvme_complete_request(req->cb_fn, req->cb_arg, req, &cpl);
nvme_free_request(req);
}

View File

@ -209,7 +209,7 @@ static void
nvme_rdma_req_complete(struct nvme_request *req,
struct spdk_nvme_cpl *rsp)
{
nvme_complete_request(req, rsp);
nvme_complete_request(req->cb_fn, req->cb_arg, req, rsp);
nvme_free_request(req);
}

View File

@ -755,7 +755,7 @@ static void
nvme_tcp_req_complete(struct nvme_request *req,
struct spdk_nvme_cpl *rsp)
{
nvme_complete_request(req, rsp);
nvme_complete_request(req->cb_fn, req->cb_arg, req, rsp);
nvme_free_request(req);
}