nvme: optimize nvme_allocate_request memsets
The memset was zeroing a lot of bytes that get initialized either later in this function or elsewhere in the submission code path. Eliminating these extra memsets saves a few nanoseconds of CPU overhead in the NVMe submission path. Note: one use of the cpl data member depended on the nvme_allocate_request memset. Since this use case is not in the primary I/O path, just memset it in that specific location before using it. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: Ife483a4d9c24c033cc7d26d94ec1700905a936f4 Reviewed-on: https://review.gerrithub.io/413153 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
7dff719f7e
commit
d76cd984aa
@ -157,14 +157,18 @@ nvme_allocate_request(struct spdk_nvme_qpair *qpair,
|
||||
STAILQ_REMOVE_HEAD(&qpair->free_req, stailq);
|
||||
|
||||
/*
|
||||
* Only memset up to (but not including) the children
|
||||
* TAILQ_ENTRY. children, and following members, are
|
||||
* Only memset/zero fields that need it. All other fields
|
||||
* will be initialized appropriately either later in this
|
||||
* function, or before they are needed later in the
|
||||
* submission patch. For example, the children
|
||||
* TAILQ_ENTRY and following members are
|
||||
* only used as part of I/O splitting so we avoid
|
||||
* memsetting them until it is actually needed.
|
||||
* They will be initialized in nvme_request_add_child()
|
||||
* if the request is split.
|
||||
*/
|
||||
memset(req, 0, offsetof(struct nvme_request, children));
|
||||
memset(req, 0, offsetof(struct nvme_request, payload_size));
|
||||
|
||||
req->cb_fn = cb_fn;
|
||||
req->cb_arg = cb_arg;
|
||||
req->payload = *payload;
|
||||
|
@ -465,6 +465,7 @@ spdk_nvme_ctrlr_cmd_abort_cpl(void *ctx, const struct spdk_nvme_cpl *cpl)
|
||||
rc = nvme_ctrlr_submit_admin_request(ctrlr, next);
|
||||
if (rc < 0) {
|
||||
SPDK_ERRLOG("Failed to submit queued abort.\n");
|
||||
memset(&next->cpl, 0, sizeof(next->cpl));
|
||||
next->cpl.status.sct = SPDK_NVME_SCT_GENERIC;
|
||||
next->cpl.status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR;
|
||||
next->cpl.status.dnr = 1;
|
||||
|
@ -180,11 +180,6 @@ nvme_payload_type(const struct nvme_payload *payload) {
|
||||
struct nvme_request {
|
||||
struct spdk_nvme_cmd cmd;
|
||||
|
||||
/**
|
||||
* Data payload for this request's command.
|
||||
*/
|
||||
struct nvme_payload payload;
|
||||
|
||||
uint8_t retries;
|
||||
|
||||
/**
|
||||
@ -192,7 +187,6 @@ struct nvme_request {
|
||||
* request which was split into multiple child requests.
|
||||
*/
|
||||
uint16_t num_children;
|
||||
uint32_t payload_size;
|
||||
|
||||
/**
|
||||
* Offset in bytes from the beginning of payload for this request.
|
||||
@ -201,6 +195,13 @@ struct nvme_request {
|
||||
uint32_t payload_offset;
|
||||
uint32_t md_offset;
|
||||
|
||||
uint32_t payload_size;
|
||||
|
||||
/**
|
||||
* Data payload for this request's command.
|
||||
*/
|
||||
struct nvme_payload payload;
|
||||
|
||||
spdk_nvme_cmd_cb cb_fn;
|
||||
void *cb_arg;
|
||||
STAILQ_ENTRY(nvme_request) stailq;
|
||||
|
Loading…
Reference in New Issue
Block a user