Commit 586d1d65 authored by John Levon's avatar John Levon Committed by Jim Harris
Browse files

nvmf/vfio-user: don't read from completion entry



We were accidentally reading the spdk_nvme_status from the CPL; on one
test, this was contributing to 2% of cache misses.

Signed-off-by: default avatarJohn Levon <john.levon@nutanix.com>
Change-Id: I7c967690458a183799f8d835360800d3094c3131
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11849


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarThanos Makatos <thanos.makatos@nutanix.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 7a9d089b
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -1086,8 +1086,9 @@ static int
post_completion(struct nvmf_vfio_user_ctrlr *ctrlr, struct nvmf_vfio_user_cq *cq,
		uint32_t cdw0, uint16_t sqid, uint16_t cid, uint16_t sc, uint16_t sct)
{
	struct spdk_nvme_cpl *cpl;
	struct spdk_nvme_status cpl_status = { 0 };
	const struct spdk_nvmf_registers *regs;
	struct spdk_nvme_cpl *cpl;
	int err;

	assert(ctrlr != NULL);
@@ -1123,11 +1124,17 @@ post_completion(struct nvmf_vfio_user_ctrlr *ctrlr, struct nvmf_vfio_user_cq *cq
	cpl->sqid = sqid;
	cpl->cid = cid;
	cpl->cdw0 = cdw0;
	cpl->status.dnr = 0x0;
	cpl->status.m = 0x0;
	cpl->status.sct = sct;
	cpl->status.sc = sc;
	cpl->status.p = cq->phase;

	/*
	 * This is a bitfield: instead of setting the individual bits we need
	 * directly in cpl->status, which would cause a read-modify-write cycle,
	 * we'll avoid reading from the CPL altogether by filling in a local
	 * cpl_status variable, then writing the whole thing.
	 */
	cpl_status.sct = sct;
	cpl_status.sc = sc;
	cpl_status.p = cq->phase;
	cpl->status = cpl_status;

	/* Ensure the Completion Queue Entry is visible. */
	spdk_wmb();