Commit d76cd984 authored by Jim Harris's avatar Jim Harris Committed by Daniel Verkamp
Browse files

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: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: Ife483a4d9c24c033cc7d26d94ec1700905a936f4
Reviewed-on: https://review.gerrithub.io/413153


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 7dff719f
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -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;
+1 −0
Original line number Diff line number Diff line
@@ -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;
+7 −6
Original line number Diff line number Diff line
@@ -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;